Skip to content

Add support for new endpoints for collections in hydrus #152

Description

@sameshl

I'm submitting a

  • bug report.
  • feature request.

Current Behaviour:

hydrus will support treating collections as a resource once PR HTTP-APIs/hydrus#488 gets merged.
This will bring in some changes to the endpoints at which hydrus is serving data.

Those changes need to be added to agent appropriately.

Expected Behaviour:

Brief description of major changes to the endpoints:

(Note: For below discussion, CommandCollection is a collection class, Command would be non-collection class / parsed class. The meaning of non-collection class would be any class which will not act as a 'collection' of items.)

  1. GET on /collection/
Example endpoint: /CommandCollection/

This fetches the data from the 'CommandCollection' table.

Example response:

Will return a list of collections.

{
"@context": "/serverapi/contexts/CommandCollection.jsonld",
"@id": "/serverapi/CommandCollection/",
"@type": "CommandCollection",
"hydra:totalItems": 3,
"hydra:view": {
"@id": "/serverapi/CommandCollection?page=1",
"@type": "hydra:PartialCollectionView",
"hydra:first": "/serverapi/CommandCollection?page=1",
"hydra:last": "/serverapi/CommandCollection?page=1"
},
"members": [
{
"@id": "/serverapi/CommandCollection/7d2cc88f-388a-43f1-80fc-0c2184de4784",
"@type": "CommandCollection"
},
{
"@id": "/serverapi/CommandCollection/50ed3b68-9437-4c68-93d4-b67013b9d412",
"@type": "CommandCollection"
},
{
"@id": "/serverapi/CommandCollection/c2e10f88-d205-41e7-aa61-338afd64f657",
"@type": "CommandCollection"
}
]
}
  1. PUT on /collection/
Example endpoint: /CommandCollection/

The request body should have the list of ids of class instances which would be grouped into a collection.
For eg,

{
"@type": "CommandCollection",
"members": ["aaaaa",
"bbbbb",
"ccccc"]
}

In the above example, 'aaaaaa', 'bbbbb' and 'ccccc' are the ids(primary key) of the instances in Command table.
This adds data in the 'CommandCollection' table.

Example response:
{
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
"@type": "Status",
"description": "Object with ID 50ed3b68-9437-4c68-93d4-b67013b9d412 successfully added",
"statusCode": 201,
"title": "Object successfully added."
}

NOTE: The id returned is actually the value of the collection_id column in the table, not the primary key id.
3) GET on /collection/id

Example endpoint: /CommandCollection/50ed3b68-9437-4c68-93d4-b67013b9d412

Note: The id is corresponding to the collection_id column in the CommandCollection table, not the primary key id.

Example response:

Will return all the members belonging to the collection with given collection_id.

{
"@context": "/serverapi/contexts/CommandCollection.jsonld",
"@id": "/serverapi/CommandCollectionCollection/50ed3b68-9437-4c68-93d4-b67013b9d412",
"@type": "CommandCollection",
"members": [
{
"@id": "/serverapi/Command/aaaaaa",
"@type": "Command"
},
{
"@id": "/serverapi/Command/bbbbbb",
"@type": "Command"
},
{
"@id": "/serverapi/Command/cccccc",
"@type": "Command"
}
]
}
  1. POST on /collection/id
Example endpoint: /CommandCollection/50ed3b68-9437-4c68-93d4-b67013b9d412

The request body should have the list of members to be updated for the given collection.
For eg,

{
"@type": "CommandCollection",
"members": ["ddd",
"eee",
"fff"]
}

Note: The id is corresponding to the collection_id column in the CommandCollection table, not the primary key id.

Example response:

Will update all the members belonging to the collection with given collection_id with the members given in the request body.

{
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
"@type": "Status",
"description": "Object with ID 50ed3b68-9437-4c68-93d4-b67013b9d412 successfully updated",
"statusCode": 200,
"title": "Object updated"
}
  1. DELETE on /collection/id
Example endpoint: /CommandCollection/50ed3b68-9437-4c68-93d4-b67013b9d412

Note: The id is corresponding to the collection_id column in the CommandCollection table, not the primary key id.

Example response:

Will delete that collection from the table.

{
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
"@type": "Status",
"description": "Object with ID 50ed3b68-9437-4c68-93d4-b67013b9d412 successfully deleted",
"statusCode": 200,
"title": "Object successfully deleted."
}
  1. GET, PUT, POST and DELETE on any /non-collection-class
Example endpoint: /Command/ or /Area

NOTE: All of these will have the same behaviour as what would have happened before on /CommandCollection/ endpoint

Metadata

Metadata

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