// Copyright Epic Games, Inc. All Rights Reserved. using System.Collections.Generic; using EpicGames.Core; using EpicGames.Horde.Commits; using EpicGames.Horde.Common; #pragma warning disable CA1716 // Rename virtual/interface member x so that it no longer conflicts with the reserved language keyword 'Default'. Using a reserved keyword as the name of a virtual/interface member makes it harder for consumers in other languages to override/implement the member. #pragma warning disable CA2227 // Change x to be read-only by removing the property setter namespace EpicGames.Horde.Jobs.Templates { /// /// Document describing a job template. These objects are considered immutable once created and uniquely referenced by hash, in order to de-duplicate across all job runs. /// public interface ITemplate { /// /// Hash of this template /// ContentHash Hash { get; } /// /// Name of the template. /// string Name { get; } /// /// Description for the template /// string? Description { get; } /// /// Priority of this job /// Priority? Priority { get; } /// /// Whether to allow preflights for this job type /// bool AllowPreflights { get; } /// /// Whether to always issues for jobs using this template /// bool UpdateIssues { get; } /// /// Whether to promote issues by default for jobs using this template /// bool PromoteIssuesByDefault { get; } /// /// Agent type to use for parsing the job state /// string? InitialAgentType { get; } /// /// Path to a file within the stream to submit to generate a new changelist for jobs /// string? SubmitNewChange { get; } /// /// Description for new changelists /// string? SubmitDescription { get; } /// /// Optional predefined user-defined properties for this job /// IReadOnlyList Arguments { get; } /// /// Parameters for this template /// IReadOnlyList Parameters { get; } } /// /// Base class for parameters used to configure templates via the new build dialog /// public interface ITemplateParameter { /// /// Gets the arguments for a job given a set of parameters /// /// Map of parameter id to value /// Whether this is a scheduled build /// Receives command line arguments for the job void GetArguments(IReadOnlyDictionary parameters, bool scheduledBuild, List arguments); /// /// Gets the default arguments for this parameter and its children /// /// List of default parameters /// Whether the arguments are being queried for a scheduled build void GetDefaultParameters(Dictionary parameters, bool scheduledBuild); } /// /// Allows the user to toggle an option on or off /// public interface ITemplateBoolParameter : ITemplateParameter { /// /// Identifier for this parameter /// ParameterId Id { get; } /// /// Label to display next to this parameter. /// string Label { get; } /// /// Argument to add if this parameter is enabled /// string? ArgumentIfEnabled { get; } /// /// Arguments to add if this parameter is enabled /// IReadOnlyList? ArgumentsIfEnabled { get; } /// /// Argument to add if this parameter is disabled /// string? ArgumentIfDisabled { get; } /// /// Arguments to add if this parameter is disabled /// IReadOnlyList? ArgumentsIfDisabled { get; } /// /// Whether this option should be enabled by default /// bool Default { get; } /// /// Whether this option should be enabled by default /// bool? ScheduleOverride { get; } /// /// Tool tip text to display /// string? ToolTip { get; } } /// /// Free-form text entry parameter /// public interface ITemplateTextParameter : ITemplateParameter { /// /// Identifier for this parameter /// ParameterId Id { get; } /// /// Label to display next to this parameter. Should default to the parameter name. /// string Label { get; } /// /// Argument to add (will have the value of this field appended) /// string Argument { get; } /// /// Default value for this argument /// string Default { get; } /// /// Override for this argument in scheduled builds. /// string? ScheduleOverride { get; } /// /// Hint text to display when the field is empty /// string? Hint { get; } /// /// Regex used to validate values entered into this text field. /// string? Validation { get; } /// /// Message displayed to explain valid values if validation fails. /// string? ValidationError { get; } /// /// Tool tip text to display /// string? ToolTip { get; } } /// /// Style of list parameter /// public enum TemplateListParameterStyle { /// /// Regular drop-down list. One item is always selected. /// List, /// /// Drop-down list with checkboxes /// MultiList, /// /// Tag picker from list of options /// TagPicker, } /// /// Allows the user to select a value from a constrained list of choices /// public interface ITemplateListParameter : ITemplateParameter { /// /// Label to display next to this parameter. /// string Label { get; } /// /// Style of picker parameter to use /// TemplateListParameterStyle Style { get; } /// /// List of values to display in the list /// IReadOnlyList Items { get; } /// /// Tool tip text to display /// string? ToolTip { get; } } /// /// Possible option for a list parameter /// public interface ITemplateListParameterItem { /// /// Identifier for this parameter /// ParameterId Id { get; } /// /// Group to display this entry in /// string? Group { get; } /// /// Text to display for this option. /// string Text { get; } /// /// Argument to add if this parameter is enabled. /// string? ArgumentIfEnabled { get; } /// /// Arguments to add if this parameter is enabled. /// IReadOnlyList? ArgumentsIfEnabled { get; } /// /// Argument to add if this parameter is disabled. /// string? ArgumentIfDisabled { get; } /// /// Arguments to add if this parameter is disabled. /// IReadOnlyList? ArgumentsIfDisabled { get; } /// /// Whether this item is selected by default /// bool Default { get; } /// /// Whether this item is selected by default /// bool? ScheduleOverride { get; } } /// /// Extension methods for templates /// public static class TemplateExtensions { /// /// Gets the full argument list for a template /// public static void GetArgumentsForParameters(this ITemplate template, IReadOnlyDictionary parameters, List arguments) { arguments.AddRange(template.Arguments); foreach (ITemplateParameter parameter in template.Parameters) { parameter.GetArguments(parameters, false, arguments); } } /// /// Gets the arguments for default options in this template. Does not include the standard template arguments. /// /// List of default arguments public static void GetDefaultParameters(this ITemplate template, Dictionary parameters, bool scheduledBuild) { foreach (ITemplateParameter parameter in template.Parameters) { parameter.GetDefaultParameters(parameters, scheduledBuild); } } } /// /// Query selecting the base changelist to use /// public interface IChangeQuery { /// /// Name of this query, for display on the dashboard. /// string? Name { get; } /// /// Condition to evaluate before deciding to use this query. May query tags in a preflight. /// Condition? Condition { get; } /// /// The template id to query /// TemplateId? TemplateId { get; } /// /// The target to query /// string? Target { get; } /// /// Whether to match a job that produced warnings /// IReadOnlyList? Outcomes { get; } /// /// Finds the last commit with this tag /// CommitTag? CommitTag { get; } } }