Update enterprise properties via API
Introduction to working with enterprise properties in the API
Enterprise properties enable you to store tenant metadata and you can also use them to configure billing dashboards and integrations, such as the VMware NSX integration, Azure VPNs, and onboard from public cloud.
To retrieve or update enterprise properties, you will require the following privilege:
- Allow user to switch enterprise: ROLE_ENTERPRISE_ADMINISTER_ALL
There are three types of enterprise properties:
- READ_WRITE
- READ_ONLY
- HIDDEN
To update READ_ONLY or HIDDEN properties you will require the following privilege:
- Manage enterprise properties: ENTERPRISE_MANAGE_PROPERTIES
When you update enterprise properties using the API, you will overwrite all existing properties
Default properties:
- If you created the enterprise using the API, by default there are no properties.
- If you created the enterprise using the user interface, some default properties and values may have been defined and/or modified. See Predefine enterprise properties for the UI
For details of how to manage enterprise properties in the UI, see:
- Set enterprise properties to store tenant details and metadata
- Enterprise property privileges and types
Retrieve enterprises by property key or value
When you get enterprises, you can filter enterprises by their properties using the "prop" query parameter. The platform combines the filters with an OR operator.
For example:
To get enterprises that have property pairs Key1=Value1 or Key2=Value2 get the enterprises with the query parameters as shown here:
admin/enterprises?prop.Key1=Value1&prop.Key2=Value2
Enterprises with properties with key 'Key1' and any value:
admin/enterprises?prop.Key1
Enterprises with properties with value 'Value1' and any key:
admin/enterprises?prop=Value1
The following query gives an example of how to get all the enterprises that have the "dataset_id" property:
curl -X GET 'https://abiquo.example.com/api/admin/enterprises?prop.dataset_id' \ -H 'Accept: application/vnd.abiquo.enterprises+json;version=5.2' \ -H 'Authorization: Token a2e19816735381c1d077771cbd002aaaaa33355111f8881d5a27124006189a0f333eed68bebcb336583737aba6666cc4ff8f8c9174d9529d59237afb537c7db'
In our system, this query returns a collection of two enterprises.
To get all enterprises with a property that has a key of "dataset_id" and a value of "billingDatasetId22", you could use the following query.
curl -X GET 'https://abiquo.example.com/api/admin/enterprises?prop.dataset_id=billingDatasetId22' \ -H 'Accept: application/vnd.abiquo.enterprises+json;version=5.2' \ -H 'Authorization: Token a2e19816735381c1d077771cbd002aaaaa33355111f8881d5a27124006189a0f333eed68bebcb336583737aba6666cc4ff8f8c9174d9529d59237afb537c7db'
Get the properties of an enterprise
To retrieve the existing enterprise properties from an enterprise, get the properties link from the enterprise's data object.
Make a GET request to the properties link similar to the one shown here.
curl -X GET https://abiquo.example.com:443/api/admin/enterprises/12/properties -H 'Accept:application/vnd.abiquo.enterpriseproperties+json;version=5.2' \ -u user:password --verbose
The response is an enterpriseproperties object as follows.
{ "links": [ { "title": "enterprise properties", "rel": "edit", "type": "application/vnd.abiquo.enterpriseproperties+json", "href": "https://abiquo.example.com:443/api/admin/enterprises/12/properties" }, { "title": "Google Cloud enterprise billingproject", "rel": "enterprise", "type": "application/vnd.abiquo.enterprise+json", "href": "https://abiquo.example.com:443/api/admin/enterprises/12" } ], "properties": [ { "accessType": "READ_WRITE", "key": "dataset_id", "value": "billingDatasetId22" } ] }
Update enterprise properties
To update enterprise properties using the API, enter the properties in key and value format.
When you update enterprise properties you will overwrite the existing properties.
When you make the put request, use an enterpriseproperties object, similar to this example. See https://wiki.abiquo.com/api/latest/enterpriseproperties.html
-d '{ "properties": [ { "key": "account_id", "value": "ABC123", "accessType": "READ_WRITE" }, { "key": "billing_code", "value": "premiumAAA", "accessType": "HIDDEN" }, { "key": "cost_center", "value": "123ABC", "accessType": "READ_ONLY" }, { "key": "dataset_id", "value": "billingDatasetId22", "accessType": "READ_WRITE" } ] }
The full PUT request to update the properties with this data entity would be as follows.
Remember that you will require the privileges listed in the Introduction to enterprise properties in the API.
curl -X PUT 'https://abiquo.example.com/api/admin/enterprises/12/properties' \ -H 'Accept: application/vnd.abiquo.enterpriseproperties+json;version=5.2' \ -H 'Content-Type: application/vnd.abiquo.enterpriseproperties+json;version=5.2' \ -d '{"links":[],"properties":[{"key":"account_id","value":"ABC123","accessType":"READ_WRITE"},{"key":"billing_code","value":"premiumAAA","accessType":"HIDDEN"},{"key":"cost_center","value":"123ABC","accessType":"READ_ONLY"},{"key":"dataset_id","value":"billingDatasetId22","accessType":"READ_WRITE"}]}'
And an example response would be as follows:
Related pages
- API documentation - Manage enterprises and their properties: EnterprisesResource
Copyright © 2006-2022, Abiquo Holdings SL. All rights reserved