Skip to content

feature: add resources section #540

@panaaj

Description

@panaaj

The specification could benefit from the addition of a Resources section to describe the way in which to work with these data items. (Noted: that #218 has a similar subject)

I have included below an example of possible content that is modelled on existing specification content and aligns with the current PUT section to help start the conversation.

Resources

Resources are collections of objects that are used to represent data that serves as
additional information to aid with navigation etc.

Resources are:

  • Usually persisted in a non-volatile data store (i.e. not lost when server re-starts)
  • Potentially large in volume and / or record size
  • Able to be created, updated and deleted by both applications and server processes
  • Grouped by type and identified by a uuid (e.g. /signalk/v1/api/resources/routes/36f9b6b5-959f-46a1-8a68-82159742aadd)

Making a Request to Create, Update or Delete a Resource Entry

Requests are sent to a server to create, update or delete resource entries.

See Request/Response for more details on request/response in Signal K.

CREATING a Resource Entry

To create a resource entry, a POST request should be sent via HTTP or using a Signal K put delta.

The source field is optional. If a request is sent without the source and there is more than one source for the
value, the server should respond with a 400 (Bad Request) HTTP status code.

Via HTTP

POST http://localhost:3000/signalk/v1/api/vessels/resources/notes/36f9b6b5-959f-46a1-8a68-82159742aadd
{
  "value": {
      "position":{
          "latitude":-35.02577800787516,"longitude":138.02825595260182
        },
        "title":"My Note",
        "description":"My note description","url":"http://mynote/url","mimeType":"text/html"
  },
  "source": "myApp",
}

Via a Delta

{
  "context": "vessels.self",
  "requestId": "6b0e776f-811a-4b35-980e-b93405371bc5",
  "put": [{
        "path": "resources.notes.36f9b6b5-959f-46a1-8a68-82159742aadd",
        "value": {
            "position":{
                "latitude":-35.02577800787516,"longitude":138.02825595260182
            },
            "title":"My Note",
            "description":"My note description","url":"http://mynote/url","mimeType":"text/html"
        }
  }]
}

The context key is optional, and defaults to vessels.self, which is the usual case. You can include it to be able to set values on other vessels.

UPDATING a Resource Entry

To update a resource entry, a PUT request should be sent via HTTP or using a Signal K put delta.

Via HTTP

PUT http://localhost:3000/signalk/v1/api/vessels/resources/notes/36f9b6b5-959f-46a1-8a68-82159742aadd
{
  "value": {
      "position":{
          "latitude":-35.02577800787516,"longitude":138.02825595260182
        },
        "title":"My Note",
        "description":"My note description","url":"http://mynote/url","mimeType":"text/html"
  },
  "source": "myApp",
}

Via a Delta

{
  "context": "vessels.self",
  "requestId": "6b0e776f-811a-4b35-980e-b93405371bc5",
  "put": [{
        "path": "resources.notes.36f9b6b5-959f-46a1-8a68-82159742aadd",
        "value": {
            "position":{
                "latitude":-35.02577800787516,"longitude":138.02825595260182
            },
            "title":"My Note",
            "description":"My note description","url":"http://mynote/url","mimeType":"text/html"
        }
  }]
}

DELETING a Resource Entry

To delete a resource entry, a DELETE request should be sent via HTTP or using a Signal K put delta with a value of null.

Via HTTP

DELETE http://localhost:3000/signalk/v1/api/vessels/resources/notes/36f9b6b5-959f-46a1-8a68-82159742aadd

Via a Delta

{
  "context": "vessels.self",
  "requestId": "6b0e776f-811a-4b35-980e-b93405371bc5",
  "put": [{
        "path": "resources.notes.36f9b6b5-959f-46a1-8a68-82159742aadd",
        "value": null
  }]
}

Querying Resource Entries

As resource groups can potentially hold a large number of entries there needs to be a way of returning a subset of entries from the relevant /resources/<resource_group> path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions