API de REST rest-apis

AEM Screens proporciona una API RESTful simple que sigue al Sirena especificación. Permite navegar por la estructura de contenido y enviar comandos a dispositivos del entorno.

Se puede acceder a la API en http://localhost:4502/api/screens.json.

El JSON devuelto por las llamadas de API enumera las entidades relacionadas con el recurso actual. Después del autovínculo enumerado, cada una de estas entidades vuelve a ser accesible como recurso REST.

Por ejemplo, para acceder a las pantallas de nuestra ubicación de buque insignia de demostración, puede llamar a:

GET /api/screens/content/screens/we-retail/locations/demo/flagship.json HTTP/1.1
Host: http://localhost:4502

O con curl:

curl -u admin:admin http://localhost:4502/api/screens/content/screens/we-retail/locations/demo/flagship.json

El resultado tendría este aspecto:

{
  "class": [
    "aem-io/screens/location"
  ],
  "links": [
    {
      "rel": [
        "self"
      ],
      "href": "http://localhost:4502/api/screens/content/screens/we-retail/locations/demo/flagship.json"
    },
    {
      "rel": [
        "parent"
      ],
      "href": "http://localhost:4502/api/screens/content/screens/we-retail/locations/demo.json"
    }
  ],
  "properties": {…},
  "entities": [
    {
      "class": [
        "aem-io/screens/display"
      ],
      "links": [
        {
          "rel": [
            "self"
          ],
          "href": "http://localhost:4502/api/screens/content/screens/we-retail/locations/demo/flagship/single.json"
        }
      ],
      "rel": [
        "child"
      ],
      "properties": {
        "title": "Single Screen Display",
        "height": 1440,
        "description": "Demo location of a single screen display.",
        "name": "single",
        "width": 2560,
        "idletimeout": 300,
        "layoutrows": 1,
        "layoutcols": 1
      }
    },
    …
  ]
}

Y luego, para acceder a la pantalla única, puede llamar a:

GET /api/screens/content/screens/we-retail/locations/demo/flagship/single.json HTTP/1.1
Host: http://localhost:4502

Ejecución de acciones en el recurso executing-actions-on-the-resource

El JSON devuelto por las llamadas de API puede contener una lista de acciones disponibles en el recurso.

La visualización, por ejemplo, enumera una broadcast-command acción que permite enviar un comando a todos los dispositivos asignados a esa pantalla.

GET /api/screens/content/screens/we-retail/locations/demo/flagship/single.json HTTP/1.1
Host: http://localhost:4502

O con curl:

curl -u admin:admin http://localhost:4502/api/screens/content/screens/we-retail/locations/demo/flagship/single.json

Resultado:

{
  "class": [
    "aem-io/screens/display"
  ],
  "links": […],
  "properties": {…},
  "entities": […],
  "actions": [
    {
      "title": "",
      "name": "broadcast-command",
      "method": "POST",
      "href": "/api/screens/content/screens/we-retail/locations/demo/flagship/single",
      "fields": [
        {
          "name": ":operation",
          "value": "broadcast-command",
          "type": "hidden"
        },
        {
          "name": "msg",
          "type": "text"
        }
      ]
    }
  ]
}

Para almacenar en déclencheur esta acción se llamaría a:

POST /api/screens/content/screens/we-retail/locations/demo/flagship/single.json HTTP/1.1
Host: http://localhost:4502

:operation=broadcast-command&msg=reboot

O con curl:

curl -u admin:admin -X POST -d ':operation=broadcast-command&msg=reboot' http://localhost:4502/api/screens/content/screens/we-retail/locations/demo/flagship/single.json
recommendation-more-help
adce462a-f916-4dbe-9ab5-0b62cfb0f053