How to: Add a dictionary in Deploy using curl and the REST API

Question

How do I add a dictionary in XL Deploy using curl and the REST API?

Answer

  1. Decide on the name of the dictionary and where it will reside. When we specify in the command line and in the source data file, we need to be specific with the full path to the dictionary. Be sure that the name is unique.
  2. To start, we create an XML source file holding the entries we want in the new dictionary. Of use for discovering the format of the file is issuing a GET of an existing dictionary as in the example below. This will give us output in the form of what the source file should look like.
[root@brix tom]# curl -u admin:changeme -X GET -H "Content-type:application/xml" 
http://10.0.0.16:4516/deployit/repository/ci/Environments/dictionary1

<udm.Dictionary id="Environments/dictionary1" token="7f709588-35ae-43e8-b6c2-8805edd2f7de"
created-by="admin" created-at="2021-03-19T16:23:25.808+0000" last-modified-by="admin"
last-modified-at="2021-03-19T17:40:33.465+0000">

<restrictToContainers/>
<restrictToApplications/>
<entries>
  <entry key="Massachusetts">MA</entry>
  <entry key="California">CA</entry>
  <entry key="Florida">FL</entry>
</entries>
</encryptedEntries>
</udm.Dictionary>

  1. Next, we create the input file (source.xml) to include the dictionary entries you wish. If we strip out the extraneous data from above such as create date and last modified and add the entries we want, we wind up with the following format for the input file. Note the udm.Dictionary ID value is the full path to the dictionary we want to create.
<udm.Dictionary id="Environments/dictionary2" >
<restrictToContainers/>
<restrictToApplications/>
<entries>
   <entry key="Massachusetts">MA</entry>
   <entry key="California">CA</entry>
   <entry key="Florida">FL</entry>
  <entry key="Ohio">OH</entry>
</entries>
</encryptedEntries>
</udm.Dictionary>
  1. From here we run the following command to create the dictionary:
[root@brix tom]# curl -u admin:changeme -X POST -H "Content-type:application/xml"
http://10.0.0.16:4516/deployit/repository/ci/Environments/dictionary2
  -d@source.xml

The output should look like the following:

<udm.Dictionary id="Environments/dictionary2" token="21ae7241-8003-46b4-ab1a-21ee03454969"
created-by="admin" created-at="2021-03-24T19:50:52.657+0000" last-modified-by="admin"
last-modified-at="2021-03-24T19:50:52.657+0000">
<restrictToContainers/>
<restrictToApplications/>
<entries>
   <entry key="Massachusetts">MA</entry>
   <entry key="Ohio">OH</entry>
   <entry key="California">CA</entry>
   <entry key="Florida">FL</entry>
</entries>
<encryptedEntries/>
</udm.Dictionary>

And we wind up with:

mceclip0.png

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.