Configlets (API)
For full API documentation, view the Platform API reference from the web interface. This is a targeted section to demonstrate configlet API similarly to the UI. The main difference between the Web UI and REST API is that the Apstra API does not make any use of the configlets stored under api/design/configlets when working with a blueprint. Design-configlets are meant for consumption under the UI. When working with configlets on the API, work directly with the blueprint.
Configlets live in http://aos-server/api/design/configlets and are referenced by ID.
{ "ref_archs": [ "two_stage_l3clos" ], "created_at": "string", "last_modified_at": "string", "id": "string", "generators": [ { "config_style": "string", "template_text": "string", "negation_template_text": "string" } ], "display_name": "string", "section": "string" }
API - Create Configlet
To create a configlet, POST to https://aos-server/api/design/configlets with a valid JSON structure representing the configlet. You can assign this configlet from the Apstra GUI. This method is not required for the REST API to assign to a blueprint. See the assigning a configlet section for more details.
A POST will create a new configlet. A PUT will overwrite an existing configlet. PUT requires the URL of the configlet. https://aos-server/api/design/configlets/{id}
curl -H "AuthToken: EXAMPLE" -d '{"display_name":"DNS","ref_archs":["two_stage_l3clos"],"section":"system","generators":[{"config_style":"eos","template_text":"ip name-server 192.168.1.1","negation_template_text":"no ip name-server 192.168.1.1"}]}' -X POST "http://aos-server/api/design/configlets"
The response will contain the ID of the newly created configlet {"id":
"995446c7-de7d-46bb-a88a-786839556064"}
API - Delete Configlet
Deleting a configlet requires an HTTP DELETE to the configlet by URL http://aos-server/api/design/configlets/{id}
curl -H "AuthToken: EXAMPLE" -X DELETE "http://aos-server/api/design/configlets/995446c7-de7d-46bb-a88a-786839556064"
A successful DELETE has an empty response {}
API - Assign Configlet
Assigning a configlet to a blueprint requires assignation of device conditions as well as embedding the configlet details. When assigning a configlet to a blueprint, the configlets available as design resources aren’t necessary. These are only used for UI purposes.
The assigned configlet lives in https://aos-server/api/blueprints/blueprint_id/configlets
JSON Syntax for putting a configlet to a blueprint. Basically, this is just an ‘items’ dictionary element containing a list of configlet schemas.
{ "items": [ { "template_params": [ "string" ], "configlet": { "generators": [ { "config_style": "string", "template_text": "string", "negation_template_text": "string" } ], "section": "string", "display_name": "string" }, "condition": "string" } ] }
CURL Example - HTTP PUT
curl "http://aos-server/api/blueprints/e4068e99-813c-4290-b7cc-e145d85a98a8/configlets" -X PUT -H "AuthToken: EXAMPLE" -H "Content-Type: application/json; charset=utf-8" --data "[{""configlet"":{""generators"":[{""config_style"":""eos"",""template_text"":""ip name-server 192.168.1.1"",""negation_template_text"":""no ip name-server 192.168.1.1""}],""section"":""system"",""display_name"":""DNS""},""condition"":""role==spine""},{""configlet"":{""generators"":[{""config_style"":""eos"",""template_text"":""ip name-server 192.168.1.1"",""negation_template_text"":""no ip name-server 192.168.1.1""}],""section"":""system"",""display_name"":""DNS""},""condition"":""role==leaf""}]"
Response
{"items": [{"configlet": {"generators": [{"config_style": "eos", "template_text": "ip name-server 192.168.1.1", "negation_template_text": "no ip name-server 192.168.1.1"}], "section": "system", "display_name": "DNS"}, "condition": "role==spine"}, {"configlet": {"generators": [{"config_style": "eos", "template_text": "ip name-server 192.168.1.1", "negation_template_text": "no ip name-server 192.168.1.1"}], "section": "system", "display_name": "DNS"}, "condition": "role==leaf"}]}
API - Unassign Configlet
To unassign a configlet, remove it from the items list by PUT with an empty json post.
curl "http://aos-server/api/blueprints/e4068e99-813c-4290-b7cc-e145d85a98a8/configlets" -X PUT -H "AuthToken: EXAMPLE" -H "Content-Type: application/json; charset=utf-8" --data ""
The response is an empty json set once the configlet is deleted: {"items": []}