Juniper / apstra-go-sdk

Go SDK for Apstra
Apache License 2.0
3 stars 0 forks source link

Handle multiple types of "CT attached to link" error #262

Closed chrismarget-j closed 4 months ago

chrismarget-j commented 4 months ago

We previously had handling for deleting "busy" server links, but it only handled individual links, not aggregate links.

It turns out the API response to POSTs at /api/blueprints/<id>/delete-switch-system-links vary depending on individual vs. aggregate links. The following example includes both types:

{
  "api_response": null,
  "config_blueprint_version": 0,
  "errors": {
    "link_ids": [
      "Deleting all links forming a LAG is not allowed since the LAG has assigned structures: ['connectivity template', 'VN endpoint']. Link ids: ['l2_virtual_004_leaf1<->l2_virtual_004_sys003(bang)[1]', 'l2_virtual_004_leaf1<->l2_virtual_004_sys003(bang)[2]']",
      "Link with id l2_virtual_004_leaf1<->l2_virtual_004_sys003(link-000000001)[1] can not be deleted since some of its interfaces have connectivity templates assigned",
      "Link with id l2_virtual_004_leaf1<->l2_virtual_004_sys003(link-000000001)[1] can not be deleted since some of its interfaces have VN endpoints"
    ]
  },
  "error_code": 422
}

Each item in link_ids represents a single link with CT assigned to the upstream switch port. In the case of an individual link, we're given the link ID. In the case of an aggregate link, we're given each member link, all together on one line.

This PR introduces support for teasing out the parent aggregate link ID and returning those IDs in an ErrCtAssignedToLinkDetail struct so that the caller can take the appropriate action.