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

From Gcube Wiki
Jump to: navigation, search
m (Instances Sharing Collection)
m (Instances Sharing Add To Context Example)
Line 55: Line 55:
  
 
<pre>
 
<pre>
POST /sharing/contexts/aa860961-6eb0-4c1c-89fb-c406fe2a2771/EService/7f37a79d-0c00-4166-8a68-165de0a438bf?operation=ADD&dryRun=true
+
POST /sharing/contexts/aa860961-6eb0-4c1c-89fb-c406fe2a2771/EService/7f37a79d-0c00-4166-8a68-165de0a438bf?operation=ADD
 
</pre>
 
</pre>
  
Line 265: Line 265:
  
 
As we can notice every instance has been enumerated individually.
 
As we can notice every instance has been enumerated individually.
 
  
 
==== Instances Sharing Add To Context Proof ====
 
==== Instances Sharing Add To Context Proof ====

Revision as of 11:28, 6 July 2021

These sections provide information regarding how to interact with Resource Registry Service for Entities and Relations instances sharing between Contexts. 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.

Instances Sharing Management

Instances Sharing Management is responsible for sharing between Contexts. It offers the following APIs:

  • Add To Context: it allows add an instance to a context;
  • Remove From Context: it allows to remove an instance from a context (the Resource Registry deletes the instance when it is available only in the removing context).


The Instances Sharing Management implements the following policies:

  • it manages the Header automatically;
  • it validates the instance against the schema of the defined type;
  • it guarantees propagation constraints.

When the resource registry receives a request to add a resource instance to a context (or remove from a context), it applies the propagation constraints defined in the outcoming relations. This behaviour can have a "cascade impact" because also the target resource will be added (removed) and so forth.

Any request to add an instance to context has a source context which means that the resource registry analysed only the propagation constraint of the relations belonging to the source contexts. Hence, sharing an instance from context C1 to context C3 can have a different result than sharing the same instance from the context C2 to the context C3.


Instances Sharing Collection

The following table shows the exposed APIs as REST Collection

Operation HTTP Method URL
Add Instance To Context POST /sharing/contexts/{CONTEXT_UUID}/{TYPE_NAME}/{INSTANCE_UUID}?operation=ADD[&dryRun=false]
Remove Instance From Context POST /sharing/contexts/{CONTEXT_UUID}/{TYPE_NAME}/{INSTANCE_UUID}?operation=REMOVE[&dryRun=false]

Each operation returns the list of affected instances (both entities and relations)

The service offers the capability of simulating the operation specifying true to dryRun query parameter. This is possible thanks to the returned list of affected instances even in dryRun mode.

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 types rather than Resource Manager.

Instances Sharing Add To Context Example

To add to the context devNext (UUID=aa860961-6eb0-4c1c-89fb-c406fe2a2771) the EService with UUID 7f37a79d-0c00-4166-8a68-165de0a438bf we need to invoke the following APIs

POST /sharing/contexts/aa860961-6eb0-4c1c-89fb-c406fe2a2771/EService/7f37a79d-0c00-4166-8a68-165de0a438bf?operation=ADD

The response is:

[
    {
        "date": "2021-06-30 16:38:26.464 +0200",
        "header": {
            "@class": "Header",
            "creationTime": "2021-07-01 08:51:02.346 +0200",
            "createdBy": "luca.frosini",
            "uuid": "6142d408-f43c-4db7-851f-1dfeb4d98b99",
            "lastUpdateBy": "luca.frosini",
            "lastUpdateTime": "2021-07-01 12:15:57.585 +0200"
        },
        "event": {
            "@class": "ValueSchema",
            "schema": "String",
            "value": "started"
        },
        "@class": "EventFacet",
        "@superClasses": [
            "Facet"
        ]
    },
    {
        "header": {
            "@class": "Header",
            "creationTime": "2021-07-01 08:51:02.341 +0200",
            "createdBy": "luca.frosini",
            "uuid": "d5e73a7f-d85b-437b-ab2e-64c94061c5ff",
            "lastUpdateBy": "luca.frosini",
            "lastUpdateTime": "2021-07-01 12:15:57.572 +0200"
        },
        "propagationConstraint": {
            "@class": "PropagationConstraint",
            "add": "propagate",
            "remove": "cascade"
        },
        "@class": "ConsistsOf",
        "@superClasses": []
    },
    {
        "header": {
            "@class": "Header",
            "creationTime": "2021-07-01 08:51:02.350 +0200",
            "createdBy": "luca.frosini",
            "uuid": "f1a41f5c-42a3-47ec-b289-6811e62a1c94",
            "lastUpdateBy": "luca.frosini",
            "lastUpdateTime": "2021-07-01 12:15:57.602 +0200"
        },
        "propagationConstraint": {
            "@class": "PropagationConstraint",
            "add": "propagate",
            "remove": "cascade"
        },
        "@class": "ConsistsOf",
        "@superClasses": []
    },
    {
        "name": "WhnManager",
        "description": "Web Hosting Node Service",
        "header": {
            "@class": "Header",
            "creationTime": "2021-07-01 08:51:02.298 +0200",
            "createdBy": "luca.frosini",
            "uuid": "97984812-90e6-4eb7-b804-50a9ad3fe4fb",
            "lastUpdateBy": "luca.frosini",
            "lastUpdateTime": "2021-07-01 12:15:57.296 +0200"
        },
        "optional": "false",
        "version": "2.0.0-4.15.0-132431",
        "group": "VREManagement",
        "@class": "SoftwareFacet",
        "@superClasses": [
            "Facet"
        ]
    },
    {
        "header": {
            "@class": "Header",
            "creationTime": "2021-07-01 08:51:02.312 +0200",
            "createdBy": "luca.frosini",
            "uuid": "3b653a72-b182-41d6-bcc5-97e0141f0ceb",
            "lastUpdateBy": "luca.frosini",
            "lastUpdateTime": "2021-07-01 12:15:57.442 +0200"
        },
        "propagationConstraint": {
            "@class": "PropagationConstraint",
            "add": "propagate",
            "remove": "cascade"
        },
        "@class": "IsIdentifiedBy",
        "@superClasses": [
            "ConsistsOf"
        ]
    },
    {
        "header": {
            "@class": "Header",
            "creationTime": "2021-07-01 08:51:02.353 +0200",
            "createdBy": "luca.frosini",
            "uuid": "7f37a79d-0c00-4166-8a68-165de0a438bf",
            "lastUpdateBy": "luca.frosini",
            "lastUpdateTime": "2021-07-01 12:15:57.605 +0200"
        },
        "@class": "EService",
        "@superClasses": [
            "Service",
            "GCubeResource",
            "Resource"
        ]
    },
    {
        "header": {
            "@class": "Header",
            "creationTime": "2021-07-01 08:51:02.332 +0200",
            "createdBy": "luca.frosini",
            "uuid": "d4aec29c-3f18-4464-94ae-5fb77306eb82",
            "lastUpdateBy": "luca.frosini",
            "lastUpdateTime": "2021-07-01 12:15:57.542 +0200"
        },
        "propagationConstraint": {
            "@class": "PropagationConstraint",
            "add": "propagate",
            "remove": "cascade"
        },
        "@class": "ConsistsOf",
        "@superClasses": []
    },
    {
        "header": {
            "@class": "Header",
            "creationTime": "2021-07-01 08:51:02.336 +0200",
            "createdBy": "luca.frosini",
            "uuid": "44abfa06-a78b-4e5a-a0c5-aa8fe7bcbcf9",
            "lastUpdateBy": "luca.frosini",
            "lastUpdateTime": "2021-07-01 12:15:57.555 +0200"
        },
        "value": "started",
        "@class": "StateFacet",try (dryRun) 
        "@superClasses": [
            "Facet"
        ]
    },
    {
        "authorization": {
            "@class": "ValueSchema",
            "type": null,
            "value": "gcube-token"
        },
        "endpoint": "http://pc-frosini.isti.cnr.it:8080/whn-manager/gcube/vremanagement/ws/whnmanager",
        "entryName": "whnmanager",
        "header": {
            "@class": "Header",
            "creationTime": "2021-07-01 08:51:02.318 +0200",
            "createdBy": "luca.frosini",
            "uuid": "f66a9fdf-3d5c-45fd-8437-6fecec463c4c",
            "lastUpdateBy": "luca.frosini",
            "lastUpdateTime": "2021-07-01 12:15:57.502 +0200"
        },
        "@class": "AccessPointFacet",
        "@superClasses": [
            "Facet"
        ]
    },
    {
        "authorization": {
            "@class": "ValueSchema",
            "type": null,
            "value": "gcube-token"
        },
        "endpoint": "http://pc-frosini.isti.cnr.it:8080/whn-manager/gcube/resource",
        "entryName": "WhnManager-remote-management",
        "header": {
            "@class": "Header",
            "creationTime": "2021-07-01 08:51:02.327 +0200",
            "createdBy": "luca.frosini",
            "uuid": "a18eb180-398e-4302-942e-c3d7e55ad4try (dryRun) 96",
            "lastUpdateBy": "luca.frosini",
            "lastUpdateTime": "2021-07-01 12:15:57.534 +0200"
        },
        "@class": "AccessPointFacet",
        "@superClasses": [
            "Facet"
        ]
    },
    {
        "header": {
            "@class": "Header",
            "creationTime": "2021-07-01 08:51:02.322 +0200",
            "createdBy": "luca.frosini",
            "uuid": "5c78bec3-2fa6-46b3-892d-d41bed93e136",
            "lastUpdateBy": "luca.frosini",
            "lastUpdateTime": "2021-07-01 12:15:57.520 +0200"
        },
        "propagationConstraint": {
            "@class": "PropagationConstraint",
            "add": "propagate",
            "remove": "cascade"
        },
        "@class": "ConsistsOf",
        "@superClasses": []
    }
]

As we can notice every instance has been enumerated individually.

Instances Sharing Add To Context Proof

If we read now the EService instance requesting to include the contexts in the header we will have also the added context:

GET /instances/EService/7f37a79d-0c00-4166-8a68-165de0a438bf?includeContextsInHeader=true
{
    "header": {
        "@class": "Header",
        "creationTime": "2021-07-01 08:51:02.353 +0200",
        "createdBy": "luca.frosini",
        "uuid": "7f37a79d-0c00-4166-8a68-165de0a438bf",
        "lastUpdateBy": "luca.frosini",
        "lastUpdateTime": "2021-07-01 12:35:26.334 +0200",
        "contexts": [
            "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
            "aa860961-6eb0-4c1c-89fb-c406fe2a2771"
        ]
    },
    "@class": "EService",
    "@superClasses": [
        "Service",
        "GCubeResource",
        "Resource"
    ],
    "consistsOf": [
        {
            "header": {
                "@class": "Header",
                "creationTime": "2021-07-01 08:51:02.312 +0200",
                "createdBy": "luca.frosini",
                "uuid": "3b653a72-b182-41d6-bcc5-97e0141f0ceb",
                "lastUpdateBy": "luca.frosini",
                "lastUpdateTime": "2021-07-01 12:35:26.281 +0200",
                "contexts": [
                    "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
                    "aa860961-6eb0-4c1c-89fb-c406fe2a2771"
                ]
            },
            "propagationConstraint": {
                "@class": "PropagationConstraint",
                "add": "propagate",
                "remove": "cascade"
            },
            "@class": "IsIdentifiedBy",
            "@superClasses": [
                "ConsistsOf"
            ],
            "source": {
                "header": {
                    "@class": "Header",
                    "creationTime": "2021-07-01 08:51:02.353 +0200",
                    "createdBy": "luca.frosini",
                    "uuid": "7f37a79d-0c00-4166-8a68-165de0a438bf",
                    "lastUpdateBy": "luca.frosini",
                    "lastUpdateTime": "2021-07-01 12:35:26.334 +0200",
                    "contexts": [
                        "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
                        "aa860961-6eb0-4c1c-89fb-c406fe2a2771"
                    ]
                },
                "@class": "EService",
                "@superClasses": [
                    "Service",
                    "GCubeResource",
                    "Resource"
                ]
            },
            "target": {
                "name": "WhnManager",
                "description": "Web Hosting Node Service",
                "header": {
                    "@class": "Header",
                    "creationTime": "2021-07-01 08:51:02.298 +0200",
                    "createdBy": "luca.frosini",
                    "uuid": "97984812-90e6-4eb7-b804-50a9ad3fe4fb",
                    "lastUpdateBy": "luca.frosini",
                    "lastUpdateTime": "2021-07-01 12:35:26.274 +0200",
                    "contexts": [
                        "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
                        "aa860961-6eb0-4c1c-89fb-c406fe2a2771"
                    ]
                },
                "optional": "false",
                "version": "2.0.0-4.15.0-132431",
                "group": "VREManagement",
                "@class": "SoftwareFacet",
                "@superClasses": [
                    "Facet"
                ]
            }
        },
        {
            "header": {
                "@class": "Header",
                "creationTime": "2021-07-01 08:51:02.322 +0200",
                "createdBy": "luca.frosini",
                "uuid": "5c78bec3-2fa6-46b3-892d-d41bed93e136",
                "lastUpdateBy": "luca.frosini",
                "lastUpdateTime": "2021-07-01 12:35:26.298 +0200",
                "contexts": [
                    "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
                    "aa860961-6eb0-4c1c-89fb-c406fe2a2771"
                ]
            },
            "propagationConstraint": {
                "@class": "PropagationConstraint",
                "add": "propagate",
                "remove": "cascade"
            },
            "@class": "ConsistsOf",
            "@superClasses": [],
            "source": {
                "header": {
                    "@class": "Header",
                    "creationTime": "2021-07-01 08:51:02.353 +0200",
                    "createdBy": "luca.frosini",
                    "uuid": "7f37a79d-0c00-4166-8a68-165de0a438bf",
                    "lastUpdateBy": "luca.frosini",
                    "lastUpdateTime": "2021-07-01 12:35:26.334 +0200",
                    "contexts": [
                        "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
                        "aa860961-6eb0-4c1c-89fb-c406fe2a2771"
                    ]
                },
                "@class": "EService",
                "@superClasses": [
                    "Service",
                    "GCubeResource",
                    "Resource"
                ]
            },
            "target": {
                "authorization": {
                    "@class": "ValueSchema",
                    "type": null,
                    "value": "gcube-token"
                },
                "endpoint": "http://pc-frosini.isti.cnr.it:8080/whn-manager/gcube/vremanagement/ws/whnmanager",
                "entryName": "whnmanager",
                "header": {
                    "@class": "Header",
                    "creationTime": "2021-07-01 08:51:02.318 +0200",
                    "createdBy": "luca.frosini",
                    "uuid": "f66a9fdf-3d5c-45fd-8437-6fecec463c4c",
                    "lastUpdateBy": "luca.frosini",
                    "lastUpdateTime": "2021-07-01 12:35:26.290 +0200",
                    "contexts": [
                        "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
                        "aa860961-6eb0-4c1c-89fb-c406fe2a2771"
                    ]
                },
                "@class": "AccessPointFacet",
                "@superClasses": [
                    "Facet"
                ]
            }
        },
        {
            "header": {
                "@class": "Header",
                "creationTime": "2021-07-01 08:51:02.332 +0200",
                "createdBy": "luca.frosini",
                "uuid": "d4aec29c-3f18-4464-94ae-5fb77306eb82",
                "lastUpdateBy": "luca.frosini",
                "lastUpdateTime": "2021-07-01 12:35:26.311 +0200",
                "contexts": [
                    "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
                    "aa860961-6eb0-4c1c-89fb-c406fe2a2771"
                ]
            },
            "propagationConstraint": {
                "@class": "PropagationConstraint",
                "add": "propagate",
                "remove": "cascade"
            },
            "@class": "ConsistsOf",
            "@superClasses": [],
            "source": {
                "header": {
                    "@class": "Header",
                    "creationTime": "2021-07-01 08:51:02.353 +0200",
                    "createdBy": "luca.frosini",
                    "uuid": "7f37a79d-0c00-4166-8a68-165de0a438bf",
                    "lastUpdateBy": "luca.frosini",
                    "lastUpdateTime": "2021-07-01 12:35:26.334 +0200",
                    "contexts": [
                        "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
                        "aa860961-6eb0-4c1c-89fb-c406fe2a2771"
                    ]
                },
                "@class": "EService",
                "@superClasses": [
                    "Service",
                    "GCubeResource",
                    "Resource"
                ]
            },
            "target": {
                "authorization": {
                    "@class": "ValueSchema",
                    "type": null,
                    "value": "gcube-token"
                },
                "endpoint": "http://pc-frosini.isti.cnr.it:8080/whn-manager/gcube/resource",
                "entryName": "WhnManager-remote-management",
                "header": {
                    "@class": "Header",
                    "creationTime": "2021-07-01 08:51:02.327 +0200",
                    "createdBy": "luca.frosini",
                    "uuid": "a18eb180-398e-4302-942e-c3d7e55ad496",
                    "lastUpdateBy": "luca.frosini",
                    "lastUpdateTime": "2021-07-01 12:35:26.306 +0200",
                    "contexts": [
                        "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
                        "aa860961-6eb0-4c1c-89fb-c406fe2a2771"
                    ]
                },
                "@class": "AccessPointFacet",
                "@superClasses": [
                    "Facet"
                ]
            }
        },
        {
            "header": {
                "@class": "Header",
                "creationTime": "2021-07-01 08:51:02.341 +0200",
                "createdBy": "luca.frosini",
                "uuid": "d5e73a7f-d85b-437b-ab2e-64c94061c5ff",
                "lastUpdateBy": "luca.frosini",
                "lastUpdateTime": "2021-07-01 12:35:26.322 +0200",
                "contexts": [
                    "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
                    "aa860961-6eb0-4c1c-89fb-c406fe2a2771"
                ]
            },
            "propagationConstraint": {
                "@class": "PropagationConstraint",
                "add": "propagate",
                "remove": "cascade"
            },
            "@class": "ConsistsOf",
            "@superClasses": [],
            "source": {
                "header": {
                    "@class": "Header",
                    "creationTime": "2021-07-01 08:51:02.353 +0200",
                    "createdBy": "luca.frosini",
                    "uuid": "7f37a79d-0c00-4166-8a68-165de0a438bf",
                    "lastUpdateBy": "luca.frosini",
                    "lastUpdateTime": "2021-07-01 12:35:26.334 +0200",
                    "contexts": [
                        "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
                        "aa860961-6eb0-4c1c-89fb-c406fe2a2771"
                    ]
                },
                "@class": "EService",
                "@superClasses": [
                    "Service",
                    "GCubeResource",
                    "Resource"
                ]
            },
            "target": {
                "header": {
                    "@class": "Header",
                    "creationTime": "2021-07-01 08:51:02.336 +0200",
                    "createdBy": "luca.frosini",
                    "uuid": "44abfa06-a78b-4e5a-a0c5-aa8fe7bcbcf9",
                    "lastUpdateBy": "luca.frosini",
                    "lastUpdateTime": "2021-07-01 12:35:26.318 +0200",
                    "contexts": [
                        "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
                        "aa860961-6eb0-4c1c-89fb-c406fe2a2771"
                    ]
                },
                "value": "started",
                "@class": "StateFacet",
                "@superClasses": [
                    "Facet"
                ]
            }
        },
        {
            "header": {
                "@class": "Header",
                "creationTime": "2021-07-01 08:51:02.350 +0200",
                "createdBy": "luca.frosini",
                "uuid": "f1a41f5c-42a3-47ec-b289-6811e62a1c94",
                "lastUpdateBy": "luca.frosini",
                "lastUpdateTime": "2021-07-01 12:35:26.332 +0200",
                "contexts": [
                    "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
                    "aa860961-6eb0-4c1c-89fb-c406fe2a2771"
                ]
            },
            "propagationConstraint": {
                "@class": "PropagationConstraint",
                "add": "propagate",
                "remove": "cascade"
            },
            "@class": "ConsistsOf",
            "@superClasses": [],
            "source": {
                "header": {
                    "@class": "Header",
                    "creationTime": "2021-07-01 08:51:02.353 +0200",
                    "createdBy": "luca.frosini",
                    "uuid": "7f37a79d-0c00-4166-8a68-165de0a438bf",
                    "lastUpdateBy": "luca.frosini",
                    "lastUpdateTime": "2021-07-01 12:35:26.334 +0200",
                    "contexts": [
                        "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
                        "aa860961-6eb0-4c1c-89fb-c406fe2a2771"
                    ]
                },
                "@class": "EService",
                "@superClasses": [
                    "Service",
                    "GCubeResource",
                    "Resource"
                ]
            },
            "target": {
                "date": "2021-06-30 16:38:26.464 +0200",
                "header": {
                    "@class": "Header",
                    "creationTime": "2021-07-01 08:51:02.346 +0200",
                    "createdBy": "luca.frosini",
                    "uuid": "6142d408-f43c-4db7-851f-1dfeb4d98b99",
                    "lastUpdateBy": "luca.frosini",
                    "lastUpdateTime": "2021-07-01 12:35:26.328 +0200",
                    "contexts": [
                        "ca50eb95-b76c-44fd-9182-229d39c3c9e2",
                        "aa860961-6eb0-4c1c-89fb-c406fe2a2771"
                    ]
                },
                "event": {
                    "@class": "ValueSchema",
                    "schema": "String",
                    "value": "started"
                },
                "@class": "EventFacet",
                "@superClasses": [
                    "Facet"
                ]
            }
        }
    ]
}


If you try to remove from context the EventFacet you will obtain a Schema Violation Exception because an EService must fave one EventFacet. This must be true in every contexts.