Switch enterprises via API

In Abiquo the Cloud admin user can switch enterprises, which means to change from one enterprise (cloud tenant) to another to work in this enterprise. This is useful because you can only access some Abiquo entities, such as virtual datacenters, from within the enterprise they belong to. This functionality is only available to the cloud administrator and other users with the privileges to "List all enterprises within scope" and "Allow user to switch enterprise". Users must have the new enterprise within their management scope.

In the UI, you can switch enterprises in Home view or Users view in the Enterprises list by clicking the switch enterprises button beside the enterprise Name. In the API, you should perform the following steps.

  1. Retrieve the user entity

    • You will need the ID of the user in the API. To get a cloud admin user from whichever enterprise they are currently in, run the get request with a wildcard for all enterprises represented by the underscore character "_". 
      For example, for the Cloud admin user with a user ID of 1.

      curl -X GET "https://example.com/api/admin/enterprises/_/users/1" \ -H "Accept: application/vnd.abiquo.user+json;version=4.6"

      To obtain a user by name, you can list all users and use the "has" parameter to filter by a text string included in attributes such as username or name

  2. Edit the user entity. Remove the existing enterprise link and replace it with a new one, for the new enterprise ID, for example to switch to enterprise 1224

    { "href": "http://example.com/api/admin/enterprises/1224", "rel": "enterprise" }

     

  3. Perform a PUT request to the user but replace the enterprise id in the URL with an underscore character "_". Send the user entity that you modified above. Remember that the user entity must be complete in order to save the user, so add an email for the user if you didn't already add one because it is a required attribute.

    curl -X PUT http://example.com/api/admin/enterprises/_/users/1179 \

     

Below is a full walkthrough of a user switching enterprise, from the current enterprise to another enterprise

Get the cloudadmin user from any enterprise.

Find the appropriate user and copy the user entity.

Edit the user entity to remove the link to the current enterprise and add the link to the new enterprise. Here we have changed the enterprise link to 276.

Note that the "title" and "type" attributes of the link are not necessary for this request.

To update the user to switch enterprises, perform a PUT request with the above user entity.

Request payload

Copyright © 2006-2024, Abiquo Holdings SL. All rights reserved