aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsheetal ghadge <sheetal.ghadge@t-systems.com>2024-01-24 12:28:04 +0530
committersheetal ghadge <sheetal.ghadge@t-systems.com>2024-01-24 12:31:02 +0530
commite4526494e030ea5b3a81ba2ab646cef4e606832c (patch)
tree15a794dabb12c9409907e7c01d58e5a284faf0ca
parent582ba400f31318dc90ec21552339d66ab79cb80e (diff)
Updating onap-sdk to list service catalog in nbi
Issue-ID: TEST-415 Change-Id: I55bf2b1352b0b006dc3e3b6100cadaecc3e4d672 Signed-off-by: sheetal ghadge <sheetal.ghadge@t-systems.com>
-rw-r--r--src/onapsdk/nbi/nbi.py29
-rw-r--r--tests/test_nbi.py13
2 files changed, 41 insertions, 1 deletions
diff --git a/src/onapsdk/nbi/nbi.py b/src/onapsdk/nbi/nbi.py
index 502a4f2..43cecba 100644
--- a/src/onapsdk/nbi/nbi.py
+++ b/src/onapsdk/nbi/nbi.py
@@ -88,7 +88,7 @@ class ServiceSpecification(Nbi):
"""Service specification representation.
Returns:
- str: Service specification object human readable representation
+ str: Service specification object human-readable representation
"""
return (f"ServiceSpecification(unique_id={self.unique_id}, name={self.name}, "
@@ -144,6 +144,33 @@ class ServiceSpecification(Nbi):
service_specification.get("lifecycleStatus"),
)
+ @classmethod
+ def specification_input_schema(cls, service_specification_id: str) -> "ServiceSpecification":
+ """Retrieve the input schema for a specific service specification.
+
+ Args:
+ service_specification_id (str): Unique identifier for the service specification.
+
+ Returns:
+ ServiceSpecification: Service specification object.
+ """
+ service_specification: dict = cls.send_message_json(
+ "GET",
+ f"Get service specification with {service_specification_id} ID from NBI",
+ f"{cls.base_url}{cls.api_version}/serviceSpecification/{service_specification_id}/"
+ f"specificationInputSchema"
+ )
+
+ return ServiceSpecification(
+ service_specification.get("id"),
+ service_specification.get("name"),
+ service_specification.get("invariantUUID"),
+ service_specification.get("category"),
+ service_specification.get("distributionStatus"),
+ service_specification.get("version"),
+ service_specification.get("lifecycleStatus"),
+ )
+
class Service(Nbi):
"""NBI service."""
diff --git a/tests/test_nbi.py b/tests/test_nbi.py
index a2545d6..a2957a9 100644
--- a/tests/test_nbi.py
+++ b/tests/test_nbi.py
@@ -459,6 +459,19 @@ def test_service_specification_get_by_id(mock_service_specification_send_message
assert service_specification.lifecycle_status == "CERTIFIED"
+@mock.patch.object(ServiceSpecification, "send_message_json")
+def test_specification_input_schema(mock_service_specification_schema_send_message):
+ mock_service_specification_schema_send_message.return_value = SERVICE_SPECIFICATION
+ service_specification_schema = ServiceSpecification.specification_input_schema("test")
+ assert service_specification_schema.unique_id == "a80c901c-6593-491f-9465-877e5acffb46"
+ assert service_specification_schema.name == "testService1"
+ assert service_specification_schema.invariant_uuid == "217deaa7-dfc3-41d8-aa53-bb009029c09f"
+ assert service_specification_schema.category == "Network Service"
+ assert service_specification_schema.distribution_status == "DISTRIBUTED"
+ assert service_specification_schema.version == "1.0"
+ assert service_specification_schema.lifecycle_status == "CERTIFIED"
+
+
@mock.patch.object(Service, "send_message_json")
@mock.patch.object(Customer, "get_by_global_customer_id")
@mock.patch.object(ServiceSpecification, "get_by_id")