// Copyright Epic Games, Inc. All Rights Reserved. using System; using System.Collections.Generic; using System.Text.Json.Serialization; using EpicGames.Core; using EpicGames.Horde.Commits; using EpicGames.Horde.Storage; using EpicGames.Horde.Streams; #pragma warning disable CA2227 namespace EpicGames.Horde.Artifacts { /// /// Creates a new artifact /// /// Name of the artifact /// Additional search keys tagged on the artifact /// Description for the artifact /// Stream to create the artifact for /// Keys used to identify the artifact /// Metadata for the artifact public record CreateArtifactRequest(ArtifactName Name, ArtifactType Type, string? Description, StreamId? StreamId, List Keys, List Metadata) { /// /// Legacy Perforce changelist number. /// [Obsolete("Use CommitId instead")] public int Change { get => _change ?? _commitId?.TryGetPerforceChange() ?? -1; set => _change = value; } int? _change; /// /// Commit for the new artifact /// public CommitId CommitId { get => _commitId ?? CommitId.FromPerforceChange(_change) ?? CommitId.Empty; set => _commitId = value; } CommitId? _commitId; } /// /// Information about a created artifact /// /// Identifier for the new artifact /// Resolved commit id for the artifact /// Namespace that should be written to with artifact data /// Ref to write to /// Ref for the artifact at the changelist prior to this one. Can be used to deduplicate against. /// Token which can be used to upload blobs for the artifact, and read blobs from the previous artifact public record CreateArtifactResponse(ArtifactId ArtifactId, CommitIdWithOrder CommitId, NamespaceId NamespaceId, RefName RefName, RefName? PrevRefName, string Token); /// /// Type of data to download for an artifact /// public enum DownloadArtifactFormat { /// /// Download as a zip file /// Zip, /// /// Download as a UGS link /// Ugs } /// /// Describes an artifact /// public class GetArtifactResponse { /// public ArtifactId Id { get; set; } /// public ArtifactName Name { get; set; } /// public ArtifactType Type { get; set; } /// public string? Description { get; set; } /// public StreamId StreamId { get; set; } /// /// Change number /// [Obsolete("Use CommitId instead")] public int Change { get => _change ?? _commitId?.TryGetPerforceChange() ?? -1; set => _change = value; } int? _change; /// public CommitIdWithOrder CommitId { get => _commitId ?? CommitIdWithOrder.FromPerforceChange(_change) ?? CommitIdWithOrder.Empty; set => _commitId = value; } CommitIdWithOrder? _commitId; /// public IReadOnlyList Keys { get; set; } /// public IReadOnlyList Metadata { get; set; } /// public NamespaceId NamespaceId { get; set; } /// public RefName RefName { get; set; } /// public DateTime CreatedAtUtc { get; set; } /// /// Default constructor /// [JsonConstructor] public GetArtifactResponse() { Keys = Array.Empty(); Metadata = Array.Empty(); } /// /// Constructor /// /// public GetArtifactResponse(IArtifact artifact) { Id = artifact.Id; Name = artifact.Name; Type = artifact.Type; Description = artifact.Description; StreamId = artifact.StreamId; CommitId = artifact.CommitId; Keys = artifact.Keys; Metadata = artifact.Metadata; NamespaceId = artifact.NamespaceId; RefName = artifact.RefName; CreatedAtUtc = artifact.CreatedAtUtc; } } /// /// Result of an artifact search /// public class FindArtifactsResponse { /// /// List of artifacts matching the search criteria /// public List Artifacts { get; set; } = new List(); } /// /// Describes a file within an artifact /// public class GetArtifactFileEntryResponse { /// /// Name of this file /// public string Name { get; } /// /// Length of this entry /// public long Length { get; } /// /// Hash of the target node /// public IoHash Hash { get; } /// /// Constructor /// public GetArtifactFileEntryResponse(string name, long length, IoHash hash) { Name = name; Length = length; Hash = hash; } } /// /// Describes a file within an artifact /// public class GetArtifactDirectoryEntryResponse : GetArtifactDirectoryResponse { /// /// Name of this file /// public string Name { get; } /// /// Length of this entry /// public long Length { get; } /// /// Hash of the target node /// public IoHash Hash { get; } /// /// Constructor /// public GetArtifactDirectoryEntryResponse(string name, long length, IoHash hash) { Name = name; Length = length; Hash = hash; } } /// /// Describes a directory within an artifact /// public class GetArtifactDirectoryResponse { /// /// Names of sub-directories /// public List? Directories { get; set; } /// /// Files within the directory /// public List? Files { get; set; } } /// /// Request to create a zip file with artifact data /// public class CreateZipRequest { /// /// Filter lines for the zip. Uses standard syntax. /// public List Filter { get; set; } = new List(); } }