Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

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

  1. 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

       Click here to expand...
              {
                  "id": 10,
                  "nick": "cloudadmin",
                  "name": "cloudadmin",
                  "surname": "cloudadmin",
                  "email": "cloudadmin@example.com",
                  "locale": "en_US",
                  "authType": "ABIQUO",
                  "active": true,
                  "publicSshKey": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDgm0ckfxabLgc2a2cJlTyTdsZ4F5xNWHQqOZjOiZ/OEJ7jDXJiDz2cWiUNeNJJ49xFHHVo4R7QIROau8F5jhjvz1T6yPIcaI+EEqyKBNZtAuTxi7u9xwiuye4Zj6H37oAsxolRNBKg/nPCZ6SGNnVp2nhbN4bJS33Ia8rUSTa7yEbQxkduQndvNh64DscmxMwPiVJOcc9GJZz7gz1PcpeNNxP7Ir3giDSQF+TP4OyCDYV8nOQitGbxqNlJK3jcrx4nhaaY9As1xb5XD1e6X40fNg2+aW6z5rTh5PaEqPReyHDf7RxFWsgj58XUiJ4EPKvnV2EqM9DQINahlDlvIVG8G7p1dx+zT9VCZjEaHIuMQvK7MhStI9cE++TxhipPRfpPClDVQMguDs/JBpiztDZyCYe8szBo+IfxWl3im3pO4CjHqns1Kq0qR8AE7hc3wzNxR4wtX/jGN22LUDObfjVO3zYvnlDu9B3iTtFhS8MZ1N4Pk2/DKnN2/qg8nSNCufSZcFHnY2OV4Wspl5S5MIvz8nQMcl+0q+0BELeIdA0zhAzAaJMv0P8C/R9L0HVLCUFmzwIPW8rrEox5WgZjbxh5Fw3gDNk8/vCWZsKWsYFyy1MoFPt9JrfrO1/axb3xowFI04FcaXgk69SAMxfzL4LQuFCimprdj0gAea1gyswLvw== maryjane.smyth@abiquo.com",
                  "firstLogin": false,
                  "locked": false,
                  "links": [
                      {
                          "rel": "enterprise",
                          "href": "https://example.com:443/api/admin/enterprises/275"
                      },
                      {
                          "title": "CLOUD_ADMIN",
                          "rel": "role",
                          "type": "application/vnd.abiquo.role+json",
                          "href": "https://example.com:443/api/admin/roles/1"
                      },
                      {
                          "title": "cloudadmin",
                          "rel": "edit",
                          "type": "application/vnd.abiquo.user+json",
                          "href": "https://example.com:443/api/admin/enterprises/275/users/10"
                      },
                      {
                          "title": "Global scope",
                          "rel": "scope",
                          "type": "application/vnd.abiquo.scope+json",
                          "href": "https://example.com:443/api/admin/scopes/1"
                      },
                      {
                          "title": "virtual machines",
                          "rel": "virtualmachines",
                          "type": "application/vnd.abiquo.virtualmachines+json",
                          "href": "https://example.com:443/api/admin/enterprises/275/users/10/action/virtualmachines"
                      },
                      {
                          "title": "pending tasks",
                          "rel": "pendingtasks",
                          "type": "application/vnd.abiquo.tasks+json",
                          "href": "https://example.com:443/api/admin/enterprises/275/users/10/action/pendingtasks"
                      },
                      {
                          "title": "applications",
                          "rel": "applications",
                          "type": "application/vnd.abiquo.applications+json",
                          "href": "https://example.com:443/api/admin/enterprises/275/users/10/applications"
                      },
                      {
                          "title": "enable two factor authentication",
                          "rel": "enable2fa",
                          "type": "application/vnd.abiquo.twofactorauthcredentials+json",
                          "href": "https://example.com:443/api/admin/enterprises/275/users/10/action/enable2fa"
                      },
                      {
                          "title": "async tasks",
                          "rel": "asynctasks",
                          "type": "application/vnd.abiquo.asynctasks+json",
                          "href": "https://example.com:443/api/admin/enterprises/275/users/10/asynctasks"
                      }
                  ]
              }
  2. 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"
        }
  3. Update the user 

    1. Perform a PUT request to the user and replace the enterprise id in the URL with an underscore character "_". 

    2. 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.

    3. 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 
    4. Sample response

       Click here to expand...
      {
                  "id": 10,
                  "nick": "cloudadmin",
                  "name": "cloudadmin",
                  "surname": "cloudadmin",
                  "email": "cloudadmin@example.com",
                  "locale": "en_US",
                  "authType": "ABIQUO",
                  "active": true,
                  "publicSshKey": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDgm0ckfxabLgc2a2cJlTyTdsZ4F5xNWHQqOZjOiZ/OEJ7jDXJiDz2cWiUNeNJJ49xFHHVo4R7QIROau8F5jhjvz1T6yPIcaI+EEqyKBNZtAuTxi7u9xwiuye4Zj6H37oAsxolRNBKg/nPCZ6SGNnVp2nhbN4bJS33Ia8rUSTa7yEbQxkduQndvNh64DscmxMwPiVJOcc9GJZz7gz1PcpeNNxP7Ir3giDSQF+TP4OyCDYV8nOQitGbxqNlJK3jcrx4nhaaY9As1xb5XD1e6X40fNg2+aW6z5rTh5PaEqPReyHDf7RxFWsgj58XUiJ4EPKvnV2EqM9DQINahlDlvIVG8G7p1dx+zT9VCZjEaHIuMQvK7MhStI9cE++TxhipPRfpPClDVQMguDs/JBpiztDZyCYe8szBo+IfxWl3im3pO4CjHqns1Kq0qR8AE7hc3wzNxR4wtX/jGN22LUDObfjVO3zYvnlDu9B3iTtFhS8MZ1N4Pk2/DKnN2/qg8nSNCufSZcFHnY2OV4Wspl5S5MIvz8nQMcl+0q+0BELeIdA0zhAzAaJMv0P8C/R9L0HVLCUFmzwIPW8rrEox5WgZjbxh5Fw3gDNk8/vCWZsKWsYFyy1MoFPt9JrfrO1/axb3xowFI04FcaXgk69SAMxfzL4LQuFCimprdj0gAea1gyswLvw== maryjane.smyth@abiquo.com",
                  "firstLogin": false,
                  "locked": false,
                  "links": [
                      {
                          "rel": "enterprise",
                          "href": "https://example.com:443/api/admin/enterprises/276"
                      },
                      {
                          "title": "CLOUD_ADMIN",
                          "rel": "role",
                          "type": "application/vnd.abiquo.role+json",
                          "href": "https://example.com:443/api/admin/roles/1"
                      },
                      {
                          "title": "cloudadmin",
                          "rel": "edit",
                          "type": "application/vnd.abiquo.user+json",
                          "href": "https://example.com:443/api/admin/enterprises/275/users/10"
                      },
                      {
                          "title": "Global scope",
                          "rel": "scope",
                          "type": "application/vnd.abiquo.scope+json",
                          "href": "https://example.com:443/api/admin/scopes/1"
                      },
                      {
                          "title": "virtual machines",
                          "rel": "virtualmachines",
                          "type": "application/vnd.abiquo.virtualmachines+json",
                          "href": "https://example.com:443/api/admin/enterprises/275/users/10/action/virtualmachines"
                      },
                      {
                          "title": "pending tasks",
                          "rel": "pendingtasks",
                          "type": "application/vnd.abiquo.tasks+json",
                          "href": "https://example.com:443/api/admin/enterprises/275/users/10/action/pendingtasks"
                      },
                      {
                          "title": "applications",
                          "rel": "applications",
                          "type": "application/vnd.abiquo.applications+json",
                          "href": "https://example.com:443/api/admin/enterprises/275/users/10/applications"
                      },
                      {
                          "title": "enable two factor authentication",
                          "rel": "enable2fa",
                          "type": "application/vnd.abiquo.twofactorauthcredentials+json",
                          "href": "https://example.com:443/api/admin/enterprises/275/users/10/action/enable2fa"
                      },
                      {
                          "title": "async tasks",
                          "rel": "asynctasks",
                          "type": "application/vnd.abiquo.asynctasks+json",
                          "href": "https://example.com:443/api/admin/enterprises/275/users/10/asynctasks"
                      }
                  ]
              }
      
      
      
      
      
      


  • No labels