Closed tobvil closed 2 years ago
Hi tobvil,
Thank you for the great question. In order to use the API to request a name, the request needs to include a ResourceNameRequest object, containing all the desired components. This class consists of strongly typed models for each component. Each component requires certain properties to ensure the name generation completes successfully. The components do not have to be in any order, as the Name Generation functionality will determine the configured component order (from the Configuration page) and ensure all the required components are present.
Initially, the name generation functionality only required the actual text values, but in order to enforce validation (REGEX for the resource type, optional/excluded components, etc.), we decided to make the functionality require the strongly-typed classes for each component to help with passing that information. We actually debated this for a while and still may add an "only text for each component" capability in the future, however, that is not supported at this time.
UPDATE In looking into this issue, I found an issue with the Name Generation API that will require a code update. That code update is currently under review. Once it is completed, I will post an updated Name Request JSON to demonstrate the API capability. (You will also need to update your image with the latest codebase then, as well).
Hi @tobvil,
The PR with the changes has been merged. Please pull the latest source code and recreate your image.
Here is a sample ResourceNamingRequests JSON body:
{ "ResourceDelimiter": { "Id": 1, "Name": "dash", "Delimiter": "-", "Enabled": true, "SortOrder": 1 }, "ResourceEnvironment": { "Id": 2, "Name": "Production", "ShortName": "prd", "SortOrder": 2 }, "ResourceInstance": "2", "ResourceLocation": { "Id": 16, "Name": "East US", "ShortName": "eu" }, "ResourceProjAppSvc": { "Id": 4, "Name": "Sample Project/App/Service", "ShortName": "spa", "SortOrder": 1 }, "ResourceType": { "Id": 67, "Resource": "Cache/Redis", "Optional": "UnitDept", "Exclude": "Org,Function", "Property": "", "ShortName": "redis", "Scope": "global", "LengthMin": "1", "LengthMax": "63", "ValidText": "Alphanumerics and hyphens. Start and end with alphanumeric.", "InvalidText": "Consecutive hyphens not allowed.", "InvalidCharacters": "", "InvalidCharactersStart": "", "InvalidCharactersEnd": "", "InvalidCharactersConsecutive": "-", "Regx": "^(?!.*-{2}.*)([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9])$", "StaticValues": "" } }
Hope this helps!
Hit @tobvil,
I wanted to let you know we published v 2.1.0 of the tool with an updated "RequestName" API function. This new version only requires a basic string format for the values and performs all validation. This should simplify your API integrations and allow for much easier name generation. The updates also includes new documentation on using the API.
Here is a sample JSON for the "new" RequestName API function:
{ "ResourceEnvironment": "prd", "ResourceInstance": "2", "ResourceLocation": "eu", "ResourceProjAppSvc": "spa", "ResourceType": "redis" }
Here are the release notes:
Version 2.1.0 Updates
Updated GitHub documentation to separate files
I hope this helps!
BryanSoltis
Hi @BryanSoltis
Just tested it, and it works perfectly. Much more intuitive and easier to work with.
Thank you 👍
I can't seems to figure out how to generate names for resources using the ResourceNamingRequests API endpoint.
Is it possible to provide examples?