// Copyright Epic Games, Inc. All Rights Reserved. using System; using System.Collections.Generic; using System.Linq; using EpicGames.Horde.Jobs.Graphs; #pragma warning disable CA2227 // Change x to be read-only by removing the property setter namespace EpicGames.Horde.Issues { /// /// Configuration for an issue workflow /// public class GetWorkflowResponse : IWorkflow { /// public WorkflowId Id { get; set; } /// public List ReportTimes { get; set; } IReadOnlyList IWorkflow.ReportTimes => ReportTimes; /// public string? SummaryTab { get; set; } /// public string? ReportChannel { get; set; } /// public bool ReportWarnings { get; set; } = true; /// public bool GroupIssuesByTemplate { get; set; } = true; /// public string? TriageChannel { get; set; } /// public string? TriagePrefix { get; set; } /// public string? TriageSuffix { get; set; } /// public string? TriageInstructions { get; set; } /// public string? TriageAlias { get; set; } /// public bool TriageErrors { get; set; } = true; /// public bool TriageWarnings { get; set; } = true; /// public Dictionary? TriageTypeAliases { get; set; } IReadOnlyDictionary? IWorkflow.TriageTypeAliases => TriageTypeAliases; /// public string? EscalateAlias { get; set; } /// public List EscalateTimes { get; set; } IReadOnlyList IWorkflow.EscalateTimes => EscalateTimes; /// public int MaxMentions { get; set; } /// public bool AllowMentions { get; set; } /// public bool InviteRestrictedUsers { get; set; } /// public bool SkipWhenEmpty { get; set; } /// public bool ShowMergeWarnings { get; set; } /// public NodeAnnotations Annotations { get; set; } = new NodeAnnotations(); IReadOnlyNodeAnnotations IWorkflow.Annotations => Annotations; /// public GetWorkflowExternalIssuesResponse? ExternalIssues { get; set; } IWorkflowExternalIssues? IWorkflow.ExternalIssues => ExternalIssues; /// public List? IssueHandlers { get; set; } IReadOnlyList? IWorkflow.IssueHandlers => IssueHandlers; /// /// Constructor /// public GetWorkflowResponse() { ReportTimes = new List(); EscalateTimes = new List(); } /// /// Constructor /// public GetWorkflowResponse(IWorkflow workflow) { Id = workflow.Id; ReportTimes = workflow.ReportTimes.ToList(); SummaryTab = workflow.SummaryTab; ReportChannel = workflow.ReportChannel; ReportWarnings = workflow.ReportWarnings; GroupIssuesByTemplate = workflow.GroupIssuesByTemplate; TriageChannel = workflow.TriageChannel; TriagePrefix = workflow.TriagePrefix; TriageSuffix = workflow.TriageSuffix; TriageInstructions = workflow.TriageInstructions; TriageAlias = workflow.TriageAlias; TriageTypeAliases = workflow.TriageTypeAliases?.ToDictionary(); TriageWarnings = workflow.TriageWarnings; TriageErrors = workflow.TriageErrors; EscalateAlias = workflow.EscalateAlias; EscalateTimes = workflow.EscalateTimes.ToList(); MaxMentions = workflow.MaxMentions; AllowMentions = workflow.AllowMentions; InviteRestrictedUsers = workflow.InviteRestrictedUsers; SkipWhenEmpty = workflow.SkipWhenEmpty; ShowMergeWarnings = workflow.ShowMergeWarnings; Annotations = new NodeAnnotations(workflow.Annotations); ExternalIssues = (workflow.ExternalIssues == null) ? null : new GetWorkflowExternalIssuesResponse(workflow.ExternalIssues); IssueHandlers = workflow.IssueHandlers?.ToList(); } } /// /// External issue tracking configuration for a workflow /// public class GetWorkflowExternalIssuesResponse : IWorkflowExternalIssues { /// public string ProjectKey { get; set; } = String.Empty; /// public string DefaultComponentId { get; set; } = String.Empty; /// public string DefaultIssueTypeId { get; set; } = String.Empty; /// /// Constructor /// public GetWorkflowExternalIssuesResponse() { ProjectKey = String.Empty; DefaultComponentId = String.Empty; DefaultIssueTypeId = String.Empty; } /// /// Constructor /// public GetWorkflowExternalIssuesResponse(IWorkflowExternalIssues issues) { ProjectKey = issues.ProjectKey; DefaultComponentId = issues.DefaultComponentId; DefaultIssueTypeId = issues.DefaultIssueTypeId; } } }