Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated select classes from nested to file-scoped namespaces #1133

Merged
merged 1 commit into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
namespace Nox.Solution
namespace Nox.Solution;

public class IntegrationScheduleRetryPolicy
{
public class IntegrationScheduleRetryPolicy
{
public int? Limit { get; internal set; }
public int? DelaySeconds { get; internal set; }
public int? DoubleDelayLimit { get; internal set; }
}
public int? Limit { get; internal set; }
public int? DelaySeconds { get; internal set; }
public int? DoubleDelayLimit { get; internal set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@
using Nox.Types;
using Nox.Yaml.Attributes;

namespace Nox.Solution
namespace Nox.Solution;

[Title("Definition namespace for a file type integration source.")]
[Description("This section specified attributes related to an integration source of type File. Attributes include the name and attributes of the file to ingest.")]
[AdditionalProperties(false)]
public class IntegrationSourceFileOptions
{
[Title("Definition namespace for a file type integration source.")]
[Description("This section specified attributes related to an integration source of type File. Attributes include the name and attributes of the file to ingest.")]
[Required]
[Title("The file name.")]
[Description("The name of the file that will be ingested.")]
public string Filename { get; set; } = null!;

[Required]
[Title("The attributes of the source file record.")]
[Description("One or more attributes describing the composition of the source file record.")]
[AdditionalProperties(false)]
public class IntegrationSourceFileOptions
{
[Required]
[Title("The file name.")]
[Description("The name of the file that will be ingested.")]
public string Filename { get; set; } = null!;

[Required]
[Title("The attributes of the source file record.")]
[Description("One or more attributes describing the composition of the source file record.")]
[AdditionalProperties(false)]
public IReadOnlyList<NoxSimpleTypeDefinition> RecordAttributes { get; internal set; } = new List<NoxSimpleTypeDefinition>();
}
public IReadOnlyList<NoxSimpleTypeDefinition> RecordAttributes { get; internal set; } = new List<NoxSimpleTypeDefinition>();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@
using Nox.Types;
using Nox.Yaml.Attributes;

namespace Nox.Solution
namespace Nox.Solution;

[Title("Definition namespace for a Message Queue integration source.")]
[Description("This section specified attributes related to an integration source of type Message Queue. Attributes include the name of the source queue or topic.")]
[AdditionalProperties(false)]
public class IntegrationSourceMessageQueueOptions
{
[Title("Definition namespace for a Message Queue integration source.")]
[Description("This section specified attributes related to an integration source of type Message Queue. Attributes include the name of the source queue or topic.")]
[Required]
[Title("The source name.")]
[Description("The name of the queue or topic subscription from which messages will be consumed.")]
public string SourceName { get; set; } = null!;

[Required]
[Title("The attributes of the source message.")]
[Description("One or more attributes describing the composition of the source message.")]
[AdditionalProperties(false)]
public class IntegrationSourceMessageQueueOptions
{
[Required]
[Title("The source name.")]
[Description("The name of the queue or topic subscription from which messages will be consumed.")]
public string SourceName { get; set; } = null!;

[Required]
[Title("The attributes of the source message.")]
[Description("One or more attributes describing the composition of the source message.")]
[AdditionalProperties(false)]
public IReadOnlyList<NoxSimpleTypeDefinition> MessageAttributes { get; internal set; } = new List<NoxSimpleTypeDefinition>();
}
public IReadOnlyList<NoxSimpleTypeDefinition> MessageAttributes { get; internal set; } = new List<NoxSimpleTypeDefinition>();
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
using System.Collections.Generic;
using Nox.Yaml.Attributes;

namespace Nox.Solution
namespace Nox.Solution;

[Title("Definition namespace for watermark columns on the integration source data.")]
[Description("This section lists the column(s) on the source data used to indicate whether a record in the source data has changed.")]
[AdditionalProperties(false)]
public class IntegrationSourceWatermark
{
[Title("Definition namespace for watermark columns on the integration source data.")]
[Description("This section lists the column(s) on the source data used to indicate whether a record in the source data has changed.")]
[AdditionalProperties(false)]
public class IntegrationSourceWatermark
{
[Title("Column(s) in datetime format used for watermark purpose.")]
[Description("List datetime columns to be compared to target data to indicate if data has changed.")]
public IReadOnlyList<string>? DateColumns { get; internal set; }
[Title("Column(s) in datetime format used for watermark purpose.")]
[Description("List datetime columns to be compared to target data to indicate if data has changed.")]
public IReadOnlyList<string>? DateColumns { get; internal set; }

[Title("Sequential key column used for watermark purpose.")]
[Description("Specify a sequential key columns to be compared to target data to indicate if data has changed.")]
public string? SequentialKeyColumn { get; internal set; }
}
[Title("Sequential key column used for watermark purpose.")]
[Description("Specify a sequential key columns to be compared to target data to indicate if data has changed.")]
public string? SequentialKeyColumn { get; internal set; }
}
37 changes: 18 additions & 19 deletions src/Nox.Solution/Models/Environment/Environment.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
using Nox.Yaml.Attributes;

namespace Nox.Solution
namespace Nox.Solution;

[GenerateJsonSchema]
[Title("A definition for a run-time environment.")]
[Description("A definition for the name, production status and other pertinent information pertaining to a run-time environment.")]
[AdditionalProperties(false)]
public class Environment : DefinitionBase
{
[GenerateJsonSchema]
[Title("A definition for a run-time environment.")]
[Description("A definition for the name, production status and other pertinent information pertaining to a run-time environment.")]
[AdditionalProperties(false)]
public class Environment : DefinitionBase
{
[Required]
[Title("A short name for the environment. Contains no spaces.")]
[Description("The name of the run-time environment. Each environment name should be unique within a solution.")]
[Pattern(@"^[^\s]*$")]
public string Name { get; internal set; } = null!;
[Required]
[Title("A short name for the environment. Contains no spaces.")]
[Description("The name of the run-time environment. Each environment name should be unique within a solution.")]
[Pattern(@"^[^\s]*$")]
public string Name { get; internal set; } = null!;

[Title("A short description of the run-time environment.")]
[Description("The description of the run-time environment. Try to include the purpose or use of the environment.")]
public string? Description { get; internal set; }
[Title("A short description of the run-time environment.")]
[Description("The description of the run-time environment. Try to include the purpose or use of the environment.")]
public string? Description { get; internal set; }

[Title("Whether this environment is a production environment (true) or not (false).")]
[Description("Specifies whether this environment is used for production or not. Affects how devops processes and the NOX runtime is configured.")]
public bool IsProduction { get; internal set; } = false;
}
[Title("Whether this environment is a production environment (true) or not (false).")]
[Description("Specifies whether this environment is used for production or not. Affects how devops processes and the NOX runtime is configured.")]
public bool IsProduction { get; internal set; } = false;
}
61 changes: 30 additions & 31 deletions src/Nox.Solution/Models/Infrastructure/Base/ServerBase.cs
Original file line number Diff line number Diff line change
@@ -1,40 +1,39 @@
using Nox.Yaml.Attributes;

namespace Nox.Solution
namespace Nox.Solution;

[AdditionalProperties(false)]
public class ServerBase
{
[AdditionalProperties(false)]
public class ServerBase
{
[Required]
[Pattern(@"^[^\s]*$")]
[Title("The unique name of this server component in the solution.")]
[Description("The name of this server component in the solution. The name must be unique in the solution configuration")]
public string Name { get; internal set; } = null!;
[Required]
[Pattern(@"^[^\s]*$")]
[Title("The unique name of this server component in the solution.")]
[Description("The name of this server component in the solution. The name must be unique in the solution configuration")]
public string Name { get; internal set; } = null!;

[Required]
[Title("Hostname, IP address or URI.")]
[Description("The name, address, URI or IP of the server to connect to.")]
[AllowVariable]
public string ServerUri { get; internal set; } = null!;
[Required]
[Title("Hostname, IP address or URI.")]
[Description("The name, address, URI or IP of the server to connect to.")]
[AllowVariable]
public string ServerUri { get; internal set; } = null!;

[Title("Server port")]
[Description("The port to connect to.")]
[AllowVariable]
public int? Port { get; internal set; }
[Title("Server port")]
[Description("The port to connect to.")]
[AllowVariable]
public int? Port { get; internal set; }

[Title("Username.")]
[Description("The username to use when connecting to this server.")]
[AllowVariable]
public string? User { get; internal set; }
[Title("Username.")]
[Description("The username to use when connecting to this server.")]
[AllowVariable]
public string? User { get; internal set; }

[Title("Password.")]
[Description("The password to use when connecting to this server.")]
[AllowVariable]
public string? Password { get; internal set; }
[Title("Password.")]
[Description("The password to use when connecting to this server.")]
[AllowVariable]
public string? Password { get; internal set; }

[Title("Additional options.")]
[Description("A list of additional options to set when connecting to this server.")]
[AllowVariable]
public string? Options { get; internal set; }
}
[Title("Additional options.")]
[Description("A list of additional options to set when connecting to this server.")]
[AllowVariable]
public string? Options { get; internal set; }
}
93 changes: 46 additions & 47 deletions src/Nox.Solution/Models/Infrastructure/Endpoints/Endpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,60 +3,59 @@
using System;
using System.Diagnostics;

namespace Nox.Solution
namespace Nox.Solution;

[Title("The definition namespace for default endpoints pertaining to a Nox solution.")]
[Description("Define default endpoints pertinent to a Nox solution here. These include endpoints for API and BFF servers.")]
[AdditionalProperties(false)]
public class Endpoints : YamlConfigNode<NoxSolution,Infrastructure>
{
[Title("The definition namespace for default endpoints pertaining to a Nox solution.")]
[Description("Define default endpoints pertinent to a Nox solution here. These include endpoints for API and BFF servers.")]
[AdditionalProperties(false)]
public class Endpoints : YamlConfigNode<NoxSolution,Infrastructure>
{
[Title("The api route prefix, defaults to api/v1 or to api/vMajor({Solution.Version}) if Version is set in the root of the Solution.")]
[Description(@"Defines the prefix for all Api routes end points.")]
public string ApiRoutePrefix { get; internal set; } = null!;

public ApiServer? ApiServer { get; internal set; }

public BffServer? BffServer { get; internal set; }
[Title("The api route prefix, defaults to api/v1 or to api/vMajor({Solution.Version}) if Version is set in the root of the Solution.")]
[Description(@"Defines the prefix for all Api routes end points.")]
public string ApiRoutePrefix { get; internal set; } = null!;

public ApiServer? ApiServer { get; internal set; }

public BffServer? BffServer { get; internal set; }


public override void SetDefaults(NoxSolution topNode, Infrastructure parentNode, string yamlPath)
public override void SetDefaults(NoxSolution topNode, Infrastructure parentNode, string yamlPath)
{
if (string.IsNullOrEmpty(ApiRoutePrefix))
{
if (string.IsNullOrEmpty(ApiRoutePrefix))
{
ApiRoutePrefix = "/api/v" + new Version(topNode.Version).Major;
return;
}
else
{
ApiRoutePrefix = SanitizeRoutePrefix(ApiRoutePrefix);
}
ApiRoutePrefix = "/api/v" + new Version(topNode.Version).Major;
return;
}
else
{
ApiRoutePrefix = SanitizeRoutePrefix(ApiRoutePrefix);
}
}

/// <summary>
/// Sanitizes the route prefix by stripping trailing forward slashes and adding leading slashes.
/// </summary>
/// <param name="routePrefix">Route prefix to sanitize.</param>
/// <returns>Sanitized route prefix.</returns>
private static string SanitizeRoutePrefix(string routePrefix)
/// <summary>
/// Sanitizes the route prefix by stripping trailing forward slashes and adding leading slashes.
/// </summary>
/// <param name="routePrefix">Route prefix to sanitize.</param>
/// <returns>Sanitized route prefix.</returns>
private static string SanitizeRoutePrefix(string routePrefix)
{
Debug.Assert(routePrefix != null);
if(string.IsNullOrEmpty(routePrefix))
{
return "";
}
if (routePrefix == "/")
{
return "";
}
if (!routePrefix!.StartsWith("/"))
{
return "/" + routePrefix;
}
if (routePrefix!.EndsWith("/"))
{
Debug.Assert(routePrefix != null);
if(string.IsNullOrEmpty(routePrefix))
{
return "";
}
if (routePrefix == "/")
{
return "";
}
if (!routePrefix!.StartsWith("/"))
{
return "/" + routePrefix;
}
if (routePrefix!.EndsWith("/"))
{
return routePrefix.TrimEnd('/');
}
return routePrefix;
return routePrefix.TrimEnd('/');
}
return routePrefix;
}
}
19 changes: 9 additions & 10 deletions src/Nox.Solution/Models/Infrastructure/Messaging/Messaging.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@

using Nox.Yaml.Attributes;

namespace Nox.Solution
namespace Nox.Solution;

public class Messaging
{
public class Messaging
{
[Required]
// These descriptors should be moved to the class when the generator is fixed
[Title("Details pertaining to the IntegrationEventServer settings in a Nox solution.")]
[Description("Defines settings pertinent to an IntegrationEventServer here. These include provider (RabbitMQ, Azure ServiceBus, Amazon SQS etc), connection details as well as internal default deployment settings.")]
[AdditionalProperties(false)]
public MessagingServer? IntegrationEventServer { get; internal set; } = new();
}
[Required]
// These descriptors should be moved to the class when the generator is fixed
[Title("Details pertaining to the IntegrationEventServer settings in a Nox solution.")]
[Description("Defines settings pertinent to an IntegrationEventServer here. These include provider (RabbitMQ, Azure ServiceBus, Amazon SQS etc), connection details as well as internal default deployment settings.")]
[AdditionalProperties(false)]
public MessagingServer? IntegrationEventServer { get; internal set; } = new();
}
Loading