| File: Dcp\DcpDataTypes.cs | Web Access |
| Project: src\src\Aspire.Hosting.Native.Server\Aspire.Hosting.Native.Server.csproj (Aspire.Hosting.Native.Server) |
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Text.Json; using System.Text.Json.Serialization; using Aspire.Hosting.Native.Runtime; namespace Aspire.Hosting.Native.Dcp; internal sealed record DcpResourceEnvelope(string ApiVersion, string Kind, DcpMetadata Metadata, JsonElement Spec); internal sealed record DcpMetadata(string Name, Dictionary<string, string>? Annotations); internal sealed record DcpResource(DcpStatus? Status); internal sealed record DcpStatus { public DcpProcessState State { get; init; } public string? ContainerId { get; init; } public long? Pid { get; init; } public int? ExitCode { get; init; } public int? EffectivePort { get; init; } public string? EffectiveAddress { get; init; } } internal sealed record DcpServiceSpec( [property: JsonConverter(typeof(WorkloadProtocolConverter))] WorkloadProtocol Protocol, DcpAddressAllocationMode AddressAllocationMode) { public int? Port { get; init; } } internal sealed record DcpServiceProducer(string ServiceName, string Address, int? Port); internal sealed record DcpEnvironment(string Name, string Value); internal sealed record DcpContainerPort(int ContainerPort, string HostIP, [property: JsonConverter(typeof(WorkloadProtocolConverter))] WorkloadProtocol Protocol) { public int? HostPort { get; init; } } internal sealed record DcpVolumeMount( [property: JsonConverter(typeof(WorkloadMountKindConverter))] WorkloadMountKind Type, string Source, string Target, bool ReadOnly); internal sealed record DcpWorkloadSpec { public required DcpEnvironment[] Env { get; init; } public required string[] Args { get; init; } public string? Image { get; init; } public string? Command { get; init; } public DcpVolumeMount[]? VolumeMounts { get; init; } public DcpContainerPort[]? Ports { get; init; } public string? ExecutablePath { get; init; } public string? WorkingDirectory { get; init; } public DcpExecutionType? ExecutionType { get; init; } } internal sealed record DcpExecutionRequest(DcpExecutionState Status, DcpResourceCleanup ShutdownResourceCleanup); internal sealed record DcpExecutionResponse(DcpExecutionState Status); [JsonSerializable(typeof(DcpResourceEnvelope))] [JsonSerializable(typeof(DcpResource))] [JsonSerializable(typeof(DcpServiceSpec))] [JsonSerializable(typeof(DcpServiceProducer[]))] [JsonSerializable(typeof(DcpWorkloadSpec))] [JsonSerializable(typeof(DcpExecutionRequest))] [JsonSerializable(typeof(DcpExecutionResponse))] [JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, RespectNullableAnnotations = true, MaxDepth = 32)] internal sealed partial class DcpJsonContext : JsonSerializerContext;