Refactor code structure for improved readability and maintainability
This commit is contained in:
@@ -19,3 +19,4 @@ namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
public string CreatedBy { get; set; } = "System";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,3 +36,4 @@ namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
public string CreatedBy { get; set; } = "System";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,13 +7,21 @@ namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
{
|
||||
[Column(Order = 2)]
|
||||
public Guid TemplateId { get; set; }
|
||||
|
||||
[Column(Order = 3)]
|
||||
public Guid? DeploymentRuleId { get; set; }
|
||||
|
||||
[Column(Order = 4)]
|
||||
[DefaultValueSql("'New'")]
|
||||
public string Status { get; set; }
|
||||
|
||||
public TemplateModel Template { get; set; }
|
||||
public DeploymentRuleModel? DeploymentRule { get; set; }
|
||||
|
||||
public ICollection<DeploymentModel> Deployments { get; set; }
|
||||
public ICollection<DeploymentTemplateSelectionModel> TemplateSelections { get; set; } = new List<DeploymentTemplateSelectionModel>();
|
||||
public ICollection<DeploymentParameterValueModel> ParameterValues { get; set; } = new List<DeploymentParameterValueModel>();
|
||||
public ICollection<DeploymentTargetAssignmentModel> TargetAssignments { get; set; } = new List<DeploymentTargetAssignmentModel>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
{
|
||||
@@ -44,3 +44,4 @@ namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
public ICollection<QueueJobStepModel> Steps { get; set; } = new List<QueueJobStepModel>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
{
|
||||
@@ -38,3 +38,4 @@ namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
public QueueJobStepModel? DependsOnQueueJobStep { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
{
|
||||
@@ -8,7 +8,7 @@ namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
public Guid QueueJobId { get; set; }
|
||||
|
||||
[Column(Order = 2)]
|
||||
public Guid VirtualMachineId { get; set; }
|
||||
public Guid TargetId { get; set; }
|
||||
|
||||
[Column(Order = 3)]
|
||||
public Guid DeploymentGroupId { get; set; }
|
||||
@@ -28,3 +28,4 @@ namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
public QueueJobModel QueueJob { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
{
|
||||
public class DeploymentParameterValueModel : BaseModel
|
||||
{
|
||||
[Column(Order = 1)]
|
||||
public Guid DeploymentGroupId { get; set; }
|
||||
|
||||
[Column(Order = 2)]
|
||||
public Guid? DeploymentTemplateSelectionId { get; set; }
|
||||
|
||||
[Column(Order = 3)]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
[Column(Order = 4)]
|
||||
public string ValueJson { get; set; } = "{}";
|
||||
|
||||
[Column(Order = 5)]
|
||||
public bool IsSecretReference { get; set; }
|
||||
|
||||
[Column(Order = 6)]
|
||||
public bool IsOverride { get; set; } = true;
|
||||
|
||||
public DeploymentGroupModel DeploymentGroup { get; set; } = null!;
|
||||
public DeploymentTemplateSelectionModel? DeploymentTemplateSelection { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
{
|
||||
@@ -16,3 +16,4 @@ namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
public ICollection<DeploymentRuleStepModel> Steps { get; set; } = new List<DeploymentRuleStepModel>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
{
|
||||
@@ -25,3 +25,4 @@ namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
public DeploymentRuleModel DeploymentRule { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
{
|
||||
public class DeploymentTargetAssignmentModel : BaseModel
|
||||
{
|
||||
[Column(Order = 1)]
|
||||
public Guid DeploymentGroupId { get; set; }
|
||||
|
||||
[Column(Order = 2)]
|
||||
public Guid TargetId { get; set; }
|
||||
|
||||
[Column(Order = 3)]
|
||||
public string RoleKey { get; set; } = "Node";
|
||||
|
||||
[Column(Order = 4)]
|
||||
public int SortOrder { get; set; }
|
||||
|
||||
[Column(Order = 5)]
|
||||
public string NodeDataJson { get; set; } = "{}";
|
||||
|
||||
public DeploymentGroupModel DeploymentGroup { get; set; } = null!;
|
||||
public TargetModel Target { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,16 +7,15 @@ namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
[Column(Order = 2)]
|
||||
public Guid DeploymentGroupId { get; set; }
|
||||
[Column(Order = 3)]
|
||||
public Guid VirtualMachineId { get; set; }
|
||||
public Guid TargetId { get; set; }
|
||||
[Column(Order = 4)]
|
||||
public string Status { get; set; }
|
||||
[Column(Order = 5)]
|
||||
public string JSONData { get; set; }
|
||||
|
||||
public DeploymentGroupModel DeploymentGroup { get; set; }
|
||||
public VirtualMachineModel VirtualMachine { get; set; }
|
||||
public TargetModel Target { get; set; }
|
||||
|
||||
public ICollection<JobModel> Jobs { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
{
|
||||
public class DeploymentTemplateSelectionModel : BaseModel
|
||||
{
|
||||
[Column(Order = 1)]
|
||||
public Guid DeploymentGroupId { get; set; }
|
||||
|
||||
[Column(Order = 2)]
|
||||
public Guid TemplateVersionId { get; set; }
|
||||
|
||||
[Column(Order = 3)]
|
||||
public string TemplateRole { get; set; } = "Service";
|
||||
|
||||
[Column(Order = 4)]
|
||||
public int SortOrder { get; set; }
|
||||
|
||||
[Column(Order = 5)]
|
||||
public string? Alias { get; set; }
|
||||
|
||||
public DeploymentGroupModel DeploymentGroup { get; set; } = null!;
|
||||
public TemplateVersionModel TemplateVersion { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,8 @@ namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
|
||||
public ICollection<EnvironmentDomainsModel> EnvironmentDomains { get; set; }
|
||||
|
||||
public ICollection<VirtualMachineModel> VirtualMachines { get; set; }
|
||||
public ICollection<TargetModel> Targets { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,4 +12,4 @@ namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
public Guid DomainId { get; set; }
|
||||
public DomainModel Domain { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
{
|
||||
public static class EnvironmentTypes
|
||||
public static class EnvironmentHostingTypes
|
||||
{
|
||||
public const string OnPrem = "OnPrem";
|
||||
public const string AzureTenant = "AzureTenant";
|
||||
public const string M365Tenant = "M365Tenant";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,20 +8,24 @@ namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
public string Name { get; set; }
|
||||
|
||||
[Column(Order = 2)]
|
||||
public string EnvironmentType { get; set; } = EnvironmentTypes.OnPrem;
|
||||
public string EnvironmentType { get; set; } = EnvironmentStages.Test;
|
||||
|
||||
[Column(Order = 3)]
|
||||
public string? ProviderType { get; set; }
|
||||
public string HostingType { get; set; } = EnvironmentHostingTypes.OnPrem;
|
||||
|
||||
[Column(Order = 4)]
|
||||
public string? TenantId { get; set; }
|
||||
public string? ProviderType { get; set; }
|
||||
|
||||
[Column(Order = 5)]
|
||||
public string? SubscriptionId { get; set; }
|
||||
public string? TenantId { get; set; }
|
||||
|
||||
[Column(Order = 6)]
|
||||
public string? SubscriptionId { get; set; }
|
||||
|
||||
[Column(Order = 7)]
|
||||
public string? MetadataJson { get; set; }
|
||||
|
||||
public ICollection<EnvironmentDomainsModel> EnvironmentDomains { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
{
|
||||
public static class EnvironmentStages
|
||||
{
|
||||
public const string Development = "Development";
|
||||
public const string Test = "Test";
|
||||
public const string QA = "QA";
|
||||
public const string Production = "Production";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
{
|
||||
public class EventModel : BaseModel
|
||||
{
|
||||
[Column(Order = 1)]
|
||||
public Guid RunbookId { get; set; }
|
||||
|
||||
[Column(Order = 2)]
|
||||
public string Class { get; set; }
|
||||
[Column(Order = 3)]
|
||||
public string Method { get; set; }
|
||||
[Column(Order = 4)]
|
||||
public string RestEndpointMethod { get; set; }
|
||||
[Column(Order = 5)]
|
||||
public string RestEndpointOperation { get; set; }
|
||||
|
||||
public RunbookModel Runbook { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
{
|
||||
public class JobModel : BaseModel
|
||||
{
|
||||
[Column(Order = 1)]
|
||||
public Guid DeploymentId { get; set; }
|
||||
[Column(Order = 2)]
|
||||
public Guid RunbookId { get; set; }
|
||||
|
||||
public DeploymentModel Deployment { get; set; }
|
||||
public RunbookModel Runbook { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -14,3 +14,4 @@ namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
public ICollection<OptionModel> Options { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,3 +17,4 @@ namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
public ICollection<TemplateOptionModel> TemplateOptions { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
{
|
||||
public static class QueueJobStatus
|
||||
{
|
||||
@@ -11,3 +11,4 @@ namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
public const string Cancelled = "Cancelled";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
{
|
||||
public static class QueueJobStepType
|
||||
{
|
||||
@@ -6,3 +6,4 @@ namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
public const string Approval = "Approval";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
{
|
||||
public static class QueueJobType
|
||||
{
|
||||
@@ -6,3 +6,4 @@ namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
public const string DeploymentRequested = "DeploymentRequested";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
{
|
||||
public class RunbookModel : BaseModel
|
||||
{
|
||||
[Column(Order = 1)]
|
||||
public string Name { get; set; }
|
||||
[Column(Order = 2)]
|
||||
public string Description { get; set; }
|
||||
|
||||
public ICollection<JobModel> Jobs { get; set; }
|
||||
|
||||
public ICollection<EventModel> Events { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -18,3 +18,4 @@ namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
public ICollection<ServiceRoleDefinitionModel> RoleDefinitions { get; set; } = new List<ServiceRoleDefinitionModel>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
{
|
||||
@@ -19,3 +19,4 @@ namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
public ServiceModel Service { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
{
|
||||
public class VirtualMachineModel : BaseModel
|
||||
public class TargetModel : BaseModel
|
||||
{
|
||||
[Column(Order = 1)]
|
||||
public Guid? DomainID { get; set; }
|
||||
@@ -12,9 +10,15 @@ namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
public string Name { get; set; }
|
||||
|
||||
[Column(Order = 3)]
|
||||
public string? ExternalId { get; set; }
|
||||
public string TargetType { get; set; } = "VirtualMachine";
|
||||
|
||||
[Column(Order = 4)]
|
||||
public string ProviderType { get; set; } = "OnPrem";
|
||||
|
||||
[Column(Order = 5)]
|
||||
public string? ExternalId { get; set; }
|
||||
|
||||
[Column(Order = 6)]
|
||||
public string? MetadataJson { get; set; }
|
||||
|
||||
public DomainModel? Domain { get; set; }
|
||||
@@ -23,3 +27,4 @@ namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,3 +20,4 @@ namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
public ICollection<TemplateModel> Templates { get; set; } = new List<TemplateModel>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@ namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
|
||||
public ICollection<DeploymentGroupModel> DeploymentGroups { get; set; }
|
||||
public ICollection<TemplateOptionModel> TemplateOptions { get; set; }
|
||||
public ICollection<TemplateVersionModel> TemplateVersions { get; set; } = new List<TemplateVersionModel>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -17,3 +17,4 @@ namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace Microsoft.SelfService.Portal.Core.API.Models
|
||||
{
|
||||
public class TemplateVersionModel : BaseModel
|
||||
{
|
||||
[Column(Order = 1)]
|
||||
public Guid TemplateId { get; set; }
|
||||
|
||||
[Column(Order = 2)]
|
||||
public string Version { get; set; } = "1.0.0";
|
||||
|
||||
[Column(Order = 3)]
|
||||
public string JsonData { get; set; } = "{}";
|
||||
|
||||
[Column(Order = 4)]
|
||||
public string JsonHash { get; set; } = string.Empty;
|
||||
|
||||
[Column(Order = 5)]
|
||||
public string SchemaVersion { get; set; } = "1.0";
|
||||
|
||||
[Column(Order = 6)]
|
||||
public bool IsPublished { get; set; }
|
||||
|
||||
[Column(Order = 7)]
|
||||
public DateTime? PublishedAt { get; set; }
|
||||
|
||||
[Column(Order = 8)]
|
||||
public string? PublishedBy { get; set; }
|
||||
|
||||
public TemplateModel Template { get; set; } = null!;
|
||||
|
||||
public void SetJsonData(string jsonData)
|
||||
{
|
||||
JsonData = string.IsNullOrWhiteSpace(jsonData) ? "{}" : jsonData;
|
||||
JsonHash = ComputeSha256(JsonData);
|
||||
}
|
||||
|
||||
public static string ComputeSha256(string value)
|
||||
{
|
||||
var bytes = SHA256.HashData(Encoding.UTF8.GetBytes(value ?? string.Empty));
|
||||
return Convert.ToHexString(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user