If you enroll in custom naming in the Automation Assembler UI, you can create custom naming templates for your organization or project using the IaaS API. Custom naming provides a way for you to name deployed resources using conventions that you define.
If you create a custom name using POST /iaas/api/naming
, any project that does not already have a template applied can use the naming template. An organization-level naming template applies to any project that is added to an organization.
A maximum of two resource naming templates can be applied to a project: one project-level naming template and one organization-level naming template. Each can have multiple resource types. If naming templates exist at both the project and organization level, the project uses the naming convention used in the project-level naming template.
The following examples show how to define custom naming templates for an organization and a project.
Prerequisites for creating a custom name
- Verify that all general prerequisites and prerequisites for the Automation Assembler Infrastructure as a Service (IaaS) service have been satisfied. See Prerequisites for API Use Case Examples.
- Verify that you have enrolled in Custom Naming.
For information about enrolling in custom naming, see Custom naming deployed resources in Automation Assembler.
- Verify that you know your organization ID. If you do not know your organization ID, perform the following steps:
- Use your My VMware credentials to log in to the organization console or https://console.cloud.vmware.com/csp/gateway/discovery.
- Click the drop-down arrow by your name to display the organization ID below the organization name.
- Right click the icon next to the organization ID to copy the long string.
- If you are adding a project-level template, verify that you know the name and ID of the project that you want to assign to the template. For information on how to get a list of projects, see Create a Project to use in Automation Assembler.
How to create a custom name with organization scope
This example shows how to define an organization-level custom name with a naming template for a machine resource type in "orgId": "8327d53f-91ea-420a-8613-ba8f3149db95" .
curl -X POST \ "$url/iaas/api/naming?apiVersion=$api_version" \ -H "Authorization: Bearer $access_token" \ -H 'Content-Type: application/json' \ -d '{ "name": "org-level custom name", "description": "Example organization-level custom name", "projects": [ { "defaultOrg": true, "active": true, "projectName": "*", "projectId": "*", "orgId": "8327d53f-91ea-420a-8613-ba8f3149db95" } ], "templates": [ { "uniqueName": true, "staticPattern": "", "counters": [], "incrementStep": 1, "pattern": "myvm-${##}", "startCounter": 1, "resourceTypeName": "Machine", "resourceType": "COMPUTE", "resourceDefault": true } ] }' | jq "."
The response shows the organization-level custom name with the custom name ID.
{ "name": "org-level custom name", "description": "Example organization-level custom name", "id": "6ca7be62-627b-41f0-9505-fc29c1349a85", "_links": { "self": { "href": "/iaas/api/naming/6ca7be62-627b-41f0-9505-fc29c1349a85" } } }
How to create a custom name with project scope
This example shows how to define a project-level custom name with naming templates for network and machine resource types, and assigned to a project that has not already been added to a custom name with project scope.
curl -X POST \ "$url/iaas/api/naming?apiVersion=$api_version" \ -H "Authorization: Bearer $access_token" \ -H 'Content-Type: application/json' \ -d '{ "name": "proj-level custom name ", "description": "Example project-level custom name", "projects": [ { "defaultOrg": false, "active": true, "projectName": "Example-CA-project", "projectId": "5944aacb-91de-4541-bb9e-ef2a5403f81b", "orgId": "8327d53f-91ea-420a-8613-ba8f3149db95" } ], "templates": [ { "uniqueName": true, "staticPattern": "", "counters": [], "incrementStep": 1, "pattern": "myCAproject-${##}", "startCounter": 1, "resourceTypeName": "Network", "resourceType": "NETWORK", "resourceDefault": true }, { "uniqueName": true, "staticPattern": "", "counters": [], "incrementStep": 1, "pattern": "myCAproject-${##}", "startCounter": 1, "resourceTypeName": "Machine", "resourceType": "COMPUTE", "resourceDefault": true } ] }' | jq "."
The response shows the project-level custom name with the custom name ID.
{ "name": "proj-level custom name", "description": "Example project-level custom name", "id": "9afa9636-9536-4867-a325-fc70eb073a86", "_links": { "self": { "href": "/iaas/api/naming/9afa9636-9536-4867-a325-fc70eb073a86" } } }