This page describes how switch enterprises via API. To switch enterprises means that an administrator can change from one tenant to another in order to work with another tenant. This is useful because you can only access some Abiquo entities and resources from within the enterprise that they belong to. For example, you must switch to an enterprise to deploy in its virtual datacenters or to edit its VM templates in the Apps library.
You will need the following resources:
- More than one enterprise created in the platform
Your user role must include the following privileges.
- ENTERPRISE_ENUMERATE
- ENTERPRISE_ADMINISTER_ALL
Your user must have the new enterprise within your management scope.
The following pages describe the switch enterprise functionality in the Abiquo UI.
Summary diagram
The steps in this diagram link to the API reference guide resources and data entities sections.
Detailed steps
Get the user entity by name
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 "_".
If you know the ID of the user, you can retrieve the user entity directly with the users link.
For example, the cloud admin user has an ID of 1, and the link as "https://example.com/api/admin/enterprises/_/users/1"Or use the "has" parameter to perform a search for the user by text such as username, name, or details
curl -X GET \ 'https://example.com/api/admin/enterprises/_/users?has=cloudadmin' \ -H 'Accept: application/vnd.abiquo.users+json;version=4.7' \
This request returns a collection of users, so find the required user
Edit the user entity and replace the enterprise link, for example to switch to enterprise 1224
{ "href": "http://example.com/api/admin/enterprises/1224", "rel": "enterprise" }
Update the user
Perform a PUT request to the user and 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, e.g. add an email attribute for the user if you didn't already add one because this is obligatory.
cURL
curl -X PUT \ https://example.com/api/admin/enterprises/_/users/10 \ -H 'Accept: application/vnd.abiquo.user+json;version=4.6' \ -H 'Content-Type: application/vnd.abiquo.user+json;version=4.6' \ -u user:password --verbose \ -d @requestpayload.json
Sample response