Skip to content

Commit

Permalink
Merge pull request #36 from mspnp/dev
Browse files Browse the repository at this point in the history
2023-10-30 - BryanSoltis - v3.1.1 Updates
  • Loading branch information
BryanSoltis authored Oct 30, 2023
2 parents 0673429 + 2cd83c3 commit eef10fe
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/AzureNamingTool.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<Version>3.1.0</Version>
<Version>3.1.1</Version>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
1 change: 1 addition & 0 deletions src/Models/ValidateNameRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
public class ValidateNameRequest
{
public long? ResourceTypeId { get; set;}
public string? ResourceType { get; set; }
public string? Name { get; set; }
}
Expand Down
4 changes: 3 additions & 1 deletion src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Blazored.Toast;
using Microsoft.OpenApi.Models;
using Blazored.Modal;
using Swashbuckle.AspNetCore.Swagger;
using System.Reflection;
using AzureNamingTool.Models;

Expand All @@ -12,6 +11,7 @@
// Add services to the container.
builder.Services.AddMvcCore().AddApiExplorer();
builder.Services.AddRazorPages();
builder.Services.AddHealthChecks();
if (builder.Environment.IsDevelopment())
{
builder.Services.AddServerSideBlazor().AddCircuitOptions(x => x.DetailedErrors = true).AddHubOptions(x => x.MaximumReceiveMessageSize = 102400000);
Expand Down Expand Up @@ -55,6 +55,8 @@
builder.Services.AddMemoryCache();
var app = builder.Build();

app.MapHealthChecks("/healthcheck/ping");

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
Expand Down
69 changes: 41 additions & 28 deletions src/Services/ResourceNamingRequestService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ public static async Task<ResourceNameResponse> RequestNameWithComponents(Resourc
// CALL VALIDATION FUNCTION
ValidateNameRequest validateNameRequest = new()
{
ResourceTypeId = resourceType.Id,
ResourceType = resourceType.ShortName,
Name = name
};
Expand Down Expand Up @@ -518,35 +519,36 @@ public static async Task<ResourceNameResponse> RequestName(ResourceNameRequest r
{
if (GeneralHelper.IsNotNull(serviceResponse.ResponseObject))
{
if (GeneralHelper.IsNotNull(serviceResponse.ResponseObject))
var customcomponents = (List<CustomComponent>)serviceResponse.ResponseObject!;
if (GeneralHelper.IsNotNull(customcomponents))
{
var customcomponents = (List<CustomComponent>)serviceResponse.ResponseObject!;
if (GeneralHelper.IsNotNull(customcomponents))
// Make sure the custom component has values
if (customcomponents.Where(x => x.ParentComponent == normalizedcomponentname).Any())
{
// Make sure the custom component has values
if (customcomponents.Where(x => x.ParentComponent == normalizedcomponentname).Any())
// Make sure the CustomComponents property was provided
if (!resourceType.Exclude.ToLower().Split(',').Contains(normalizedcomponentname))
{
// Make sure the CustomComponents property was provided
if (!resourceType.Exclude.ToLower().Split(',').Contains(normalizedcomponentname))
// Add property value to name, if exists
if (GeneralHelper.IsNotNull(request.CustomComponents))
{
// Add property value to name, if exists
if (GeneralHelper.IsNotNull(request.CustomComponents))
// Check if the custom compoment value was provided in the request
if (request.CustomComponents.ContainsKey(normalizedcomponentname))
{
// Check if the custom compoment value was provided in the request
if (request.CustomComponents.ContainsKey(normalizedcomponentname))
// Get the value from the provided custom components
var componentvalue = request.CustomComponents[normalizedcomponentname];
if (!GeneralHelper.IsNotNull(componentvalue))
{
// Get the value from the provided custom components
var componentvalue = request.CustomComponents[normalizedcomponentname];
if (!GeneralHelper.IsNotNull(componentvalue))
// Check if the prop is optional
if (!resourceType.Optional.ToLower().Split(',').Contains(normalizedcomponentname))
{
// Check if the prop is optional
if (!resourceType.Optional.ToLower().Split(',').Contains(normalizedcomponentname))
{
valid = false;
sbMessage.Append(component.Name + " value was not provided. ");
}
valid = false;
sbMessage.Append(component.Name + " value was not provided. ");
}
else
}
else
{
// Check if the custom component is empty
if (!String.IsNullOrEmpty(componentvalue))
{
// Check to make sure it is a valid custom component
var customComponents = await ConfigurationHelper.GetList<CustomComponent>();
Expand All @@ -572,14 +574,14 @@ public static async Task<ResourceNameResponse> RequestName(ResourceNameRequest r
}
}
}
}
else
{
// Check if the prop is optional
if (!resourceType.Optional.ToLower().Split(',').Contains(normalizedcomponentname))
else
{
valid = false;
sbMessage.Append(component.Name + " value was not provided. ");
// Check if the prop is optional
if (!resourceType.Optional.ToLower().Split(',').Contains(normalizedcomponentname))
{
valid = false;
sbMessage.Append(component.Name + " value was not provided. ");
}
}
}
}
Expand All @@ -593,9 +595,19 @@ public static async Task<ResourceNameResponse> RequestName(ResourceNameRequest r
}
}
}
else
{
// Check if the prop is optional
if (!resourceType.Optional.ToLower().Split(',').Contains(normalizedcomponentname))
{
valid = false;
sbMessage.Append(component.Name + " value was not provided. ");
}
}
}
}
}

}
}
}
Expand Down Expand Up @@ -695,6 +707,7 @@ public static async Task<ResourceNameResponse> RequestName(ResourceNameRequest r
// Validate the generated name for the resource type
ValidateNameRequest validateNameRequest = new()
{
ResourceTypeId = resourceType.Id,
ResourceType = resourceType.ShortName,
Name = name
};
Expand Down
13 changes: 11 additions & 2 deletions src/Services/ResourceTypeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,17 @@ public static async Task<ServiceResponse> ValidateResourceTypeName(ValidateNameR
List<ResourceType> resourceTypes = (List<ResourceType>)serviceResponse.ResponseObject!;
if (GeneralHelper.IsNotNull(resourceTypes))
{
// Get the specified resoure type
ResourceType resourceType = resourceTypes.FirstOrDefault(x => x.ShortName == validateNameRequest.ResourceType)!;
ResourceType resourceType = null;
if (GeneralHelper.IsNotNull(validateNameRequest.ResourceTypeId))
{
// Get the specified resoure type by id
resourceType = resourceTypes.FirstOrDefault(x => x.Id == validateNameRequest.ResourceTypeId)!;
}
else
{
// Get the specified resoure type by short name
resourceType = resourceTypes.FirstOrDefault(x => x.ShortName == validateNameRequest.ResourceType)!;
}
if (GeneralHelper.IsNotNull(resourceType))
{
// Create a validate name request
Expand Down
2 changes: 1 addition & 1 deletion src/programsettings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"FeedbackURL": "https://forms.office.com/r/M2EZLg6zKq",
"latestNewsEnabled": "false",
"toolVersion":"3.1.0"
"toolVersion":"3.1.1"
}

0 comments on commit eef10fe

Please sign in to comment.