diff options
-rw-r--r-- | src/onapsdk/configuration/global_settings.py | 1 | ||||
-rw-r--r-- | src/onapsdk/cps/anchor.py | 3 | ||||
-rw-r--r-- | src/onapsdk/cps/cps_element.py | 4 | ||||
-rw-r--r-- | src/onapsdk/cps/dataspace.py | 14 | ||||
-rw-r--r-- | src/onapsdk/cps/schemaset.py | 5 | ||||
-rw-r--r-- | src/onapsdk/version.py | 2 | ||||
-rw-r--r-- | tests/test_settings.py | 2 | ||||
-rw-r--r-- | tests/test_version.py | 2 |
8 files changed, 18 insertions, 15 deletions
diff --git a/src/onapsdk/configuration/global_settings.py b/src/onapsdk/configuration/global_settings.py index 6f7e4d7..7672abc 100644 --- a/src/onapsdk/configuration/global_settings.py +++ b/src/onapsdk/configuration/global_settings.py @@ -29,6 +29,7 @@ CDS_URL = "http://portal.api.simpledemo.onap.org:30449" CDS_AUTH = ("ccsdkapps", "ccsdkapps") CPS_URL = "http://portal.api.simpledemo.onap.org:8080" CPS_AUTH = ("cpsuser", "cpsr0cks!") +CPS_VERSION = "v1" MSB_URL = "https://msb.api.simpledemo.onap.org:30283" SDC_BE_URL = "https://sdc.api.be.simpledemo.onap.org:30204" SDC_FE_URL = "https://sdc.api.fe.simpledemo.onap.org:30207" diff --git a/src/onapsdk/cps/anchor.py b/src/onapsdk/cps/anchor.py index f02687d..6e37a3c 100644 --- a/src/onapsdk/cps/anchor.py +++ b/src/onapsdk/cps/anchor.py @@ -55,8 +55,7 @@ class Anchor(CpsElement): str: Anchor url """ - return f"{self._url}/cps/api/v1/dataspaces/"\ - f"{self.schema_set.dataspace.name}/anchors/{self.name}" + return f"{self._url}/dataspaces/{self.schema_set.dataspace.name}/anchors/{self.name}" def delete(self) -> None: """Delete anchor.""" diff --git a/src/onapsdk/cps/cps_element.py b/src/onapsdk/cps/cps_element.py index 27f1faa..edcabc7 100644 --- a/src/onapsdk/cps/cps_element.py +++ b/src/onapsdk/cps/cps_element.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +from urllib.parse import urljoin + from onapsdk.configuration import settings from onapsdk.onap_service import OnapService @@ -20,5 +22,5 @@ from onapsdk.onap_service import OnapService class CpsElement(OnapService): """Mother Class of all CPS elements.""" - _url: str = settings.CPS_URL + _url: str = urljoin(settings.CPS_URL, f"cps/api/{settings.CPS_VERSION}") auth: tuple = settings.CPS_AUTH diff --git a/src/onapsdk/cps/dataspace.py b/src/onapsdk/cps/dataspace.py index e6340d7..d997f81 100644 --- a/src/onapsdk/cps/dataspace.py +++ b/src/onapsdk/cps/dataspace.py @@ -50,7 +50,7 @@ class Dataspace(CpsElement): str: Dataspace url """ - return f"{self._url}/cps/api/v1/dataspaces/{self.name}" + return f"{self._url}/dataspaces/{self.name}" @classmethod def create(cls, dataspace_name: str) -> "Dataspace": @@ -66,7 +66,7 @@ class Dataspace(CpsElement): cls.send_message( "POST", f"Create {dataspace_name} dataspace", - f"{cls._url}/cps/api/v1/dataspaces?dataspace-name={dataspace_name}", + f"{cls._url}/dataspaces?dataspace-name={dataspace_name}", auth=cls.auth ) return Dataspace(dataspace_name) @@ -143,8 +143,8 @@ class Dataspace(CpsElement): """ schema_set_data: Dict[str, Any] = self.send_message_json( "GET", - "Get all CPS dataspace schemasets", - f"{self._url}/cps/api/v1/dataspaces/{self.name}/schema-sets/{schema_set_name}", + f"Get CPS dataspace {schema_set_name} schemaset", + f"{self._url}/dataspaces/{self.name}/schema-sets/{schema_set_name}", auth=self.auth ) return SchemaSet( @@ -152,7 +152,7 @@ class Dataspace(CpsElement): dataspace=self, module_references=[ SchemaSetModuleReference( - name=module_reference_data["name"], + name=module_reference_data.get("name"), namespace=module_reference_data["namespace"], revision=module_reference_data["revision"] ) for module_reference_data in schema_set_data["moduleReferences"] @@ -175,7 +175,7 @@ class Dataspace(CpsElement): self.send_message( "POST", "Create schema set", - f"{self._url}/cps/api/v1/dataspaces/{self.name}/schema-sets/", + f"{self._url}/dataspaces/{self.name}/schema-sets/", files={"file": schema_set}, data={"schema-set-name": schema_set_name}, headers={}, # Leave headers empty to fill it correctly by `requests` library @@ -188,6 +188,6 @@ class Dataspace(CpsElement): self.send_message( "DELETE", f"Delete {self.name} dataspace", - f"{self._url}/cps/api/v1/dataspaces/{self.name}", + f"{self._url}/dataspaces?dataspace-name={self.name}", auth=self.auth ) diff --git a/src/onapsdk/cps/schemaset.py b/src/onapsdk/cps/schemaset.py index 650d12d..b94cd60 100644 --- a/src/onapsdk/cps/schemaset.py +++ b/src/onapsdk/cps/schemaset.py @@ -29,9 +29,9 @@ class SchemaSetModuleReference: Stores all information about module reference. """ - name: str namespace: str revision: str + name: Optional[str] = None class SchemaSet(CpsElement): @@ -69,5 +69,6 @@ class SchemaSet(CpsElement): self.send_message( "DELETE", f"Delete {self.name} schema set", - f"{self._url}/cps/api/v1/dataspaces/{self.dataspace.name}/schema-sets/{self.name}" + f"{self._url}/dataspaces/{self.dataspace.name}/schema-sets/{self.name}", + auth=self.auth ) diff --git a/src/onapsdk/version.py b/src/onapsdk/version.py index e31995f..be63da9 100644 --- a/src/onapsdk/version.py +++ b/src/onapsdk/version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "10.3.1" +__version__ = "10.3.2" diff --git a/tests/test_settings.py b/tests/test_settings.py index 7e62da6..9b6172e 100644 --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -24,7 +24,7 @@ from onapsdk.exceptions import ModuleError def test_global_settings(): """Test global settings.""" - assert len(settings._settings) == 43 + assert len(settings._settings) == 44 assert settings.AAI_URL == "https://aai.api.sparky.simpledemo.onap.org:30233" assert settings.CDS_URL == "http://portal.api.simpledemo.onap.org:30449" assert settings.SDNC_URL == "https://sdnc.api.simpledemo.onap.org:30267" diff --git a/tests/test_version.py b/tests/test_version.py index 70d0fe7..781a53c 100644 --- a/tests/test_version.py +++ b/tests/test_version.py @@ -17,4 +17,4 @@ import onapsdk.version as version def test_version(): """Check version is the right one.""" - assert version.__version__ == '10.3.1' + assert version.__version__ == '10.3.2' |