// Copyright Epic Games, Inc. All Rights Reserved. using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using EpicGames.Horde.Commits; using EpicGames.Horde.Streams; namespace EpicGames.Horde.Artifacts { /// /// Interface for a collection of artifacts /// public interface IArtifactCollection { /// /// Creates a new artifact /// /// Name of the artifact /// Type identifier for the artifact /// Description for the artifact /// Stream that the artifact was built from /// Commit that the artifact was built from /// Keys for the artifact /// Metadata for the artifact /// Cancellation token for the operation /// The new log file document Task CreateAsync(ArtifactName name, ArtifactType type, string? description, StreamId streamId, CommitId commitId, IEnumerable keys, IEnumerable metadata, CancellationToken cancellationToken = default); /// /// Finds artifacts with the given keys. /// /// Identifiers to return /// Stream to find artifacts for /// Minimum commit for the artifacts (inclusive) /// Maximum commit for the artifacts (inclusive) /// Name of the artifact to search for /// The artifact type /// Set of keys, all of which must all be present on any returned artifacts /// Maximum number of results to return /// Cancellation token for the operation /// Sequence of artifacts. Ordered by descending CL order, then by descending order in which they were created. IAsyncEnumerable FindAsync(ArtifactId[]? ids = null, StreamId? streamId = null, CommitId? minCommitId = null, CommitId? maxCommitId = null, ArtifactName? name = null, ArtifactType? type = null, IEnumerable? keys = null, int maxResults = 100, CancellationToken cancellationToken = default); /// /// Gets an artifact by ID /// /// Unique id of the artifact /// Cancellation token for the operation /// The artifact document Task GetAsync(ArtifactId artifactId, CancellationToken cancellationToken = default); } /// /// Extension methods for artifacts /// public static class ArtifactCollectionExtensions { /// /// Finds artifacts with the given keys. /// /// Collection to operate on /// Stream to find artifacts for /// Minimum commit for the artifacts (inclusive) /// Maximum commit for the artifacts (inclusive) /// Name of the artifact to search for /// The artifact type /// Set of keys, all of which must all be present on any returned artifacts /// Maximum number of results to return /// Cancellation token for the operation /// Sequence of artifacts. Ordered by descending CL order, then by descending order in which they were created. public static IAsyncEnumerable FindAsync(this IArtifactCollection artifactCollection, StreamId? streamId = null, CommitId? minCommitId = null, CommitId? maxCommitId = null, ArtifactName? name = null, ArtifactType? type = null, IEnumerable? keys = null, int maxResults = 100, CancellationToken cancellationToken = default) => artifactCollection.FindAsync(null, streamId, minCommitId, maxCommitId, name, type, keys, maxResults, cancellationToken); } }