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 d0568f41e28..8a939f44551 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. /// @@ -583,6 +633,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, @@ -3029,6 +3098,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 215bc231ff3..a5cf03325ef 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{ @@ -6552,6 +6742,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{ @@ -7036,6 +7239,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{ @@ -7804,6 +8021,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{ @@ -8357,7 +8588,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()), } @@ -8587,6 +8818,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{ @@ -8603,6 +8854,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{ @@ -9676,6 +9941,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{ @@ -10898,6 +11177,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{ @@ -11396,6 +11688,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{ @@ -12647,14 +12953,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 } @@ -12675,6 +12981,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{ @@ -12904,6 +13231,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{ @@ -13388,6 +13728,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{ @@ -14156,14 +14510,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 } @@ -14184,6 +14538,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{ @@ -14370,8 +14745,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()), } @@ -14441,6 +14816,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{ @@ -14938,6 +15326,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{ @@ -15890,14 +16292,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 } @@ -15918,6 +16320,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{ @@ -16147,6 +16570,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{ @@ -16631,6 +17067,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 37325d58db8..7c618a213c8 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<>(); @@ -4681,6 +4856,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<>(); @@ -5015,6 +5198,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<>(); @@ -5525,6 +5717,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<>(); @@ -5888,7 +6089,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)); @@ -6038,6 +6239,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<>(); @@ -6049,6 +6265,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<>(); @@ -6781,6 +7006,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<>(); @@ -7572,6 +7806,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<>(); @@ -7915,6 +8157,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<>(); @@ -8746,13 +8997,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 */ @@ -8764,6 +9015,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<>(); @@ -8913,6 +9180,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<>(); @@ -9247,6 +9522,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<>(); @@ -9750,13 +10034,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 */ @@ -9768,6 +10052,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<>(); @@ -9889,8 +10189,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)); @@ -9935,6 +10235,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<>(); @@ -10277,6 +10585,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<>(); @@ -10911,13 +11228,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 */ @@ -10929,6 +11246,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<>(); @@ -11078,6 +11411,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<>(); @@ -11412,6 +11753,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 1ed8d96fecd..68ee15e288e 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) } @@ -3293,6 +3408,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) } @@ -3533,6 +3654,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) } @@ -3913,6 +4041,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) } @@ -4184,7 +4319,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) @@ -4293,6 +4428,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) } @@ -4301,6 +4445,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) } @@ -4856,6 +5007,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) } @@ -5455,6 +5613,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) } @@ -5702,6 +5866,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) } @@ -6341,12 +6512,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""" @@ -6355,6 +6526,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) } @@ -6466,6 +6648,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) } @@ -6706,6 +6894,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) } @@ -7077,12 +7272,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""" @@ -7091,6 +7286,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) } @@ -7180,8 +7386,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) @@ -7216,6 +7422,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) } @@ -7462,6 +7674,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) } @@ -7939,12 +8158,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""" @@ -7953,6 +8172,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) } @@ -8064,6 +8294,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) } @@ -8304,6 +8540,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 d1ba5360ef7..b51ee0a048e 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(); @@ -5766,6 +5950,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(); @@ -6155,6 +6349,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(); @@ -6784,6 +6989,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(); @@ -7290,7 +7506,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)); @@ -7471,6 +7687,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(); @@ -7484,6 +7717,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(); @@ -8694,6 +8938,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(); @@ -9746,6 +10001,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(); @@ -10146,6 +10411,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(); @@ -11293,13 +11569,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())) } @@ -11315,6 +11591,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(); @@ -11493,6 +11787,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(); @@ -11882,6 +12186,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(); @@ -12507,13 +12822,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())) } @@ -12529,6 +12844,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(); @@ -12675,8 +13008,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)); @@ -12729,6 +13062,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(); @@ -13127,6 +13470,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(); @@ -13894,13 +14248,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())) } @@ -13916,6 +14270,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(); @@ -14094,6 +14466,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(); @@ -14483,6 +14865,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 11d33822cad..a28c83bcb90 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; @@ -3211,7 +3249,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', @@ -3220,7 +3258,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)); } @@ -3371,6 +3409,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 { @@ -3388,6 +3445,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 { @@ -3574,7 +3646,7 @@ export class DistributedApplicationBuilderPromise implements PromiseLike obj.addContainer(name, image))); } @@ -3623,11 +3695,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))); @@ -4594,7 +4676,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', @@ -4603,8 +4685,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 }; @@ -5385,8 +5482,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))); } @@ -5470,6 +5567,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))); @@ -5832,6 +5934,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 }; @@ -6343,6 +6460,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))); @@ -6683,17 +6805,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)); } @@ -6712,6 +6834,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 }; @@ -6977,6 +7120,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 }; @@ -7503,6 +7661,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 }; @@ -8152,8 +8325,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))); } @@ -8162,6 +8335,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))); @@ -8242,6 +8420,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))); @@ -8392,6 +8575,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))); @@ -8850,6 +9038,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 }; @@ -9391,6 +9594,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 }; @@ -10041,6 +10259,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))); @@ -10196,6 +10419,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))); @@ -10752,6 +10980,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 }; @@ -11278,6 +11521,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 }; @@ -11963,6 +12221,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))); @@ -12113,6 +12376,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))); @@ -12579,6 +12847,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 }; @@ -13105,6 +13388,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 }; @@ -13760,6 +14058,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))); @@ -13910,6 +14213,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))); @@ -14306,6 +14614,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 }; @@ -14822,6 +15145,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))); @@ -15186,6 +15514,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 }; @@ -15702,6 +16045,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))); @@ -16125,6 +16473,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 }; @@ -16666,6 +17029,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 }; @@ -17316,6 +17694,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))); @@ -17471,6 +17854,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))); @@ -17841,17 +18229,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)); } @@ -17870,6 +18258,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 }; @@ -18135,6 +18544,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 }; @@ -18661,6 +19085,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 }; @@ -19310,8 +19749,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))); } @@ -19320,6 +19759,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))); @@ -19400,6 +19844,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))); @@ -19550,6 +19999,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))); @@ -19925,17 +20379,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)); } @@ -19954,6 +20408,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 }; @@ -20165,7 +20640,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', @@ -20174,8 +20649,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 }; @@ -20784,6 +21274,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 }; @@ -21622,8 +22127,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))); } @@ -21632,6 +22137,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))); @@ -21697,8 +22207,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))); } @@ -21722,6 +22232,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))); @@ -21877,6 +22392,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))); @@ -22317,17 +22837,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)); } @@ -22346,6 +22866,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 }; @@ -22611,6 +23152,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 }; @@ -23137,6 +23693,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 }; @@ -23801,8 +24372,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))); } @@ -23811,6 +24382,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))); @@ -23891,6 +24467,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))); @@ -24041,6 +24622,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))); @@ -24544,6 +25130,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 }; @@ -25055,6 +25656,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))); @@ -25290,7 +25896,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', @@ -25299,8 +25905,8 @@ export class ResourceWithConnectionString extends ResourceBuilderBase obj.withConnectionProperty(name, value))); } @@ -25926,6 +26532,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 }; @@ -26141,6 +26762,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)));