Difference between revisions of "Information System Resource Registry"
Luca.frosini (Talk | contribs) (→Query & Access) |
Luca.frosini (Talk | contribs) |
||
Line 14: | Line 14: | ||
Every Port type is exposed as [https://en.wikipedia.org/wiki/Representational_state_transfer REST] API. | Every Port type is exposed as [https://en.wikipedia.org/wiki/Representational_state_transfer REST] API. | ||
− | == Context Management == | + | == Port Types == |
+ | |||
+ | === Context Management === | ||
It is responsible for managing [[Facet_Based_Resource_Model#Context| Context]] belonging to the same Application Domain. | It is responsible for managing [[Facet_Based_Resource_Model#Context| Context]] belonging to the same Application Domain. | ||
Line 37: | Line 39: | ||
− | === Create === | + | ==== Create === |
<pre>PUT /resource-registry/context</pre> | <pre>PUT /resource-registry/context</pre> | ||
− | ==== Description ==== | + | ===== Description ==== |
Create new Context as child of another Context (if any). | Create new Context as child of another Context (if any). | ||
− | ==== Parameters ==== | + | ===== Parameters ==== |
{|class="wikitable" | {|class="wikitable" | ||
Line 64: | Line 66: | ||
|} | |} | ||
− | ==== Responses ==== | + | ===== Responses ==== |
{|class="wikitable" | {|class="wikitable" | ||
Line 76: | Line 78: | ||
|} | |} | ||
− | ==== Examples ==== | + | ===== Examples ==== |
Create a new Context with name '''gcube''' with no parent. It is a ROOT Context. | Create a new Context with name '''gcube''' with no parent. It is a ROOT Context. | ||
Line 147: | Line 149: | ||
</pre> | </pre> | ||
− | === Rename === | + | ==== Rename === |
<pre>POST /resource-registry/context/rename/{UUID}</pre> | <pre>POST /resource-registry/context/rename/{UUID}</pre> | ||
− | ==== Description ==== | + | ===== Description ==== |
Rename a Context identified by the UUID provided as path parameter to the new name provided as query parameter. | Rename a Context identified by the UUID provided as path parameter to the new name provided as query parameter. | ||
− | ==== Parameters ==== | + | ===== Parameters ==== |
{|class="wikitable" | {|class="wikitable" | ||
Line 174: | Line 176: | ||
|} | |} | ||
− | ==== Responses ==== | + | ===== Responses ==== |
{|class="wikitable" | {|class="wikitable" | ||
Line 186: | Line 188: | ||
|} | |} | ||
− | ==== Examples ==== | + | ===== Examples ==== |
Rename a Context '''9d73d3bd-1873-490c-b0a7-e3c0da11ad52''' (was '''devVRE''') to the new name '''devNext'''. | Rename a Context '''9d73d3bd-1873-490c-b0a7-e3c0da11ad52''' (was '''devVRE''') to the new name '''devNext'''. | ||
Line 210: | Line 212: | ||
</pre> | </pre> | ||
− | === Move === | + | ==== Move === |
<pre>POST /resource-registry/context/move/d821bcc0-946b-11e6-bdf4-800200c9a66[?parentContextId=a2fe0030-7b3d-4617-ba37-532c0e4b778d</pre> | <pre>POST /resource-registry/context/move/d821bcc0-946b-11e6-bdf4-800200c9a66[?parentContextId=a2fe0030-7b3d-4617-ba37-532c0e4b778d</pre> | ||
− | === Delete === | + | ==== Delete === |
<pre>DELETE /resource-registry/context/d821bcc0-946b-11e6-bdf4-0800200c9a66</pre> | <pre>DELETE /resource-registry/context/d821bcc0-946b-11e6-bdf4-0800200c9a66</pre> | ||
− | == Schema Management == | + | === Schema Management == |
At time of writing this port type is only accessible by using REST API. | At time of writing this port type is only accessible by using REST API. | ||
A java client is under development. | A java client is under development. | ||
− | === Type Definition === | + | ==== Type Definition === |
Any Type is described by the following attributes: | Any Type is described by the following attributes: | ||
Line 233: | Line 235: | ||
* Zero o more [[Facet_Based_Resource_Model#Property | Properties]] | * Zero o more [[Facet_Based_Resource_Model#Property | Properties]] | ||
− | ==== Property ==== | + | ===== Property ==== |
Any [[Facet_Based_Resource_Model#Property | Property]] is described by the following attributes: | Any [[Facet_Based_Resource_Model#Property | Property]] is described by the following attributes: | ||
Line 247: | Line 249: | ||
* '''regexpr''' : A [https://en.wikipedia.org/wiki/Regular_expression Regular Expression] to validate the property value, <code>default=null</code>. A good online tool for regex is avalable at [https://regex101.com/ https://regex101.com/] | * '''regexpr''' : A [https://en.wikipedia.org/wiki/Regular_expression Regular Expression] to validate the property value, <code>default=null</code>. A good online tool for regex is avalable at [https://regex101.com/ https://regex101.com/] | ||
− | ===== Property Type Mapping ===== | + | ====== Property Type Mapping ===== |
[[Facet_Based_Resource_Model#Basic_Property_Type | Property Type]] are mapped to and integer to be used in property definition: | [[Facet_Based_Resource_Model#Basic_Property_Type | Property Type]] are mapped to and integer to be used in property definition: | ||
Line 331: | Line 333: | ||
|} | |} | ||
− | === Resource Type Creation === | + | ==== Resource Type Creation === |
<pre> | <pre> | ||
Line 348: | Line 350: | ||
</pre> | </pre> | ||
− | === Facet Type Creation === | + | ==== Facet Type Creation === |
<pre> | <pre> | ||
Line 391: | Line 393: | ||
</pre> | </pre> | ||
− | === IsRelatedTo Type Creation === | + | ==== IsRelatedTo Type Creation === |
<pre> | <pre> | ||
PUT /resource-registry/schema/IsRelatedTo | PUT /resource-registry/schema/IsRelatedTo | ||
Line 407: | Line 409: | ||
</pre> | </pre> | ||
− | === ConsistsOf Type Creation === | + | ==== ConsistsOf Type Creation === |
<pre> | <pre> | ||
Line 424: | Line 426: | ||
</pre> | </pre> | ||
− | === Embedded Type Creation === | + | ==== Embedded Type Creation === |
<pre> | <pre> | ||
PUT /resource-registry/schema/Embedded | PUT /resource-registry/schema/Embedded | ||
Line 464: | Line 466: | ||
</pre> | </pre> | ||
− | == ER Management == | + | === ER Management === |
Apart the REST API this port type can be used also by using a Java client | Apart the REST API this port type can be used also by using a Java client | ||
Line 485: | Line 487: | ||
− | === Facet Instances APIs === | + | ==== Facet Instances APIs === |
− | ==== Create Facet Instance ==== | + | ===== Create Facet Instance ==== |
− | ===== REST API ===== | + | ====== REST API ===== |
<pre> | <pre> | ||
PUT /resource-registry/er/facet/CPUFacet | PUT /resource-registry/er/facet/CPUFacet | ||
Line 517: | Line 519: | ||
</pre> | </pre> | ||
− | ===== Java API ===== | + | ====== Java API ===== |
<pre> | <pre> | ||
CPUFacet cpuFacet = new CPUFacetImpl(); | CPUFacet cpuFacet = new CPUFacetImpl(); | ||
Line 528: | Line 530: | ||
</pre> | </pre> | ||
− | ==== Update Facet Instance ==== | + | ===== Update Facet Instance ==== |
− | ===== REST API ===== | + | ====== REST API ===== |
<pre> | <pre> | ||
POST /resource-registry/er/facet/69f0b376-38d2-4a85-bc63-37f9fa323f82 | POST /resource-registry/er/facet/69f0b376-38d2-4a85-bc63-37f9fa323f82 | ||
Line 558: | Line 560: | ||
</pre> | </pre> | ||
− | ===== Java API ===== | + | ====== Java API ===== |
<pre> | <pre> | ||
createdCpuFacet.setClockSpeed("2 GHz"); | createdCpuFacet.setClockSpeed("2 GHz"); | ||
Line 564: | Line 566: | ||
</pre> | </pre> | ||
− | ==== Delete Facet Instance ==== | + | ===== Delete Facet Instance ==== |
− | ===== REST API ===== | + | ====== REST API ===== |
<pre> | <pre> | ||
DELETE /resource-registry/er/facet/69f0b376-38d2-4a85-bc63-37f9fa323f82 | DELETE /resource-registry/er/facet/69f0b376-38d2-4a85-bc63-37f9fa323f82 | ||
Line 576: | Line 578: | ||
</pre> | </pre> | ||
− | ===== Java API ===== | + | ====== Java API ===== |
<pre> | <pre> | ||
boolean deleted = resourceRegistryPublisher.deleteFacet(createdCpuFacet); | boolean deleted = resourceRegistryPublisher.deleteFacet(createdCpuFacet); | ||
</pre> | </pre> | ||
− | === Resource Instances APIs === | + | ==== Resource Instances APIs === |
− | ==== Create Resource Instance ==== | + | ===== Create Resource Instance ==== |
− | ===== REST API ===== | + | ====== REST API ===== |
<pre> | <pre> | ||
PUT /resource-registry/er/resource/HostingNode | PUT /resource-registry/er/resource/HostingNode | ||
Line 677: | Line 679: | ||
</pre> | </pre> | ||
− | ===== Java API ===== | + | ====== Java API ===== |
<pre> | <pre> | ||
NetworkingFacet networkingFacet = new NetworkingFacetImpl(); | NetworkingFacet networkingFacet = new NetworkingFacetImpl(); | ||
Line 709: | Line 711: | ||
</pre> | </pre> | ||
− | ==== Update Resource Instance ==== | + | ===== Update Resource Instance ==== |
− | ===== REST API ===== | + | ====== REST API ===== |
<pre> | <pre> | ||
POST /resource-registry/er/resource/670eeabf-76c7-493f-a449-4e6e139a2e84 | POST /resource-registry/er/resource/670eeabf-76c7-493f-a449-4e6e139a2e84 | ||
Line 784: | Line 786: | ||
</pre> | </pre> | ||
− | ===== Java API ===== | + | ====== Java API ===== |
<pre> | <pre> | ||
Line 795: | Line 797: | ||
</pre> | </pre> | ||
− | ==== Delete Resource Instance ==== | + | ===== Delete Resource Instance ==== |
− | ===== REST API ===== | + | ====== REST API ===== |
<pre> | <pre> | ||
DELETE /resource-registry/er/resource/670eeabf-76c7-493f-a449-4e6e139a2e84 | DELETE /resource-registry/er/resource/670eeabf-76c7-493f-a449-4e6e139a2e84 | ||
</pre> | </pre> | ||
− | ===== Java API ===== | + | ====== Java API ===== |
<pre> | <pre> | ||
boolean deleted = resourceRegistryPublisher.deleteResource(hostingNode); | boolean deleted = resourceRegistryPublisher.deleteResource(hostingNode); | ||
</pre> | </pre> | ||
− | === Relation Instances APIs === | + | ==== Relation Instances APIs === |
<pre> | <pre> | ||
</pre> | </pre> | ||
− | == Query & Access == | + | === Query & Access === |
− | === Exists === | + | ==== Exists === |
<pre>HEAD /resource-registry/access/instance/{ER-Type}/{INSTANCE UUID}</pre> | <pre>HEAD /resource-registry/access/instance/{ER-Type}/{INSTANCE UUID}</pre> | ||
Line 824: | Line 826: | ||
− | === Get Instance === | + | ==== Get Instance === |
<pre>GET /resource-registry/access/instance/{ER-Type}/{INSTANCE UUID}</pre> | <pre>GET /resource-registry/access/instance/{ER-Type}/{INSTANCE UUID}</pre> | ||
Line 834: | Line 836: | ||
− | === Get All Instances of a Specific Type === | + | ==== Get All Instances of a Specific Type === |
<pre>GET /resource-registry/access/instances/{ER-Type}?[polymorphic=(true|false)][&reference={INSTANCE UUID}][&direction=(in|out|both)]</pre> | <pre>GET /resource-registry/access/instances/{ER-Type}?[polymorphic=(true|false)][&reference={INSTANCE UUID}][&direction=(in|out|both)]</pre> | ||
Line 850: | Line 852: | ||
− | === Raw Query === | + | ==== Raw Query === |
<pre>GET /resource-registry/access?query=SELECT FROM Facet</pre> | <pre>GET /resource-registry/access?query=SELECT FROM Facet</pre> |
Revision as of 10:43, 3 November 2017
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
- ER Management : manage instances of registered Entity and Relation type
- Query & Access : query instances and get the schema definition of registered types
Every Port type is exposed as REST API.
Port Types
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:
Any action made to Contexts succeed if the following requirements are guaranteed:
- Two Context with same name can exist but only if they have different parents. The operation which will try to obtain a Context with the same name to the same parent will fails with no effect.
- Any operation made in any Context has effect only to the Context. In other words, there will be no effect on the associated Entity and Relations.
= Create
PUT /resource-registry/context
= Description
Create new Context as child of another Context (if any).
= 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 | The json representation of the context. |
= Examples
Create a new Context with name gcube with no parent. It is a ROOT Context.
Request URL
PUT /resource-registry/context?name=gcube
Response Body
{ "@class":"Context", "header": { "@class":"Header", "uuid":"2705dd32-c857-444b-818a-3ec69e339e5d", "creator":"luca.frosini", "creationTime":"2017-03-17 11:47:55", "lastUpdateTime":"2017-03-17 11:47:55" }, "name":"gCube" }
Create a new Context with name devsec as child of Context with UUID 2705dd32-c857-444b-818a-3ec69e339e5d (gcube)
Request URL
/resource-registry/context?name=devsec&parentContextId=2705dd32-c857-444b-818a-3ec69e339e5d
Response Body
{ "@class":"Context", "header": { "@class":"Header", "uuid":"30f6254c-c87a-451e-bc0f-7cfcbd94a84a", "creator":"luca.frosini", "creationTime":"2017-03-17 11:47:56", "lastUpdateTime":"2017-03-17 11:47:56" } "name":"devsec" }
Create a new Context with name devVRE as child of Context with UUID 30f6254c-c87a-451e-bc0f-7cfcbd94a84a (devsec)
Request URL
/resource-registry/context?name=devVRE&parentContextId=30f6254c-c87a-451e-bc0f-7cfcbd94a84a
Response Body
{ "@class":"Context", "header": { "@class":"Header", "uuid":"9d73d3bd-1873-490c-b0a7-e3c0da11ad52", "creator":"luca.frosini", "creationTime":"2017-03-17 11:47:57", "lastUpdateTime":"2017-03-17 11:47:57" } "name":"devVRE" }
= Rename
POST /resource-registry/context/rename/{UUID}
= Description
Rename a Context identified by the UUID provided as path parameter to the new name provided as query parameter.
= Parameters
Name | Type | Required | Description |
---|---|---|---|
{Path Paramenter} | String (UUID) | true | The UUID of the target context. |
name | String | true | The new name of the target context. |
= Responses
Code | Type | Description |
---|---|---|
200 | String | The json representation of the context. |
= Examples
Rename a Context 9d73d3bd-1873-490c-b0a7-e3c0da11ad52 (was devVRE) to the new name devNext.
Request URL
POST /resource-registry/context/rename/9d73d3bd-1873-490c-b0a7-e3c0da11ad52?name=devNext
Response Body
{ "@class":"Context", "header": { "@class":"Header", "uuid":"9d73d3bd-1873-490c-b0a7-e3c0da11ad52", "creator":"luca.frosini", "creationTime":"2017-03-17 11:47:56", "lastUpdateTime":"2017-03-17 11:52:56" } "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
At time of writing this port type is only accessible by using REST API. A java client is under development.
= Type Definition
Any Type is described by the following attributes:
- name (String): Type Name
- description (String): The description of the Type.
default=null
. - abstractType (Boolean): Indicate if the type is abstract so that it cannot be instatiated. In other words only subtypes of this type can be isntantiated.
default=false
. - superclasses (List<String>): The list of all supertypes of this type. Multiple Inheritance is supported.
- Zero o more Properties
= Property
Any Property is described by the following attributes:
- name : Property Name
- type : The Type of the Property (e.g. String, Integer, ...). See Property Type
- description : The description of the Property.
default=null
. - mandatory : Indicate if the Property is mandatory.
default=false
. - readOnly : The Property cannot change its value.
default=false
. - notNull : Whether the property must assume a value diverse from 'null' or not.
default=false
- max :
default=null
- min :
default=null
- regexpr : A Regular Expression to validate the property value,
default=null
. A good online tool for regex is avalable at https://regex101.com/
= Property Type Mapping
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
Request Body
{ "name":"Actor", "description":"Any entity (human or machine) playing an active role.", "abstractType":true, /* If the Resource cannot be instantiated */ "superclasses":["Resource"], /* Resource or any registered specialization. */ "properties":null /* MUST be null. The Resource cannot have any property. */ }
= Facet Type Creation
PUT /resource-registry/schema/Facet
Request Body
{ "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
Request Body
{ "name":"Hosts", "description": "…”, "abstractType":false, "superclasses":["IsRelatedTo"], "properties":[] }
= ConsistsOf Type Creation
PUT /resource-registry/schema/ConsistsOf
Request Body
{ "name":"HasContact", "description":"", "abstractType":true, "superclasses":["ConsistsOf"], "properties":[] }
= Embedded Type Creation
PUT /resource-registry/schema/Embedded
Request Body
{ "name":"AccessPolicy", "description":"", "abstractType":false, "superclasses":["Embedded"], "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 */ }] }
ER 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/er/facet/CPUFacet
Request Body
{ "@class":"CPUFacet", "header":null, "model":"Opteron", "vendor":"AMD", "clockSpeed":"1 GHz" }
Response Body
{ "@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); UUID uuid = createdCpuFacet.getHeader().getUUID(); // 69f0b376-38d2-4a85-bc63-37f9fa323f82
= Update Facet Instance
= REST API
POST /resource-registry/er/facet/69f0b376-38d2-4a85-bc63-37f9fa323f82
Request Body
{ "@class":"CPUFacet", "header":{"uuid":"69f0b376-38d2-4a85-bc63-37f9fa323f82"}, /* if you pass the header only the UUID is checked and must be the same of the one provided in the URL*/ "model":"Opteron", "vendor":"AMD", "clockSpeed":"2 GHz" }
Response Body
{ "@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/er/facet/69f0b376-38d2-4a85-bc63-37f9fa323f82
Response Body
true
= Java API
boolean deleted = resourceRegistryPublisher.deleteFacet(createdCpuFacet);
= Resource Instances APIs
= Create Resource Instance
= REST API
PUT /resource-registry/er/resource/HostingNode
Request Body
{ "@class":"HostingNode", "consistsOf":[ { "@class":"ConsistsOf", "target":{ "@class":"CPUFacet", "model":"Opteron", "vendor":"AMD", "clockSpeed":"3 GHz" } },{ "@class":"IsIdentifiedBy", "target":{ "@class":"NetworkingFacet", "header":{"uuid":"59617b01-5856-4d8e-b85c-590a42039933"}, /* In this example we suppose that the NetworkingFacet was already created, so the UUID is enought to attach it by using IsIdentifiedBy relation */ } } ], "isRelatedTo":[ { "@class":"Hosts", "propagationConstraint":{ "add":"unpropagate", "remove": "cascade" }, "target":{ "@class":"EService", "header":{"uuid":"9bff49c8-c0a7-45de-827c-accb71defbd3"} /* The EService was already created, so the UUID is enought to attach it by using Hosts relation */ } } ] }
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", ...}, "ipAddress" : "146.48.87.183", "hostName": "pc-frosini.isti.cnr.it", "domainName" : "isti.cnr.it", "mask" : "255.255.248.0", "broadcastAddress":"146.48.87.255" } } ], "isRelatedTo":[ { "@class":"Hosts", "header":{"uuid":"47494ad0-e606-4630-9def-4c607761ae14", ...}, "propagationConstraint":{ "add":"unpropagate", "remove": "cascade" }, "target":{ "@class":"EService", "header":{"uuid":"9bff49c8-c0a7-45de-827c-accb71defbd3", ...} } } ] }
= Java API
NetworkingFacet networkingFacet = new NetworkingFacetImpl(); networkingFacet.setIPAddress("146.48.87.183"); networkingFacet.setHostName("pc-frosini.isti.cnr.it"); networkingFacet.setDomainName("isti.cnr.it"); networkingFacet.setMask("255.255.248.0"); networkingFacet.setBroadcastAddress("146.48.87.255"); networkingFacet = resourceRegistryPublisher.createFacet(NetworkingFacet.class, networkingFacet); HostingNode hostingNode = new HostingNodeImpl(); CPUFacet cpuFacet = new CPUFacetImpl(); cpuFacet.setClockSpeed("1 GHz"); cpuFacet.setModel("Opteron"); cpuFacet.setVendor("AMD"); hostingNode.addFacet(cpuFacet); isIdentifiedBy = new IsIdentifiedByImpl<Resource, Facet>(hostingNode, networkingFacet, null); hostingNode.attachFacet(isIdentifiedBy); PropagationConstraint propagationConstraint = new PropagationConstraintImpl(); propagationConstraint.setRemoveConstraint(RemoveConstraint.cascade); propagationConstraint.setAddConstraint(AddConstraint.unpropagate); Hosts<HostingNode, EService> hosts = new HostsImpl<HostingNode, EService>(hostingNode, eService, propagationConstraint); hostingNode.attachResource(hosts); hostingNode = resourceRegistryPublisher.createResource(HostingNode.class, hostingNode);
= Update Resource Instance
= REST API
POST /resource-registry/er/resource/670eeabf-76c7-493f-a449-4e6e139a2e84
Request Body
{ "@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", ...}, "ipAddress" : "146.48.87.183", "hostName": "pc-frosini.isti.cnr.it", "domainName" : "isti.cnr.it", "mask" : "255.255.248.0", "broadcastAddress":"146.48.87.255", "username":"luca.frosini" /* Added this property */ } } ] }
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", ...}, "ipAddress" : "146.48.87.183", "hostName": "pc-frosini.isti.cnr.it", "domainName" : "isti.cnr.it", "mask" : "255.255.248.0", "broadcastAddress":"146.48.87.255", "username":"luca.frosini" } } ] }
= Java API
/* This is just a code example, here we suppose that there is only one identification Facet of the type (NetworkingFacet). This could not be true in real scenario*/ networkingFacet = (NetworkingFacet) hostingNode.getIdentificationFacets().get(0); networkingFacet.setAdditionalProperty("username", "luca.frosini"); hostingNode = resourceRegistryPublisher.updateResource(HostingNode.class, hostingNode);
= Delete Resource Instance
= REST API
DELETE /resource-registry/er/resource/670eeabf-76c7-493f-a449-4e6e139a2e84
= Java API
boolean deleted = resourceRegistryPublisher.deleteResource(hostingNode);
= Relation Instances APIs
Query & Access
= Exists
HEAD /resource-registry/access/instance/{ER-Type}/{INSTANCE UUID}
Example
HEAD /resource-registry/access/instance/ContactFacet/4d28077b-566d-4132-b073-f4edaf61dcb9
= Get Instance
GET /resource-registry/access/instance/{ER-Type}/{INSTANCE UUID}
Example
GET /resource-registry/access/instance/ContactFacet/4d28077b-566d-4132-b073-f4edaf61dcb9
= Get All Instances of a Specific Type
GET /resource-registry/access/instances/{ER-Type}?[polymorphic=(true|false)][&reference={INSTANCE UUID}][&direction=(in|out|both)]
Default:
* polymorphic : false * direction : both
direction has sense only if reference UUID is provided, is ignored otherwise.
GET /resource-registry/access/instances/EService?polymorphic=true
GET /resource-registry/access/instances/EService?polymorphic=true&reference=4d28077b-566d-4132-b073-f4edaf61dcb9&direction=(in|out|both)
= Raw Query
GET /resource-registry/access?query=SELECT FROM Facet