mspnp / AzureNamingTool

The Azure Naming Tool is a .NET 8 Blazor application, with a RESTful API. The UI consists of several pages to allow the configuration and generation of Azure Resource names. The API provides a programmatic interface for the functionality.
https://aka.ms/azurenamingtool
MIT License
308 stars 604 forks source link

Extend API: Allow generated name to be queried and deleted by ID #5

Closed theneedyguy closed 11 months ago

theneedyguy commented 11 months ago

This will allow API users to query the generated names by providing an ID in the URL.

BryanSoltis commented 11 months ago

Hi @theneedyguy ,

Thank you for the PR! These are great changes and will be integrated into the next version (3.0.1). In reviewing the change, I found a number of areas in the API that were not properly returning the right information (example: If an ID for component doesn't exist). v3.0.1 will update all APIS to resolve this, as well as add your suggested changes.

I'm trying to determine the best way to merge these changes with your edits. I will update the PR once that process is complete.

Thank you again for the contribution!

-Bryan

theneedyguy commented 11 months ago

@BryanSoltis Thanks for reviewing my changes. I too found that some areas would not return an empty array if the index was out of bounds but would instead return the last item of the array.

P.S. The reason for my contribution was to be able to use the naming tool with Terraform together Mastercard's rest_api module. My changes would allow the "creation" and "destruction" of names using the API. What I also found is when using the module, the API would not be fast enough to create multiple names in parallel. This might be because using JSON as the storage is not suited for parallel writes. The workaround is setting the Terraform parallelism to 1 when applying the config. Maybe using a proper DB for data storage could fix this issue or maybe adding some kind of queueing mechanism to make sure the index is already used and to move on to the next free index. This an extremely niche case and the workaround works for me so that might be something for the future.

BryanSoltis commented 11 months ago

Hi @theneedyguy,

Thank you for your PR! These changes will be merged into the project, then updated with new functionality to align with recent API updates.

-Bryan

BryanSoltis commented 10 months ago

You can test out the changes in the pre-lease here:

https://github.com/mspnp/AzureNamingTool/releases/tag/v3.0.1

Please let me know if you have any issues!

-Bryan