Scripts to talk to POMS Rest API.
Some plain XML examples can be found in examples
For python we maintain a 'poms.py' which is imported in the other python scripts. It provides a simple shelve-database with settings you use, and maps the rest-calls which are used in the scripts.
michiel@baleno:~/github/npo-poms/scripts/python$ ./post.py -r -t dev ../examples/program.xml
Username for https://api-dev.poms.omroep.nl/media/: vpro-mediatools
Password:
Username/password stored in file creds.db. Use -r to set it.
posting to https://api-dev.poms.omroep.nl/media/media?errors=michiel.meeuwissen@gmail.com
crid://bds.tv/9876,crid://tmp.fragment.mmbase.vpro.nl/1234
michiel@baleno:~/github/npo-poms/scripts/python$
This is quite straight forward and was later improved to be an actual (python library)[https://github.com/npo-poms/pyapi]. Some scripts in the python directory of this project make use of that library.
Since POMS is written in Java, it is actually feasible to use its domain objects in your scripts. Rest clients are available, which use these domain objects directly.
MediaRestClient client = new MediaRestClient();
client.setUrl(mediaRsUrl);
client.setUserName(userName);
client.setPassword(password);
client.setErrors(getMail());
..
GroupUpdate group = client.getGroup(id);
..
group.setPublishStart(onlineDate);
client.set(group);
In the directory java
of this project we appear code that (temporary) used these clients.
Simply calling 'curl' in shell script is of course possible too. These scripts include a 'creds.sh'. A template 'copy.to.creds.sh' is available. Do that and provide your own credentials in it. Most scripts can be prefixed with the environment:
michiel@belono:~/github/npo-poms/scripts/bash$ ENV=prod ./unpublish.sh WO_VPRO_717563
posting:
<?xml version="1.0"?>
<program xmlns="urn:vpro:media:update:2009" type="CLIP" avType="VIDEO" embeddable="true" mid="WO_VPRO_717563" publishStop="2015-02-07T11:28:05Z" urn="urn:vpro:media:program:48270798">
<broadcaster xmlns:media="urn:vpro:media:2009" xmlns:shared="urn:vpro:shared:2009">VPRO</broadcaster>
<title xmlns:media="urn:vpro:media:2009" xmlns:shared="urn:vpro:shared:2009" type="MAIN">test</title>
<locations xmlns:media="urn:vpro:media:2009" xmlns:shared="urn:vpro:shared:2009"/>
<scheduleEvents xmlns:media="urn:vpro:media:2009" xmlns:shared="urn:vpro:shared:2009"/>
<images xmlns:media="urn:vpro:media:2009" xmlns:shared="urn:vpro:shared:2009"/>
<segments xmlns:media="urn:vpro:media:2009" xmlns:shared="urn:vpro:shared:2009"/>
</program>
result:
WO_VPRO_717563
Sometimes operations involve modifying XML, which is done using xsltproc/XSLT in these scripts.