-
Notifications
You must be signed in to change notification settings - Fork 10
Links (proposal)
New domain object Link is intoduced. Link must include following attributes:
- href - Absolute (may be relative to base) uri to resource.
- methods - array of HTTP verbs to use (only GET is allowed, if omitted)
- rel - Link relation. May contain values:
- self - for self-pointing resources
- collection - to point to collection urls (GET)
Link may include:
- type - Domain type and media. This is possibly valid only for GET links.
Parts of entities are omitted for the sake of brevity.
- User starts with a root of application.
GET / (admin privileges)
[
{"href" : "/projects", "type": "application/vnd.griddynamics.genesis.Project+json", "rel": "collection"},
{"href" : "/settings", "type": "application/vnd.griddynamics.genesis.Link+json", "rel": "collection"}
]
GET / (no admin privileges)
[
{"href" : "/projects", "type": "application/vnd.griddynamics.genesis.Project+json", "rel": "collection"}
]
Setting has a type genesis.Link, because it's anything but links collection.
For non-admin user no /settings url will be present at this stage.
- User choose to continue with /projects link
GET /projects (admin privilieges)
{ "items" : [
{
"name" : "project",
"id" : "id",
"links" : [
{"href" : "/projects/1", "rel" : "self", "type": "application/vnd.griddynamics.genesis.Project+json"}
]
},
],
"links": [
{"href":"/projects", "methods": ["get","post"], "rel":"self", "type" : "application/vnd.griddynamics.genesis.Project+json"}
]
}
GET /projects (no admin privileges)
{
"items" : [
{
"name" : "project",
"id" : "id",
"links" : [
{"href" : "/projects/1", "rel" : "self", "type": "application/vnd.griddynamics.genesis.Project+json"}
]
},
]
}
For non-admin user no links array will be present, so user can't create projects.
GET /projects/1 with admin privileges
{
"id": "1",
"name" : "project",
"links": [
{"href" : "/ptojects/1/envs", "rel" : "collection", "methods" : ["get","post"], "type" : "application/vnd.griddynamics.genesis.Environment+json"},
{"href": "/project/1/settings", "rel" : "collection", "type" : "application/vnd.griddynamics.genesis.Link+json"},
{"href": "/projects/1", "rel" : "self", "methods" : ["get","put","delete"]}
]
}
GET /projects/1 without admin privileges (no new environments creation is allowed, too)
{
"id": "1",
"name" : "project",
"links": [
{"href" : "/projects/1/envs", "rel" : "collection", "type" : "application/vnd.griddynamics.genesis.Environment+json"},
{"href": "/projects/1", "rel" : "self"}
]
}
GET /projects/1 without admin privileges (new environments creation is allowed)
{
"id": "1",
"name" : "project",
"links": [
{"href" : "/projects/1/envs", "rel" : "collection", "method" : ["get", "post"], "type" : "application/vnd.genesis.griddynamics.Environment+json"},
{"href": "/projects/1", "rel" : "self"}
]
}
GET /projects/1/settings
Only admin and read-only admin
[
{"href" : "/project/1/configs", "rel" : "collection", "type" : "application/vnd.griddynamics.genesis.Configuration+json"},
{"href" : "/project/1/databags", "rel" :"collection", "type" : "application/vnd.griddynamics.genesis.Databag+json"},
....
]
GET /projects/1/databags
As an admin
{
"items" : [
{"id": "1",
"links": [
{"href" : "/projects/1/databags/1", "rel":"self", "methods" : ["get","put","delete"], "type":"application/vnd.griddynamics.genesis.Databag+json"}
]
}
],
"links" : [
{"href":"//projects/1/databags", "methods": ["get","post"], "rel":"self", "type" : "application/vnd.griddynamics.genesis.Databag+json"}
]
}
As a read-only admin
{
"items" : [
{"id": "1",
"links": [
{"href" : "/projects/1/databags":"1", "rel":"self", "type":"application/vnd.griddynamics.genesis.Databag+json"}
]}
],
"links" : [
{"href":"//projects/1/databags", "rel":"self", "type" :"application/vnd.griddynamics.genesis.Databag+json"}
]
}
GET /projects/1/envs/1
User that can only view environment:
{
"id" : 1
....
"links" : [
{"href": "/projects/1/envs/1", "rel": "self", "type":"application/vnd.griddynamics.genesis.EnvironmentDetails+json"}
{"href": "/projects/1/envs/1/history", "rel":"collection", "type":"application/vnd.griddynamics.genesis.WorkflowHistory"}
]
}
User that can modify environment:
{
"id" : 1
....
"links" : [
{"href": "/projects/1/envs/1", "rel": "self", "methods": ["get","put","delete"], "type":"application/vnd.griddynamics.genesis.EnvironmentDetails+json"}
{"href": "/projects/1/envs/1/history", "rel":"collection", "type":"application/vnd.griddynamics.genesis.WorkflowHistory"}
{"href": "/projects/1/envs/1/actions", "rel":"collection", "methods" : ["post"]}
]
}
Most probably, actions attribute of EnvironmentDetails object should be separated in its own REST resource for better consistency.
Only admin and readonly admin users here
** GET /settings **
Admin:
{
"items" : [
{"name":"genesis.system.beat.period.ms","value":"1000"},
...
]
"links": [
{"href" : "/settings", "rel":"self", "methods":["get","put","delete"],
"type":"application/vnd.griddynamics.genesis.ConfigProperty+json"},
{"href" : "/roles", "rel":"collection", "type" :
"application/vnd.griddynamics.genesis.GenesisRole+json"},
...
]
}
Readonly admin:
{
"items" : [
{"name":"genesis.system.beat.period.ms","value":"1000"},
...
]
"links": [
{"href" : "/settings", "rel":"self", "type":"application/vnd.griddynamics.genesis.ConfigProperty+json"},
{"href" : "/roles", "rel":"collection", "type" :
"application/vnd.griddynamics.genesis.GenesisRole+json"},
...
]
}