A CTMS Session using the CTMS Registry

The aim of this document is to give developers information how to use the CTMS Registry to put working with CTMS APIs into effect. This example shows how access to the root folder of a system’s folder hierarchy works.

  • We assume that authorization was done via an HTTP basic authorization string that can be obtained from Avid. The authorization provides an OpenID token, which is to be used as the bearer token for upcoming communication with the upstream service in the HTTP "Authorization" header.

  • Request the CTMS Registry:

GET https://host/ctms-registry/v1
Accept: application/hal+json
Authorization: Bearer <OpenID token>
  • Get the 'loc:root-item' resources from the CTMS Registry’s response. 'loc:root-item' can potentially be provided by multiple CTMS-compatible service instances, therefore the result is a list of 'loc:root-item' resources:

var rootItemResources = jsonPath("$.'resources'..'loc:root-item'");
  • For this example let’s pick the very first 'loc:root-item' resource. In a real world scenario a resource provided by a specific systemId would be picked:

var rootItemResource = rootItemResources[0];
  • Each resource returned from the CTMS Registry provides an URI template. We can use this URI template to build the effective URL to request the root folder. So let’s get the URI templates of the 'loc:root-item' resource:

var rootItemUriTemplate = rootItemResource.jsonPath("..href");
  • The returned rootItemUriTemplate looks like this:

https://upstream/apis/avid.mam.assets.access;version=0;realm=021B5C9B-3966-4A1E-A8A3-23DCA1A2FBDE/locations/items
  • If the URI template contains any template parameters they need to be replaced with the actual arguments. Using a library to handle URI templates is recommended, because it cares for the correct replacement and the correct URL-encoding of the arguments. In this case the template URI does not contain any template parameters.

var rootItemUri = rootItemUriTemplate.expand();
  • Since there were no template parameters present in the URI template the effective URI looks the same as before:

https://upstream/apis/avid.mam.assets.access;version=0;realm=021B5C9B-3966-4A1E-A8A3-23DCA1A2FBDE/locations/items
  • Next we request rootItemUri and get the the root folder resource

GET https://upstream/apis/avid.mam.assets.access;version=0;realm=021B5C9B-3966-4A1E-A8A3-23DCA1A2FBDE/locations/items
Accept: application/hal+json
Authorization: Bearer <OpenID token>
  • In the result, we can retrieve the list of folders and iterate over it:

var folderList = rootItemResult.jsonPath("..'_embedded'..'loc:collection'..'_embedded'..'loc:item'");
for (var folder : folderList) {
	var folderId = asset.jsonPath("..base.id");
	var folderName = asset.jsonPath("..common.name");
}
  • Finally, once you’re done, logout from the platform

Code examples can be found in the CTMS Client examples.