From 81b484b55c6b269cb5ffcb9c0493c46f26b62ec3 Mon Sep 17 00:00:00 2001 From: Ihor Aleksandrychiev Date: Thu, 11 Sep 2025 14:46:27 +0300 Subject: [PATCH] Updated CMDB documentations Switched to v2 Ticket: ENT-11117 Signed-off-by: Ihor Aleksandrychiev --- .../api/enterprise-api-ref/cmdb-api.markdown | 508 ++++++------------ .../enterprise-api-ref/shared-groups.markdown | 295 +++++----- 2 files changed, 300 insertions(+), 503 deletions(-) diff --git a/content/api/enterprise-api-ref/cmdb-api.markdown b/content/api/enterprise-api-ref/cmdb-api.markdown index a6eb2c9bc..249096ffd 100644 --- a/content/api/enterprise-api-ref/cmdb-api.markdown +++ b/content/api/enterprise-api-ref/cmdb-api.markdown @@ -5,336 +5,218 @@ aliases: - "/api-enterprise-api-ref-cmdb-api.html" --- -The configuration management database (CMDB) API enables you to manage classes and variables for specific hosts. +The configuration management database (CMDB) API v2 enables you to manage configuration entries for specific hosts. -## List CMDB +## Get CMDB for specific host -You can see a list of stored host-specific configurations +Get all configuration entries for a specific host. -**URI:** https://hub.cfengine.com/api/cmdb +**URI:** https://hub.cfengine.com/api/cmdb/v2/:hostkey **Method:** GET **Parameters:** -- **fromEpoch** _(integer)_ - Returns configurations with epoch value greater than set in the filter. - Epoch is the sequence number of the latest CMDB change. In every API list request, - `cmdb_epoch` will be present in the meta section, which contains the maximum - epoch value among selected items. Optional parameter. -- **fromTime** _(timestamp)_ - Include changes performed within interval. Format: `YYYY-mm-dd HH:MM:SS` or `YYYY-mm-dd`. Optional parameter. -- **toTime** _(timestamp)_ - Include changes performed within interval. Format: `YYYY-mm-dd HH:MM:SS` or `YYYY-mm-dd`. Optional parameter. +- **hostkey** _(string)_ + Unique host identifier. +- **sortColumn** _(string)_ + Column to sort by. Optional parameter. +- **sortDescending** _(boolean)_ + Sort in descending order. Optional parameter. - **skip** _(integer)_ - Number of results to skip for the processed - query. The Mission Portal uses this for pagination. Optional parameter. + Number of results to skip for pagination. Optional parameter. - **limit** _(integer)_ - Limit the number of results in the query. Optional parameter. -- **hostContextInclude** _(array)_ - Includes only results that concern hosts which have all specified CFEngine contexts (class) set. Optional parameter. -- **hostContextExclude** _(array)_ - Excludes results that concern hosts which have specified CFEngine context (class) set. Hosts that have at least one of the specified contexts set will be excluded from the results. Optional parameter. + Limit the number of results (max 100). Optional parameter. **Example request (curl):** ```console curl -k --user : \ -X GET \ - https://hub.cfengine.com/api/cmdb?epochFrom=2&hostContextInclude[]=ubuntu + https://hub.cfengine.com/api/cmdb/v2/SHA=f622992fa4525070f47da086041a38733496f03a77880f70b1ce6784c38f79ab?limit=10&skip=0 ``` **Example response:** -``` -HTTP 200 Ok +```json { - "data": { - "SHA=fdab725e8fb18aa0ad194477be8a2a1338b4b29f6a8597819af89697e432418f": { - "classes": { - "My_class": {}, - "My_class2": { - "comment": "comment helps to understand what this class serves for" - } - }, - "variables": { - "HubCMDB:My.hostname": { - "value": "host1.cfengine.com", - "comment": "comment" - }, - "Namespace:BundleName.VariableName": { - "value": "myvalue" - } - } + "data": [ + { + "id": 1, + "hostkey": "SHA=f622992fa4525070f47da086041a38733496f03a77880f70b1ce6784c38f79ab", + "created_at": "2025-09-08 13:53:37.303128", + "name": "my_class_config", + "description": "Sample class configuration", + "tags": ["test_tag", "production"], + "type": "class", + "meta": {}, + "entries": [ + { + "id": 1, + "entry_id": 1, + "item_name": "My_class", + "item_type": "class", + "item_value": null } - }, - "meta": { - "count": "1", - "page": 1, - "timestamp": 1619116399, - "total": "1", - "cmdb_epoch": "13" + ] } + ], + "meta": { "total": 1, "page": 1, "count": 1 } } ``` -## Get host's specific configuration +## Create configuration entry -**URI:** https://hub.cfengine.com/api/cmdb/:hostkey/:type/:name/ +Create a new configuration entry for a host. -**Method:** GET +**URI:** https://hub.cfengine.com/api/cmdb/v2/:hostkey + +**Method:** POST **Parameters:** - **hostkey** _(string)_ Unique host identifier. -- **type** _(string)_ - Configuration type. Allowed value: `variables`, `classes` +**Request body parameters:** +- **type** _(string)_ + Configuration type. Allowed values: `inventory`, `class`, `variable`, `policy_configuration` - **name** _(string)_ - Configuration name. Classes or variables name. + Configuration entry name (max 255 characters). +- **description** _(string)_ + Configuration description. Optional parameter. +- **tags** _(array)_ + Array of tags. Optional parameter. +- **meta** _(object)_ + Metadata object. Optional parameter. +- **entries** _(array)_ + Array of sub-entries with the following structure: + - **item_name** _(string)_ - Name of the item (letters, numbers, dots, colons, underscores only) + - **item_type** _(string)_ - Type of item (`class` or `variable`) + - **item_value** _(mixed)_ - Value for variables (not used for classes). Optional parameter. -**Example request (curl):** +**Example request for class (curl):** ```console curl -k --user : \ - -X GET \ - https://hub.cfengine.com/api/cmdb/SHA=f622992fa4525070f47da086041a38733496f03a77880f70b1ce6784c38f79ab/variables/HubCMDB:My.hostname/ -``` - -**Example response:** - -``` -HTTP 200 Ok -{ - "hostkey": "SHA=437d63cdc0b13ad18bb2d9de2490bfabe4edc8aa59f248b5b5b050c77bf4eeef", - "variables": { - "default:def.augment_inputs": { - "tags": [ - "suggestion-004" - ], - "value": [], - "comment": "Add filenames to this list to make the CFEngine agent parse them. Note: Update the bundle sequence to evaluate bundles from these policy files." - } - } -} + -X POST \ + https://hub.cfengine.com/api/cmdb/v2/SHA=f622992fa4525070f47da086041a38733496f03a77880f70b1ce6784c38f79ab \ + -H 'content-type: application/json' \ + -d '{ + "type": "class", + "name": "class1", + "description": "CMDB class", + "tags": ["test_tag"], + "entries": [{ + "item_name": "class1", + "item_type": "class" + }] + }' ``` -## Get host's configurations - -**URI:** https://hub.cfengine.com/api/cmdb/:hostkey - -**Method:** GET - -**Parameters:** - -- **hostkey** _(string)_ - Unique host identifier. - -**Example request (curl):** +**Example request for variable (curl):** ```console curl -k --user : \ - -X GET \ - https://hub.cfengine.com/api/cmdb/SHA=f622992fa4525070f47da086041a38733496f03a77880f70b1ce6784c38f79ab + -X POST \ + https://hub.cfengine.com/api/cmdb/v2/SHA=f622992fa4525070f47da086041a38733496f03a77880f70b1ce6784c38f79ab \ + -H 'content-type: application/json' \ + -d '{ + "type": "variable", + "name": "my_variables", + "description": "Sample variables configuration", + "tags": ["variables", "config"], + "entries": [ + { + "item_name": "HubCMDB:My.hostname", + "item_type": "variable", + "item_value": "host1.cfengine.com" + } + ] + }' ``` **Example response:** -``` -HTTP 200 Ok +```json { - "hostkey": "SHA=f622992fa4525070f47da086041a38733496f03a77880f70b1ce6784c38f79ab", - "value": { - "classes": { - "My_class": {}, - "My_class2": { - "comment": "" - } - }, - "variables": { - "HubCMDB:My.hostname": { - "value": "host1.cfengine.com", - "comment": "My hostname should be set to this" - }, - "Namespace:BundleName.VariableName": { - "value": "myvalue" - } - } - } + "id": 123 } ``` -## Create configuration +## Get specific sub-entry -**URI:** https://hub.cfengine.com/api/cmdb/:hostkey/:type/:name/ +Get a specific sub-entry by type and name. -**Method:** POST +**URI:** https://hub.cfengine.com/api/cmdb/v2/subentry/:hostkey/:type/:name + +**Method:** GET **Parameters:** - **hostkey** _(string)_ Unique host identifier. - - **type** _(string)_ - Configuration type. Allowed value: `variables`, `classes` - + Sub-entry type (`class` or `variable`). - **name** _(string)_ - Configuration name. Classes or variables name. - -**Request body parameters:** - -- **value** _(string|array)_ - Variable value, can be array or text. Classes do not support values. - -- **comment** _(string)_ - Variables or classes description. Optional parameter. - -- **tags** _(array)_ - Variables or classes tags. Optional parameter. + Sub-entry name. **Example request (curl):** ```console curl -k --user : \ - -X POST \ - https://hub.cfengine.com/api/cmdb/SHA=f622992fa4525070f47da086041a38733496f03a77880f70b1ce6784c38f79ab/variables/Namespace:BundleName.Ports/ \ - -H 'content-type: application/json' \ - -d ' - { "value": ["80", "443"], - "comment":"Openning ports", - "tags" : ["ports", "tag"] - }' + -X GET \ + https://hub.cfengine.com/api/cmdb/v2/subentry/SHA=f622992fa4525070f47da086041a38733496f03a77880f70b1ce6784c38f79ab/variable/HubCMDB:My.hostname ``` **Example response:** -``` -HTTP 200 Ok -``` - -## Batch create configurations - -**URI:** https://hub.cfengine.com/api/cmdb - -**Method:** POST - -**Parameters:** - -- **hostkey** _(string)_ - Unique host identifier. -- **classes** _(JSON object)_ - The format is a JSON object where the key is class name and value is another JSON object - with optionals `comment` and `tags` property. - Example: - - ```json - { - "classes": { - "My_class": {}, - "My_class2": { - "comment": "comment body", - "tags": ["suggestion-001", "reporting"] - } - } - } - ``` - -- **variables** _(JSON object)_ - The format is a JSON object where the key is variable name and value is another JSON object - with a required `value` property and optionals `comment` and `tags`. - Example: - - ```json - { - "variables": { - "Namespace:BundleName.VariableName": { "value": "myvalue" }, - "HubCMDB:My.hostname": { - "value": "host1.cfengine.com", - "comment": "My hostname should be set to this", - "tags": ["suggestion-001", "reporting"] - } - } - } - ``` - -**Example request (curl):** - -```console -curl -k --user : \ - -X POST \ - https://hub.cfengine.com/api/cmdb \ - -H 'content-type: application/json' \ - -d '{ - "hostkey":"SHA=f622992fa4525070f47da086041a38733496f03a77880f70b1ce6784c38f79ab", - "classes":{ - "My_class": {}, - "My_class2":{ - "comment":"comment body", - "tags": ["suggestion-001", "reporting"] - } - }, - "variables":{ - "Namespace:BundleName.VariableName":{ - "value":"myvalue" - }, - "HubCMDB:My.hostname":{ - "value":"host1.cfengine.com", - "comment":"My hostname should be set to this" - } - } -}' +```json +{ + "id": 1, + "entry_id": 123, + "item_name": "HubCMDB:My.hostname", + "item_value": "host1.cfengine.com" +} ``` -**Example response:** +## Update configuration entry -``` -HTTP 201 Created -``` +Update an existing configuration entry by ID. -## Update configuration +**URI:** https://hub.cfengine.com/api/cmdb/v2/entry/:id -**URI:** https://hub.cfengine.com/api/cmdb/:hostkey/:type/:name/ - -**Method:** PATCH +**Method:** PUT **Parameters:** -- **hostkey** _(string)_ - Unique host identifier. - -- **type** _(string)_ - Configuration type. Allowed value: `variables`, `classes` - -- **name** _(string)_ - Configuration name. Classes or variables name. +- **id** _(integer)_ + Configuration entry ID. **Request body parameters:** -- **value** _(string|array)_ - Variable value, can be array or text. Classes do not support values. - -- **comment** _(string)_ - Variables or classes description. Optional parameter. - -- **tags** _(array)_ - Variables or classes tags. Optional parameter. - -- **name** _(string)_ - New name, in case of renaming. Optional parameter. +Same as create request: `type`, `name`, `description`, `tags`, `meta`, `entries` **Example request (curl):** ```console curl -k --user : \ - -X PATCH \ - https://hub.cfengine.com/api/cmdb/SHA=f622992fa4525070f47da086041a38733496f03a77880f70b1ce6784c38f79ab/variables/Namespace:BundleName.Ports/ \ + -X PUT \ + https://hub.cfengine.com/api/cmdb/v2/entry/123 \ -H 'content-type: application/json' \ - -d ' - { "value": ["80", "443"], - "comment":"Openning ports", - "tags" : ["ports", "tag"] + -d '{ + "type": "variable", + "name": "updated_variables", + "description": "Updated variables configuration", + "tags": ["variables", "updated"], + "entries": [ + { + "item_name": "HubCMDB:My.hostname", + "item_type": "variable", + "item_value": "newhost.cfengine.com" + } + ] }' ``` @@ -344,101 +226,40 @@ curl -k --user : \ HTTP 200 Ok ``` -## Batch update configurations - -**URI:** https://hub.cfengine.com/api/cmdb/:hostkey - -**Method:** PATCH - -**Parameters:** - -- **hostkey** _(string)_ - Unique host identifier. -- **classes** _(JSON object)_ - The format is a JSON object where the key is class name and value is another JSON object - with an optional `comment` property. - Example: - - ```json - { - "classes": { "My_class": {}, "My_class2": { "comment": "comment body" } } - } - ``` - -If you need to delete all classes from host you need to set null value: - -```json -{ - "classes": null -} -``` - -If your request body misses classes then the previous value will be preserved. +## Delete configuration entry -- **variables** _(JSON object)_ - The format is a JSON object where the key is variable name and value is another JSON object - with a required `value` property and an optional `comment` property. - Example: +Delete a configuration entry by ID. - ```json - { - "variables": { - "Namespace:BundleName.VariableName": { "value": "myvalue" }, - "HubCMDB:My.hostname": { - "value": "host1.cfengine.com", - "comment": "My hostname should be set to this" - } - } - } - ``` +**URI:** https://hub.cfengine.com/api/cmdb/v2/entry/:id -If you need to delete all variables from host you need to set null value: +**Method:** DELETE -```json -{ - "variables": null -} -``` +**Parameters:** -If your request body misses variables then the previous value will be preserved. +- **id** _(integer)_ + Configuration entry ID. **Example request (curl):** ```console curl -k --user : \ - -X PATCH \ - https://hub.cfengine.com/api/cmdb/SHA=f622992fa4525070f47da086041a38733496f03a77880f70b1ce6784c38f79ab \ - -H 'content-type: application/json' \ - -d '{ - "classes":{ - "My_class2":{ - "comment" : "" - }, - "My_class": {} - }, - "variables":{ - "Namespace:BundleName.VariableName":{ - "value":"myvalue" - }, - "HubCMDB:My.hostname":{ - "value":"host1.cfengine.com", - "comment":"My hostname should be set to this" - } - } -}' + -X DELETE \ + https://hub.cfengine.com/api/cmdb/v2/entry/123 ``` **Example response:** ``` -HTTP 200 Ok +HTTP 204 No Content ``` -## Delete host's configurations +## Get policy configuration IDs -**URI:** https://hub.cfengine.com/api/cmdb/:hostkey +Get all policy configuration IDs for a host. -**Method:** DELETE +**URI:** https://hub.cfengine.com/api/cmdb/v2/:hostkey/policy-configuration-ids + +**Method:** GET **Parameters:** @@ -449,43 +270,60 @@ HTTP 200 Ok ```console curl -k --user : \ - -X DELETE \ - https://hub.cfengine.com/api/cmdb/SHA=f622992fa4525070f47da086041a38733496f03a77880f70b1ce6784c38f79ab + -X GET \ + https://hub.cfengine.com/api/cmdb/v2/SHA=f622992fa4525070f47da086041a38733496f03a77880f70b1ce6784c38f79ab/policy-configuration-ids ``` **Example response:** -``` -HTTP 204 No Content +```json +[ + "policy-123", + "policy-456" +] ``` -## Delete specific configuration +## View Host-Specific JSON Configuration -**URI:** https://hub.cfengine.com/api/cmdb/:hostkey/:type/:name/ +Get the rendered JSON configuration file for a host. -**Method:** DELETE +**URI:** https://hub.cfengine.com/api/cmdb/v2/:hostkey/json + +**Method:** GET **Parameters:** - **hostkey** _(string)_ Unique host identifier. -- **type** _(string)_ - Configuration type. Allowed value: `variables`, `classes` - -- **name** _(string)_ - Configuration name. Classes or variables name. - **Example request (curl):** ```console curl -k --user : \ - -X DELETE \ - https://hub.cfengine.com/api/cmdb/SHA=f622992fa4525070f47da086041a38733496f03a77880f70b1ce6784c38f79ab/classes/My_class2/ + -X GET \ + https://hub.cfengine.com/api/cmdb/v2/SHA=f622992fa4525070f47da086041a38733496f03a77880f70b1ce6784c38f79ab/json ``` **Example response:** -``` -HTTP 204 No Content +```json +{ + "classes": { + "default:cfengine_internal_masterfiles_update": { + "comment": "Enable automatic VCS policy deployments", + "tags": [] + }, + "default:services_autorun": { + "comment": "Automatically evaluate bundles tagged with autorun.", + "tags": [] + } + }, + "variables": { + "variable_name": { + "comment": "test variable", + "tags": ["test"], + "value": "value" + } + } +} ``` diff --git a/content/api/enterprise-api-ref/shared-groups.markdown b/content/api/enterprise-api-ref/shared-groups.markdown index 40ebb9761..d69d5e3a0 100644 --- a/content/api/enterprise-api-ref/shared-groups.markdown +++ b/content/api/enterprise-api-ref/shared-groups.markdown @@ -401,11 +401,11 @@ API returns new ID of the personal group. The configuration management database (CMDB) API enables you to manage classes and variables for specific host groups. -## List CMDB +## Get CMDB for specific shared group You can see a list of stored group-specific configurations -**URI:** https://hub.cfengine.com/api/host-groups/shared/:id/cmdb +**URI:** https://hub.cfengine.com/api/host-groups/v2/shared/:id/cmdb **Method:** GET @@ -413,241 +413,231 @@ You can see a list of stored group-specific configurations - **id** _(integer)_ Unique group identifier. -- **fromEpoch** _(integer)_ - Returns configurations with epoch value greater than set in the filter. - Epoch is the sequence number of the latest CMDB change. In every API list request, - `cmdb_epoch` will be present in the meta section, which contains the maximum - epoch value among selected items. Optional parameter. -- **fromTime** _(timestamp)_ - Include changes performed within interval. Format: `YYYY-mm-dd HH:MM:SS` or `YYYY-mm-dd`. Optional parameter. -- **toTime** _(timestamp)_ - Include changes performed within interval. Format: `YYYY-mm-dd HH:MM:SS` or `YYYY-mm-dd`. Optional parameter. -- **skip** _(integer)_ - Number of results to skip for the processed - query. The Mission Portal uses this for pagination. Optional parameter. +- **sortColumn** _(string)_ + Column to sort by. Default: `created_at`. Optional parameter. +- **sortDescending** _(boolean)_ + Sort in descending order. Default: `true`. Optional parameter. - **limit** _(integer)_ - Limit the number of results in the query. Optional parameter. + Limit the number of results. Default: `10`. Optional parameter. +- **skip** _(integer)_ + Number of results to skip for pagination. Default: `0`. Optional parameter. **Example request (curl):** ```console curl -k --user : \ -X GET \ - https://hub.cfengine.com/api/host-groups/shared/4/cmdb?epochFrom=2 + https://hub.cfengine.com/api/host-groups/v2/shared/4/cmdb?limit=20&skip=0 ``` **Example response:** -``` -HTTP 200 Ok +```json { - "data": { - "5": { - "classes": { - "My_class": {}, - "My_class2": { - "comment": "comment helps to understand what this class serves for" - } - }, - "variables": { - "HubCMDB:My.hostname": { - "value": "host1.cfengine.com", - "comment": "comment" - }, - "Namespace:BundleName.VariableName": { - "value": "myvalue" - } - } + "data": [ + { + "id": 1, + "group_id": 4, + "type": "class", + "name": "My_class", + "description": "CMDB class example", + "tags": ["production", "webserver"], + "meta": {}, + "created_at": "2023-06-14 10:41:25.601112+00", + "entries": [ + { + "id": 1, + "group_id": 4, + "entry_id": 1, + "item_name": "My_class", + "item_type": "class", + "item_value": null } - }, - "meta": { - "count": "1", - "page": 1, - "timestamp": 1619116399, - "total": "1", - "cmdb_epoch": "13" + ] } + ], + "meta": { "total": 1, "page": 1, "count": 1 } } ``` ## Get group's specific configuration -**URI:** https://hub.cfengine.com/api/host-groups/shared/:id/cmdb/:type/:name/ +**URI:** https://hub.cfengine.com/api/host-groups/v2/shared/cmdb/:entry_id **Method:** GET **Parameters:** -- **id** _(integer)_ - Unique group identifier. - -- **type** _(string)_ - Configuration type. Allowed value: `variables`, `classes` - -- **name** _(string)_ - Configuration name. Classes or variables name. +- **entry_id** _(integer)_ + Unique entry identifier. **Example request (curl):** ```console curl -k --user : \ -X GET \ - https://hub.cfengine.com/api/host-groups/shared/5/cmdb/variables/HubCMDB:My.hostname/ + https://hub.cfengine.com/api/host-groups/v2/shared/cmdb/5 ``` **Example response:** -``` -HTTP 200 Ok +```json { - "group_id": "5", - "variables": { - "default:def.augment_inputs": { - "tags": [ - "suggestion-004" - ], - "value": [], - "comment": "Add filenames to this list to make the CFEngine agent parse them. Note: Update the bundle sequence to evaluate bundles from these policy files." - } - } + "id": 6, + "group_id": 5, + "type": "variable", + "name": "server_ports", + "description": "Server port configuration", + "tags": ["network", "config"], + "meta": {}, + "created_at": "2023-06-14 11:15:30.123456+00" } ``` -## Get group's configurations +## Get group's CMDB sub-entry -**URI:** https://hub.cfengine.com/api/host-groups/shared/:id/cmdb +**URI:** https://hub.cfengine.com/api/host-groups/v2/shared/:id/cmdb/subentry/:type/:name **Method:** GET **Parameters:** -- **id** _(string)_ +- **id** _(integer)_ Unique group identifier. +- **type** _(string)_ + Subentry type (`class` or `variable`) +- **name** _(string)_ + Subentry name. **Example request (curl):** ```console curl -k --user : \ -X GET \ - https://hub.cfengine.com/api/host-groups/shared/5/cmdb + https://hub.cfengine.com/api/host-groups/v2/shared/5/cmdb/subentry/variable/Namespace:BundleName.Ports ``` **Example response:** -``` -HTTP 200 Ok +```json { - "group_id": "5", - "value": { - "classes": { - "My_class": {}, - "My_class2": { - "comment": "" - } - }, - "variables": { - "HubCMDB:My.hostname": { - "value": "host1.cfengine.com", - "comment": "My hostname should be set to this" - }, - "Namespace:BundleName.VariableName": { - "value": "myvalue" - } - } - } + "id": 1, + "group_id": 5, + "entry_id": 6, + "item_name": "Namespace:BundleName.Ports", + "item_type": "variable", + "item_value": "[\"80\", \"443\", \"8080\"]" } ``` ## Create configuration -**URI:** https://hub.cfengine.com/api/host-groups/shared/:id/cmdb/:type/:name/ +**URI:** https://hub.cfengine.com/api/host-groups/v2/shared/:id/cmdb **Method:** POST **Parameters:** -- **id** _(string)_ +- **id** _(integer)_ Unique group identifier. -- **type** _(string)_ - Configuration type. Allowed value: `variables`, `classes` - -- **name** _(string)_ - Configuration name. Classes or variables name. - **Request body parameters:** -- **value** _(string|array)_ - Variable value, can be array or text. Classes do not support values. - -- **comment** _(string)_ - Variables or classes description. Optional parameter. - +- **type** _(string)_ + Configuration type. Allowed values: `inventory`, `class`, `variable`, `policy_configuration` +- **name** _(string)_ + Configuration entry name (max 255 characters). +- **description** _(string)_ + Configuration description. Optional parameter. - **tags** _(array)_ - Variables or classes tags. Optional parameter. + Array of tags. Optional parameter. +- **meta** _(object)_ + Metadata object. Optional parameter. +- **entries** _(array)_ + Array of sub-entries with the following structure: + - **item_name** _(string)_ - Name of the item (letters, numbers, dots, colons, underscores only) + - **item_type** _(string)_ - Type of item (`class` or `variable`) + - **item_value** _(mixed)_ - Value for variables (not used for classes). Optional parameter. **Example request (curl):** ```console curl -k --user : \ -X POST \ - https://hub.cfengine.com/api/host-groups/shared/5/cmdb/variables/Namespace:BundleName.Ports/ \ + https://hub.cfengine.com/api/host-groups/v2/shared/5/cmdb \ -H 'content-type: application/json' \ - -d ' - { "value": ["80", "443"], - "comment":"Openning ports", - "tags" : ["ports", "tag"] + -d '{ + "type": "class", + "name": "class1", + "description": "CMDB class", + "tags": ["test_tag"], + "entries": [ + { + "item_name": "class1", + "item_type": "class" + } + ] }' ``` **Example response:** -``` -HTTP 200 Ok +```json +{ + "id": "6" +} ``` ## Update configuration -**URI:** https://hub.cfengine.com/api/host-groups/shared/:id/cmdb/:type/:name/ +**URI:** https://hub.cfengine.com/api/host-groups/v2/shared/cmdb/:entry_id -**Method:** PATCH +**Method:** PUT **Parameters:** -- **id** _(string)_ - Unique group identifier. +- **entry_id** _(integer)_ + Unique entry identifier. + +**Request body parameters:** - **type** _(string)_ - Configuration type. Allowed value: `variables`, `classes` + Entry type. Examples: `class`, `variable`, `policy_configuration`, `inventory` - **name** _(string)_ - Configuration name. Classes or variables name. + Entry name. -**Request body parameters:** - -- **value** _(string|array)_ - Variable value, can be array or text. Classes do not support values. - -- **comment** _(string)_ - Variables or classes description. Optional parameter. +- **description** _(string)_ + Entry description. Optional parameter. - **tags** _(array)_ - Variables or classes tags. Optional parameter. + Entry tags. Optional parameter. -- **name** _(string)_ - New name, in case of renaming. Optional parameter. +- **meta** _(object)_ + Additional metadata. Optional parameter. + +- **entries** _(array)_ + Array of subentries containing the actual configuration data. **Example request (curl):** ```console curl -k --user : \ - -X PATCH \ - https://hub.cfengine.com/api/host-groups/shared/5/cmdb/variables/Namespace:BundleName.Ports/ \ + -X PUT \ + https://hub.cfengine.com/api/host-groups/v2/shared/cmdb/5 \ -H 'content-type: application/json' \ - -d ' - { "value": ["80", "443"], - "comment":"Openning ports", - "tags" : ["ports", "tag"] + -d '{ + "type": "variable", + "name": "updated_server_ports", + "description": "Updated server port configuration", + "tags": ["network", "config", "updated"], + "entries": [ + { + "item_name": "Namespace:BundleName.Ports", + "item_type": "variable", + "item_value": ["80", "443", "8080"] + } + ] }' ``` @@ -657,54 +647,23 @@ curl -k --user : \ HTTP 200 Ok ``` -## Delete group's configurations - -**URI:** https://hub.cfengine.com/api/host-groups/shared/:id/cmdb - -**Method:** DELETE - -**Parameters:** - -- **id** _(string)_ - Unique group identifier. - -**Example request (curl):** - -```console -curl -k --user : \ - -X DELETE \ - https://hub.cfengine.com/api/host-groups/shared/5/cmdb -``` - -**Example response:** - -``` -HTTP 204 No Content -``` - -## Delete specific configuration +## Delete specific configuration entry -**URI:** https://hub.cfengine.com/api/host-groups/shared/:id/cmdb/:type/:name/ +**URI:** https://hub.cfengine.com/api/host-groups/v2/shared/cmdb/:entry_id **Method:** DELETE **Parameters:** -- **id** _(string)_ - Unique group identifier. - -- **type** _(string)_ - Configuration type. Allowed value: `variables`, `classes` - -- **name** _(string)_ - Configuration name. Classes or variables name. +- **entry_id** _(integer)_ + Unique entry identifier. **Example request (curl):** ```console curl -k --user : \ -X DELETE \ - https://hub.cfengine.com/api/host-groups/shared/5/cmdb/classes/My_class2/ + https://hub.cfengine.com/api/host-groups/v2/shared/cmdb/5 ``` **Example response:**