Skip to content

Developers

How can we help you?

← Go back

Target platform

Note: This resource links can be expanded using the expand option.

The Target Platform resource is used to specify the output platforms for which a given resource (normally an Image or a Rendition) is good for.

For instance, you could have one image associated to a title that is valid for multiple platforms and some other images which are valid for other platforms.

We’re going to explain how to manipulate target platforms associated to images. But the same can be applied for other resources, like renditions.

In BeBanjo land, a target platform looks like:

<target-platform>
  <link rel="self" href="https://movida.bebanjo.net/api/target_platforms/1"/>
  <link rel="platform" href="https://movida.bebanjo.net/api/platforms/1"/>
</target-platform>
{
  "resource_type": "target_platform",
  "self_link": "https://movida.bebanjo.net/api/target_platforms/23548932",
  "platform_link": "https://movida.bebanjo.net/api/platforms/4763"
}

Get a List of all target platforms of a resource

Target platforms are accessed via its Content Resource, for example, Image Resource. Refer to the corresponding resource page, i.e. BeBanjo Resource: Image page to find out how to access an Image. Inside an Image, one of the related link nodes is the target_platforms node, identified by the rel attribute. Like here:

<?xml version='1.0' encoding='utf-8' ?>
<image>
  <!-- ... -->
  <link rel="target_platforms" href="https://movida.bebanjo.net/api/images/1/target_platforms"/>
  <!-- ... -->
</image>
{
  "resource_type": "image",
  // ...
  "target_platforms_link": "https://movida.bebanjo.net/api/images/1/target_platforms",
  // ...
}

If we follow that link we can fetch the list of all target platforms for that image.

$ curl --digest -u robot_user:password https://movida.bebanjo.net/api/images/1/target_platforms
$ curl --digest -u robot_user:password -H "Accept: application/json" https://movida.bebanjo.net/api/images/1/target_platforms
<?xml version="1.0" encoding="UTF-8"?>
<target-platforms type="array">
  <target-platform>
    <link rel="self" href="https://movida.bebanjo.net/api/target_platforms/5"/>
    <link rel="platform" href="https://movida.bebanjo.net/api/platforms/1"/>
  </target-platform>
</target-platforms>
{
  "entries": [
    {
      "resource_type": "target_platform",
      "self_link": "https://movida.bebanjo.net/api/target_platforms/5",
      "platform_link": "https://movida.bebanjo.net/api/platforms/1"
    }
  ]
}

Creating target platform for a resource

To create a new target platform, you just need to POST a proper XML/JSON target platform representation to the target platforms URL of the resource. That URL can be found in a link which rel attribute equals target_platforms. The only attribute is the platform .

For example, this POST would create a target platform (we’ll use curl’s @ option, which reads data to be posted from a file):

$ cat target_platform.xml
$ cat target_platform.json
<?xml version="1.0" encoding="UTF-8"?>
<target_platform>
  <link rel="platform" href="https://movida.bebanjo.net/api/platforms/1"/>
</target_platform>
{
  "platform_link": "https://movida.bebanjo.net/api/platforms/1"
}
$ curl --digest -u robot_user:password -H "Content-Type: application/xml" -X POST -d @target_platform.xml "https://movida.bebanjo.net/api/images/1/target_platforms"
$ curl --digest -u robot_user:password -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d @target_platform.json "https://movida.bebanjo.net/api/images/1/target_platforms"

BeBanjo will return the full XML/JSON of the target platform just created:

<?xml version="1.0" encoding="UTF-8"?>
<target-platform>
  <link rel="self" href="https://movida.bebanjo.net/api/target_platforms/1"/>
  <link rel="platform" href="https://movida.bebanjo.net/api/platforms/1"/>
</target-platform>
{
  "resource_type": "target_platform",
  "self_link": "https://movida.bebanjo.net/api/target_platforms/1",
  "platform_link": "https://movida.bebanjo.net/api/platforms/1"
}

Updating a target platform

You can update target platforms using a PUT request to the URL of a given target platform, as the following example illustrates.

$ cat target_platform.xml
$ cat target_platform.json
<?xml version="1.0" encoding="UTF-8"?>
<target_platform>
  <link rel="platform" href="https://movida.bebanjo.net/api/platforms/2"/>
</target_platform>
{
  "platform_link": "https://movida.bebanjo.net/api/platforms/2"
}

Now we send the XML/JSON as the body of a PUT request to the target_platform’s URL

$ curl --digest -u robot_user:password -H "Content-Type: application/xml" -X PUT -d @target_platform.xml "https://movida.bebanjo.net/api/target_platforms/1"
$ curl --digest -u robot_user:password -H "Content-Type: application/json" -H "Accept: application/json" -X PUT -d @target_platform.json "https://movida.bebanjo.net/api/target_platforms/1"

The PUT request would return the updated XML/JSON of the target platform:

<?xml version="1.0" encoding="UTF-8"?>
<target-platform>
  <link rel="self" href="https://movida.bebanjo.net/api/target_platforms/1"/>
  <link rel="platform" href="https://movida.bebanjo.net/api/platforms/2"/>
</target-platform>
{
  "resource_type": "target_platform",
  "self_link": "https://movida.bebanjo.net/api/target_platforms/1",
  "platform_link": "https://movida.bebanjo.net/api/platforms/2"
}

Delete a target platform

The following example shows how to destroy a particular target platform. Only a DELETE HTTP request to its URL is required:

$ curl --digest -u robot_user:password -X DELETE "https://movida.bebanjo.net/api/target_platforms/1"
$ curl --digest -u robot_user:password -H "Accept: application/json" -X DELETE "https://movida.bebanjo.net/api/target_platforms/1"

The DELETE request doesn’t return anything, as that target platform is now gone.

Deleting a target platform doesn’t delete the targeted content nor the platform.