Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for new endpoints for collections in hydrus #152

Open
1 of 2 tasks
sameshl opened this issue Jul 31, 2020 · 1 comment
Open
1 of 2 tasks

Add support for new endpoints for collections in hydrus #152

sameshl opened this issue Jul 31, 2020 · 1 comment
Assignees

Comments

@sameshl
Copy link
Member

sameshl commented Jul 31, 2020

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

@priyanshunayan priyanshunayan self-assigned this Aug 5, 2020
@priyanshunayan
Copy link
Member

Seems like we need to discuss the Redis layer again due to the latest changes. Earlier, collection members were fetched from the server everytime a request was made to the Collection endpoint and only class instances were stored. And now since a class can have members just like collections, so we need to decide whether to cache them or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants