diff options
Diffstat (limited to 'src/onapsdk/cps/dataspace.py')
-rw-r--r-- | src/onapsdk/cps/dataspace.py | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/src/onapsdk/cps/dataspace.py b/src/onapsdk/cps/dataspace.py index 282880f..e574866 100644 --- a/src/onapsdk/cps/dataspace.py +++ b/src/onapsdk/cps/dataspace.py @@ -14,8 +14,8 @@ # limitations under the License. from functools import wraps -from typing import Any, Dict, Iterable -from onapsdk.exceptions import (APIError, ResourceNotFound) +from typing import Any, BinaryIO, Dict, Iterable, Union +from ..exceptions import (APIError, ResourceNotFound) from .anchor import Anchor from .cps_element import CpsElement @@ -89,6 +89,26 @@ class Dataspace(CpsElement): ) return Dataspace(dataspace_name) + @classmethod + @exception_handler + def get_dataspace(cls, dataspace_name: str) -> "Dataspace": + """Get existing dataspace with given name. + + Args: + dataspace_name (str): Dataspace name + + Returns: + Dataspace: Dataspace object + + """ + dataspace_data = cls.send_message_json( + "GET", + f"Get {dataspace_name} dataspace", + f"{cls._url}/admin/dataspaces/{dataspace_name}", + auth=cls.auth + ) + return Dataspace(name=dataspace_data["name"]) + @exception_handler def create_anchor(self, schema_set: SchemaSet, anchor_name: str) -> Anchor: """Create anchor. @@ -188,7 +208,11 @@ class Dataspace(CpsElement): ) @exception_handler - def create_schema_set(self, schema_set_name: str, schema_set: bytes) -> SchemaSet: + def create_schema_set( + self, + schema_set_name: str, + schema_set: Union[bytes, BinaryIO] + ) -> SchemaSet: """Create schema set. Create CPS schema set in dataspace |