Difference between revisions of "Resource Registry Service - Instances Management"

From Gcube Wiki
Jump to: navigation, search
(REST API)
Line 32: Line 32:
  
  
=== 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 69: Line 69:
 
</pre>
 
</pre>
  
===== Java API =====
+
==== Java API =====
  
 
<pre>
 
<pre>
Line 75: Line 75:
 
</pre>
 
</pre>
  
====== Example ======
+
===== Example ======
 
<pre>
 
<pre>
 
CPUFacet cpuFacet = new CPUFacetImpl();
 
CPUFacet cpuFacet = new CPUFacetImpl();
Line 99: Line 99:
 
The second method is more efficient but you have to be sure that the '''facetType''' is the same specified in the header of the serialized facet.
 
The second method is more efficient but you have to be sure that the '''facetType''' is the same specified in the header of the serialized facet.
  
==== 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 134: Line 134:
 
</pre>
 
</pre>
  
===== Java API =====
+
==== Java API =====
  
 
<pre>
 
<pre>
Line 140: Line 140:
 
</pre>
 
</pre>
  
====== Example ======
+
===== Example ======
  
 
<pre>
 
<pre>
Line 158: Line 158:
 
The second method is more efficient but you have to be sure that the provided '''uuid''' is the same specified in the header of the serialized facet.
 
The second method is more efficient but you have to be sure that the provided '''uuid''' is the same specified in the header of the serialized facet.
  
==== 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 170: Line 170:
 
</pre>
 
</pre>
  
===== Java API =====
+
==== Java API =====
  
 
<pre>
 
<pre>
Line 176: Line 176:
 
</pre>
 
</pre>
  
====== Example ======
+
===== Example ======
  
 
<pre>
 
<pre>
Line 190: Line 190:
 
The method just need the UUID of the Facet to be deleted.
 
The method just need the UUID of the Facet to be deleted.
  
=== 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 286: Line 286:
 
</pre>
 
</pre>
  
===== Java API =====
+
==== Java API =====
  
 
<pre>
 
<pre>
Line 292: Line 292:
 
</pre>
 
</pre>
  
====== Example ======
+
===== Example ======
  
 
<pre>
 
<pre>
Line 338: Line 338:
 
The second method is more efficient but you have to be sure that the '''resourceType''' is the same specified in the header of the serialized resource.
 
The second method is more efficient but you have to be sure that the '''resourceType''' is the same specified in the header of the serialized resource.
  
==== 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 413: Line 413:
 
</pre>
 
</pre>
  
===== Java API =====
+
==== Java API =====
 
<pre>
 
<pre>
 
public <R extends Resource> R updateResource(R resource) throws ResourceNotFoundException, ResourceRegistryException;
 
public <R extends Resource> R updateResource(R resource) throws ResourceNotFoundException, ResourceRegistryException;
 
</pre>
 
</pre>
  
====== Example ======
+
===== Example ======
  
 
<pre>
 
<pre>
Line 440: Line 440:
 
The second method is more efficient but you have to be sure that the '''uuid''' is the same specified in the header of the serialized resource.
 
The second method is more efficient but you have to be sure that the '''uuid''' is the same specified in the header of the serialized resource.
  
==== 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>
 
public <R extends Resource> boolean deleteResource(R resource) throws ResourceNotFoundException, ResourceRegistryException;
 
public <R extends Resource> boolean deleteResource(R resource) throws ResourceNotFoundException, ResourceRegistryException;
 
</pre>
 
</pre>
  
====== Example ======
+
===== Example ======
  
 
<pre>
 
<pre>
Line 466: Line 466:
 
The method just need the UUID of the Resource to be deleted.
 
The method just need the UUID of the Resource to be deleted.
  
=== Relation Instances APIs ===
+
== Relation Instances APIs ===
==== ConsistsOf ====
+
=== ConsistsOf ====
  
===== Create ConsistsOf Instance =====
+
==== Create ConsistsOf Instance =====
  
====== REST API ======
+
===== REST API ======
  
 
'''Example 1'''
 
'''Example 1'''
Line 569: Line 569:
 
</pre>
 
</pre>
  
====== Java API ======
+
===== Java API ======
  
 
<pre>
 
<pre>
Line 611: Line 611:
 
The second method is more efficient but you have to be sure that the '''consistsOfType''' is the same specified in the header of the serialized resource.
 
The second method is more efficient but you have to be sure that the '''consistsOfType''' is the same specified in the header of the serialized resource.
  
===== Delete ConsistsOf Instance =====
+
==== Delete ConsistsOf Instance =====
  
====== REST API ======
+
===== REST API ======
  
 
'''Example 1'''
 
'''Example 1'''
Line 625: Line 625:
 
</pre>
 
</pre>
  
====== Java API ======
+
===== Java API ======
 
<pre>
 
<pre>
 
public <C extends ConsistsOf<? extends Resource, ? extends Facet>> boolean deleteConsistsOf(C consistsOf) throws ResourceRegistryException;
 
public <C extends ConsistsOf<? extends Resource, ? extends Facet>> boolean deleteConsistsOf(C consistsOf) throws ResourceRegistryException;

Revision as of 19:25, 8 November 2017

This sections provide information regarding how to interact with Resource Registry Service for Entities and Relations Management. REST and JAVA API are presented for each functionality.

Please note that the provided examples can intentionally hide some details in the response to avoid unneeded complexity.

Apart the REST API this port type can be used also by using Resource Registry Publisher java client.


Resource Registry Publisher has the following maven coordinates

<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 ResourceRegistryPublisherFactory.create() method the library discover the correct endpoint to interact with the Resource Registry 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",
	"header": {
		"uuid":"69f0b376-38d2-4a85-bc63-37f9fa323f82",
		"creator":"luca.frosini",
		"lastUpdater":"luca.frosini",
		"creationTime":"2016-10-05 11:16:24",
		"lastUpdateTime":"2016-10-05 11:16:24
	},
	"model":"Opteron",
	"vendor":"AMD",
	"clockSpeed":"1 GHz"
}

Java API =

public <F extends Facet> F createFacet(F facet) throws FacetAlreadyPresentException, ResourceRegistryException;
Example =
CPUFacet cpuFacet = new CPUFacetImpl();
cpuFacet.setClockSpeed("1 GHz");
cpuFacet.setModel("Opteron");
cpuFacet.setVendor("AMD");

CPUFacet createdCpuFacet = resourceRegistryPublisher.createFacet(cpuFacet);
UUID uuid = createdCpuFacet.getHeader().getUUID(); // 69f0b376-38d2-4a85-bc63-37f9fa323f82


There are also two other equivalent methods with the following signature:

public String createFacet(String facet) throws FacetAlreadyPresentException, ResourceRegistryException;

public String createFacet(String facetType, String facet) throws FacetAlreadyPresentException, ResourceRegistryException;

The first methods get the Facet to be created as JSON string instead of as Java class. The second get also the facetType as parameter (which as to be specified as PATH PARAMETER in the request) avoiding to force client to retrieve it from the string. The second method is more efficient but you have to be sure that the facetType is the same specified in the header of the serialized facet.

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",
	"header": {
		"uuid":"69f0b376-38d2-4a85-bc63-37f9fa323f82",
		"creator":"luca.frosini", 
		"lastUpdater":"luca.frosini", 
		"creationTime":"2016-10-05 11:16:24",
		"lastUpdateTime":"2016-10-05 11:17:32"
	},
	"model":"Opteron",
	"vendor":"AMD",
	"clockSpeed":"2 GHz"
}

Java API =

public <F extends Facet> F updateFacet(F facet) throws FacetNotFoundException, ResourceRegistryException;
Example =
createdCpuFacet.setClockSpeed("2 GHz");
CPUFacet updatedCpuFacet = resourceRegistryPublisher.updateFacet(createdCpuFacet);

There are also two other equivalent methods with the following signature:

public String updateFacet(String facet) throws FacetNotFoundException, ResourceRegistryException;
public String updateFacet(UUID uuid, String facet) throws FacetNotFoundException, ResourceRegistryException;

The first methods get the Facet to be created as JSON string instead of as Java class. The second get also the uuid as parameter (which as to be specified as PATH PARAMETER in the request) avoiding to force client to retrieve it from the string. The second method is more efficient but you have to be sure that the provided uuid is the same specified in the header of the serialized facet.

Delete Facet Instance =

REST API =

DELETE /resource-registry/er/facet/69f0b376-38d2-4a85-bc63-37f9fa323f82

Response Body

true

Java API =

public <F extends Facet> boolean deleteFacet(F facet) throws FacetNotFoundException, ResourceRegistryException;
Example =
boolean deleted = resourceRegistryPublisher.deleteFacet(createdCpuFacet);

There is also another equivalent methods with the following signature:

public boolean deleteFacet(UUID uuid) throws FacetNotFoundException, ResourceRegistryException;

The method just need the UUID of the Facet to be deleted.

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 =

public <R extends Resource> R createResource(R resource) throws ResourceAlreadyPresentException, ResourceRegistryException;
Example =
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);

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);


There are also two other equivalent methods with the following signature:

public String createResource(String resource) throws ResourceAlreadyPresentException, ResourceRegistryException;

public String createResource(String resourceType, String resource) throws ResourceAlreadyPresentException, ResourceRegistryException;

The first methods get the Resource to be created as JSON string instead of as Java class. The second get also the resourceType as parameter (which as to be specified as PATH PARAMETER in the request) avoiding to force client to retrieve it from the string. The second method is more efficient but you have to be sure that the resourceType is the same specified in the header of the serialized resource.

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 =

public <R extends Resource> R updateResource(R resource) throws ResourceNotFoundException, ResourceRegistryException;
Example =

/* 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);

There are also two other equivalent methods with the following signature:

public String updateResource(String resource) throws ResourceNotFoundException, ResourceRegistryException;
public String updateResource(UUID uuid, String resource) throws ResourceNotFoundException, ResourceRegistryException;

The first methods get the Resource to be created as JSON string instead of as Java class. The second get also the uuid as parameter (which as to be specified as PATH PARAMETER in the request) avoiding to force client to retrieve it from the string. The second method is more efficient but you have to be sure that the uuid is the same specified in the header of the serialized resource.

Delete Resource Instance =

REST API =

DELETE /resource-registry/er/resource/670eeabf-76c7-493f-a449-4e6e139a2e84

Java API =

public <R extends Resource> boolean deleteResource(R resource) throws ResourceNotFoundException, ResourceRegistryException;
Example =
boolean deleted = resourceRegistryPublisher.deleteResource(hostingNode);

There is also another equivalent methods with the following signature:

public boolean deleteResource(UUID uuid) throws ResourceNotFoundException, ResourceRegistryException;

The method just need the UUID of the Resource to be deleted.

Relation Instances APIs =

ConsistsOf =

Create ConsistsOf Instance =

REST API =

Example 1

PUT /resource-registry/er/consistsOf/IsIdentifiedBy

In this example the target Facet already exists. The Service set automatically the Facet_Based_Resource_Model#PropagationConstraint Propagation Constraint to default values (i.e. remove=cascadeWhenOrphan, add=propagate)

Request Body

{
	"@class":"IsIdentifiedBy", 
	"source" : {
		"@class":"HostingNode",
		"header":{"uuid":"670eeabf-76c7-493f-a449-4e6e139a2e84"} // The HostingNode must be already created. The header with UUId is enough.
	}
	"target":{ 
		"@class":"NetworkingFacet",
		"header":{"uuid":"59617b01-5856-4d8e-b85c-590a42039933"}, 
		/* In this example we suppose that the NetworkingFacet already exists, so the UUID is enought to attach it by using IsIdentifiedBy relation */
	}
}

Response

{
	"@class":"IsIdentifiedBy",
	"propagationConstraint":{
		"add":"propagate",
		"remove": "cascadeWhenOrphan"
	},
	"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"
	}
}

Example 2

PUT /resource-registry/er/consistsOf/ConsistsOf

In this example the target Facet is created contestually with ConsistsOf relation. Moreover the Facet_Based_Resource_Model#PropagationConstraint Propagation Constraint are explicitly set (i.e. remove=cascade, add=propagate).

Request Body

{
	"@class":"ConsistsOf", 
	"propagationConstraint":{
		"add":"propagate",
		"remove": "cascade"
	},
	"source" : {
		"@class":"HostingNode",
		"header":{"uuid":"670eeabf-76c7-493f-a449-4e6e139a2e84"} // The HostingNode must be already created. The header with UUId is enough.
	}
	"target":{ 
		"@class":"CPUFacet",
		"model":"Opteron",
		"vendor":"AMD",
		"clockSpeed":"3 GHz"
	}
}

Response

{
	"@class":"ConsistsOf",
	"header":{"uuid":"9bff49c8-c0a7-45de-827c-accb71defbd3", ...},
	"propagationConstraint":{
		"add":"propagate",
		"remove": "cascade"
	},
	"target":{ 
		"@class":"CPUFacet",
		"header":{"uuid":"1daef6a8-5ca4-4700-844b-2a2d784e17b0", ...},
		"model":"Opteron",
		"vendor":"AMD",
		"clockSpeed":"1 GHz"
	}
}
Java API =
public <C extends ConsistsOf<? extends Resource, ? extends Facet>> C createConsistsOf(C consistsOf) throws FacetNotFoundException, ResourceNotFoundException, ResourceRegistryException;

Example 1

IsIdentifiedBy isIdentifiedBy = new IsIdentifiedByImpl<Resource, Facet>(hostingNode, networkingFacet, null);
resourceRegistryPublisher.createConsistsOf(isIdentifiedBy);

Example 2

CPUFacet cpuFacet = new CPUFacetImpl();
cpuFacet.setClockSpeed("1 GHz");
cpuFacet.setModel("Opteron");
cpuFacet.setVendor("AMD");

PropagationConstraint propagationConstraint = new PropagationConstraintImpl();
propagationConstraint.setRemoveConstraint(RemoveConstraint.cascade);
propagationConstraint.setAddConstraint(AddConstraint.propagate);

ConsistsOf consistsOf = new ConsistsOfImpl<Resource, Facet>(hostingNode, cpuFacet, propagationConstraint);
consistsOf = resourceRegistryPublisher.createConsistsOf(consistsOf);


There are also two other equivalent methods with the following signature:

public String createConsistsOf(String consistsOfType, String cnsistsOf) throws FacetNotFoundException, ResourceNotFoundException, ResourceRegistryException;
	
public String createConsistsOf(String consistsOf) throws FacetNotFoundException, ResourceNotFoundException, ResourceRegistryException;

The first methods get the consistsOfType to be created as JSON string instead of as Java class. The second get also the consistsOfType as parameter (which as to be specified as PATH PARAMETER in the request) avoiding to force client to retrieve it from the string. The second method is more efficient but you have to be sure that the consistsOfType is the same specified in the header of the serialized resource.

Delete ConsistsOf Instance =

REST API =

Example 1

DELETE /resource-registry/er/consistsOf/02a7072c-4f72-4568-945b-9ddccc881e9f

Example 2

DELETE /resource-registry/er/consistsOf/9bff49c8-c0a7-45de-827c-accb71defbd3
Java API =
public <C extends ConsistsOf<? extends Resource, ? extends Facet>> boolean deleteConsistsOf(C consistsOf) throws ResourceRegistryException;

Example 1

boolean deleted = resourceRegistryPublisher.deleteConsistsOf(isIdentifiedBy);

Example 2

boolean deleted = resourceRegistryPublisher.deleteConsistsOf(consistsOf);


There is also another equivalent methods with the following signature:

public boolean deleteConsistsOf(UUID uuid) throws ResourceRegistryException;

The method just need the UUID of the ConsistsOf relation to be deleted.

Example 1

UUID uuid = UUID.fromString("02a7072c-4f72-4568-945b-9ddccc881e9f")
boolean deleted = resourceRegistryPublisher.deleteConsistsOf(uuid);

Example 2

UUID uuid = UUID.fromString("9bff49c8-c0a7-45de-827c-accb71defbd3")
boolean deleted = resourceRegistryPublisher.deleteConsistsOf(uuid);