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
Get the new enterprise by name
curl -X GET \ 'https://example.com/api/admin/enterprises?has=abiquo' \ -H 'Accept: application/vnd.abiquo.enterprises+json;version=4.7' \
Find the required enterprise in the list
Get the enterprise "edit" link
Edit the user entity.
Find the link with the "rel" value of "enterprise" and replace it with the new enterprise link. For example, to switch to enterprise 1224, you could use the link below
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 it is required.
Sample enterprise link
{ "href": "http://example.com/api/admin/enterprises/1224", "rel": "enterprise" }
Update the user
In the user URL, replace the enterprise id with an underscore character "_".
Perform a PUT request to the user, sending the updated user entity.
cURL
curl -X PUT \ https://example.com/api/admin/enterprises/_/users/10 \ -H 'Accept: application/vnd.abiquo.user+json;version=4.7' \ -H 'Content-Type: application/vnd.abiquo.user+json;version=4.7' \ -u user:password --verbose \ -d @requestpayload.json
Sample response