Using API on Management Center to update policy object
search cancel

Using API on Management Center to update policy object

book

Article ID: 171607

calendar_today

Updated On:

Products

Management Center Management Center - VA

Issue/Introduction

You can use the Application Programmable Interface (API) on the Management Center (MC) to push a policy object using curl. For reference every MC contains a guide located at https://YourMC_IP_or_FQDN:8082/help/api. There are three methods supported - GET, PUT and POST

Resolution

You can first use GET to find out the UUID of the object you wish to update as well as the contents and json syntax of the object.

NOTE: All the object accessible via API on MC are in json format.

curl -k -H "X-Auth-Token: YOUR_API_TOKEN -X GET https://yourMC:8082/api/policies

NOTE: You can use BasicAuth providing your username and password but the API is more secure option. Should you wish to use the credentials in plain text use the "-u" switch instead of the " -H "X-Auth-Token: {VALUE.EN_US} " switch

The output of this command is all the policy objects on the MC. You can restrict access to only a single policy object via "Roles" applied to the user that has the API key.


}, {
  "uuid" : "2AD0B755-9920-48A0-AD60-CD7FA9065FF3",
  "name" : "Untitled",
  "contentType" : "cpl",
  "description" : "",
  "referenceId" : "Untitled",
  "tenant" : null,
  "author" : "admin",
  "shared" : false,
  "replaceVariables" : true


To update the content of the policy object use the below syntax and save this file on any machine that can run curl.

{
  "content" : {
    "sections" : [ {
      "name" : "Untitled",
      "purpose" : "CustomSolution",
      "defaultPolicy" : "I used an API token with no user to update the policy. This is where the policy goes",
      "overridePolicy" : null,
      "mandatoryPolicy" : null
    } ],
    "editMode" : "SECTIONED",
    "referenceDeviceUuid" : null
  },
  "schemaVersion" : "1.0",
  "contentType" : "cpl",
    "changeDescription" : "This is where you put a comment about the change"
   }
  }


The curl command to push the change with the above syntax is:

curl -k -H "X-Auth-Token: {YOURTOKEN.EN_US}"  -d "@/path/path/policy-file.txt" -H "Content-Type: application/json" -X POST https://yourMC:8082/api/policies/{YourUUID}content

If executed succesfully the command will return the new content of the new policy. Otherwise you get a HTTP status code (eg 404, 500, 401)