Difference between revisions of "Information System Resource Registry"
Luca.frosini (Talk | contribs) (→REST API) |
Luca.frosini (Talk | contribs) (→REST API) |
||
Line 385: | Line 385: | ||
"model":"Opteron", | "model":"Opteron", | ||
"vendor":"AMD", | "vendor":"AMD", | ||
− | "clockSpeed":" | + | "clockSpeed":"2 GHz" |
} | } | ||
</pre> | </pre> | ||
Line 392: | Line 392: | ||
<pre> | <pre> | ||
{ | { | ||
− | "@class":"CPUFacet", "model":"Opteron", "vendor":"AMD", "clockSpeed":" | + | "@class":"CPUFacet", "model":"Opteron", "vendor":"AMD", "clockSpeed":"2 GHz", |
"header": { | "header": { | ||
"uuid":"69f0b376-38d2-4a85-bc63-37f9fa323f82", | "uuid":"69f0b376-38d2-4a85-bc63-37f9fa323f82", |
Revision as of 19:53, 21 October 2016
Resource Registry is part of gCube Information System.
Resource Registry is responsible for:
- Context Management : manage hierarchical Context.
- Schema Management : register and define Entities and Relations schema
- Entity Management : manage Entities and Relations instances of registered schemas
- Query and Access : query instances and get the schema definition of registered types
Every Port type is exposed as REST API.
Context Management
It is responsible for managing Context belonging to the same Application Domain.
Security configuration based on Authorization Framework make this port type accessible only from Resource Manager. In other words no others client is allowed to manage Context rather than Resource Manager.
Context requirements:
- No predefined number of levels.
- Possibility to change the name of the Context with no impact for any component.
- Possibility to move a Context from a parent Context to another.
Available Methods:
Create
PUT /resource-registry/context
Description
Create new Context
Parameters
Name | Type | Required | Description |
---|---|---|---|
name | String | true | The name of the context. |
parentContextId | String (UUID) | false | The UUID of the parent Context if any |
Responses
Code | Type | Description |
---|---|---|
200 | String (UUID) | The String representation of the UUID assigned to the created Context |
Examples
URL | Description | Response Example |
---|---|---|
/resource-registry/context?name=gCube | Create a new Context with name gCube | a2fe0030-7b3d-4617-ba37-532c0e4b778d |
PUT /resource-registry/context?name=devsec[&parentContextId=a2fe0030-7b3d-4617-ba37-532c0e4b778d] -> c0f314e7-2807-4241-a792-2a6c79ed4fd0
PUT /resource-registry/context?name=devVRE[&parentContextId=c0f314e7-2807-4241-a792-2a6c79ed4fd0] -> d821bcc0-946b-11e6-bdf4-0800200c9a66
Rename
POST /resource-registry/context/rename/d821bcc0-946b-11e6-bdf4-0800200c9a66?name=devNext
Move
POST /resource-registry/context/move/d821bcc0-946b-11e6-bdf4-800200c9a66[?parentContextId=a2fe0030-7b3d-4617-ba37-532c0e4b778d
Delete
DELETE /resource-registry/context/d821bcc0-946b-11e6-bdf4-0800200c9a66
Schema Management
Property Type are mapped to and integer to be used in property definition:
Type binder is defined here: [1]
Type | Integer Mapping | Java type | Description |
---|---|---|---|
Boolean | 0 | java.lang.Boolean or boolean
|
Handles only the values True or False. |
Integer | 1 | java.lang.Integer or int or java.math.BigInteger
|
32-bit signed Integers. |
Short | 2 | java.lang.Short or short
|
Small 16-bit signed integers. |
Long | 3 | java.lang.Long or long
|
Big 64-bit signed integers. |
Float | 4 | java.lang.Float or float
|
Decimal numbers |
Double | 5 | java.lang.Double or double
|
Decimal numbers with high precision. |
Date | 6 | java.util.Date
|
Any date with the precision up to milliseconds. |
String | 7 | java.lang.String
|
Any string as alphanumeric sequence of chars. |
Binary | 8 | java.lang.Byte[] or byte[]
|
Can contain any value as byte array. |
Embedded | 9 | ? extends org.gcube.informationsystem.model.embedded.Embedded
|
This is an Object contained inside the owner Entity and has no Header. It is reachable only by navigating the owner Entity. |
Embedded list | 10 | List<? extends org.gcube.informationsystem.model.embedded.Embedded>
|
List of Objects contained inside the owner Entity and have no Header. They are reachable only by navigating the owner Entity. |
Embedded set | 11 | Set<? extends org.gcube.informationsystem.model.embedded.Embedded>
|
Set (no duplicates) of Objects contained inside the owner Entity and have no Header. They are reachable only by navigating the owner Entity. |
Embedded map | 12 | Map<String, ? extends org.gcube.informationsystem.model.embedded.Embedded>
|
Map of Objects contained inside the owner Entity and have no Header. They are reachable only by navigating the owner Entity. |
Byte | 17 | java.lang.Byte or byte
|
Single byte. usesful to store small 8-bit signed integers. |
Resource Type Creation
PUT /resource-registry/schema/resource?schema={ "name":"Actor", "description":"Any entity (human or machine) playing an active role.", "abstractType":true, /* If the Resource cannot be instantiated */ "superclasses":["Resource"], /* Resource of any registered specialization. */ "properties":null /* MUST be null. The Resource cannot have any property. */ }
Facet Type Creation
PUT /resource-registry/schema/facet
Parameter
schema={ "name":"ContactFacet", "description":"This facet is expected to capture contact information", "abstractType": false, "superclasses":["Facet"], "properties":[ { "name":"name", "description":"First Name", "mandatory":true, "readonly":false, "notnull":true, "max":null, "min":null, "regexpr":null, "linkedType":null, "linkedClass":null, "type":7 /* String*/ },{ "name":"eMail", "description": "A restricted range of RFC‑822 compliant email address. ... ", "mandatory":true, "readonly":false, "notnull":true, "max":null, "min":null, "regexpr":"^[a-z0-9._%+-]{1,128}@[a-z0-9.-]{1,128}$", "linkedType":null, "linkedClass":null, "type":7 /* String */ } ] }
isRelatedTo Type Creation
PUT /resource-registry/schema/isRelatedTo
Parameter
schema={ "name":"Hosts", "description": "…”, "abstractType":false, "superclasses":["IsRelatedTo"], "properties":[] }
consistsOf Type Creation
PUT /resource-registry/schema/consistsOf?schema={ "name":"HasContact", "description":"", "abstractType":true, "superclasses":["ConsistsOf"], "properties":[] }
Embedded Type Creation
PUT /resource-registry/schema/embedded
Parameter
schema={ "name":"AccessPolicy", "description":"", "abstractType":false, "superclasses":[], "properties":[{ "name":"policy", "description":"", "mandatory":false, "readonly":false, "notnull":false, "max":null, "min":null, "regexpr":null, "linkedType":null, "linkedClass":”ValueSchema”, "type": 9 /* Embedded */ },{ "name":"note", "description":"", "mandatory": false, "readonly":false, "notnull":false, "max":null, "min":null, "regexpr":null, "linkedType":null, "linkedClass":null, "type":7 /* String */ }] }
Entity Management
Apart the REST API this port type can be used also by using a Java client
<dependency> <groupId>org.gcube.information-system</groupId> <artifactId>resource-registry-publisher</artifactId> <version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version> </dependency>
To use the client you need first get a resourceRegistryPublisher instance. By using create method the library automatically query the Information System to get the correct endpoint for the current context.
SecurityTokenProvider.instance.set("Your-NextNext-Token-Here"); //If not already set ResourceRegistryPublisher resourceRegistryPublisher = ResourceRegistryPublisherFactory.create();
Facet Instances APIs
Create Facet Instance
REST API
PUT /resource-registry/entity/facet/CPUFacet
Parameter
definition={ "@class":"CPUFacet", "header":null, "model":"Opteron", "vendor":"AMD", "clockSpeed":"1 GHz" }
Response
{ "@class":"CPUFacet", "model":"Opteron", "vendor":"AMD", "clockSpeed":"1 GHz", "header": { "uuid":"69f0b376-38d2-4a85-bc63-37f9fa323f82", "creator":"luca.frosini", "creationTime":"2016-10-05 11:16:24", "lastUpdateTime":"2016-10-05 11:16:24 } }
Java API
CPUFacet cpuFacet = new CPUFacetImpl(); cpuFacet.setClockSpeed("1 GHz"); cpuFacet.setModel("Opteron"); cpuFacet.setVendor("AMD"); CPUFacet createdCpuFacet = resourceRegistryPublisher.createFacet(CPUFacet.class, cpuFacet); createdCpuFacet.getHeader().getUUID();
Update Facet Instance
REST API
POST /resource-registry/entity/facet/69f0b376-38d2-4a85-bc63-37f9fa323f82
Parameter
definition={ "@class":"CPUFacet", "header":{"uuid":"69f0b376-38d2-4a85-bc63-37f9fa323f82"}, "model":"Opteron", "vendor":"AMD", "clockSpeed":"2 GHz" }
Response
{ "@class":"CPUFacet", "model":"Opteron", "vendor":"AMD", "clockSpeed":"2 GHz", "header": { "uuid":"69f0b376-38d2-4a85-bc63-37f9fa323f82", "creator":"luca.frosini", "creationTime":"2016-10-05 11:16:24", "lastUpdateTime":"2016-10-05 11:17:32" } }
Java API
createdCpuFacet.setClockSpeed("2 GHz"); CPUFacet updatedCpuFacet = resourceRegistryPublisher.updateFacet(CPUFacet.class, createdCpuFacet);
Delete Facet Instance
REST API
DELETE /resource-registry/entity/facet/69f0b376-38d2-4a85-bc63-37f9fa323f82
Java API
boolean deleted = resourceRegistryPublisher.deleteFacet(createdCpuFacet);
Resource Instances APIs
Create Resource Instance
REST API
PUT /resource-registry/entity/resource/HostingNode
Parameter
definition={ "@class":"HostingNode", "consistsOf":[ { "@class":"ConsistsOf", "target":{ "@class":"CPUFacet", "model":"Opteron", "vendor":"AMD", "clockSpeed":"1 GHz" } },{ "@class":"IsIdentifiedBy", "target":{ "@class":"NetworkingFacet", "header":{"uuid":"59617b01-5856-4d8e-b85c-590a42039933"}, } } ], "isRelatedTo":[ { "@class":"Hosts", "target":{ "@class":"EService", "header":{"uuid":"9bff49c8-c0a7-45de-827c-accb71defbd3 " } } ] }
Response
{ "@class":"HostingNode", "header":{"uuid":"670eeabf-76c7-493f-a449-4e6e139a2e84"}, "consistsOf":[ { "@class":"ConsistsOf", "header":{"uuid":"9d0b1b2b-ac4e-40a9-8dea-bec90076e0ca"}, "target":{ "@class":"CPUFacet", "header":{"uuid":"1daef6a8-5ca4-4700-844b-2a2d784e17b0"}, "model":"Opteron", "vendor":"AMD", "clockSpeed":"1 GHz" } },{ "@class":"IsIdentifiedBy", "header":{"uuid":"02a7072c-4f72-4568-945b-9ddccc881e9f"}, "target":{ "@class":"NetworkingFacet", "header":{"uuid":"59617b01-5856-4d8e-b85c-590a42039933"}, ..... } } ], "isRelatedTo":[ { "@class":"Hosts", "header":{"uuid":"47494ad0-e606-4630-9def-4c607761ae14"}, "target":{ "@class":"EService", "header":{"uuid":"9bff49c8-c0a7-45de-827c-accb71defbd3 " } } ] }
Java API
CPUFacet cpuFacet = new CPUFacetImpl(); cpuFacet.setClockSpeed("1 GHz"); cpuFacet.setModel("Opteron"); cpuFacet.setVendor("AMD"); CPUFacet createdCpuFacet = resourceRegistryPublisher.createFacet(CPUFacet.class, cpuFacet); createdCpuFacet.getHeader().getUUID();
Delete Facet Instance
REST API
DELETE /resource-registry/entity/facet/69f0b376-38d2-4a85-bc63-37f9fa323f82
Java API
boolean deleted = resourceRegistryPublisher.deleteFacet(createdCpuFacet);
Relation Instances APIs
Query Management
...