aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--onap-client/onap_client/sdc/catalog/service_catalog.py22
-rw-r--r--onap-client/onap_client/sdc/service.py21
-rw-r--r--onap-client/setup.py2
3 files changed, 44 insertions, 1 deletions
diff --git a/onap-client/onap_client/sdc/catalog/service_catalog.py b/onap-client/onap_client/sdc/catalog/service_catalog.py
index aeaa3da..c40306f 100644
--- a/onap-client/onap_client/sdc/catalog/service_catalog.py
+++ b/onap-client/onap_client/sdc/catalog/service_catalog.py
@@ -495,4 +495,26 @@ CATALOG_RESOURCES = {
sdc_properties.GLOBAL_SDC_PASSWORD,
),
},
+ "GET_SDC_CSAR": {
+ "verb": "GET",
+ "description": "Returns the CSAR for a service.",
+ "uri": partial(
+ "{endpoint}{service_path}/{catalog_service_id}/artifacts/{csar_artifact_id}".format,
+ endpoint=sdc_properties.SDC_BE_ENDPOINT,
+ service_path=sdc_properties.SDC_CATALOG_SERVICES_PATH,
+ ),
+ "uri-parameters": ["catalog_service_id", "csar_artifact_id"],
+ "success_code": 200,
+ "headers": {
+ "Accept": "application/json",
+ "Content-Type": "application/json",
+ "USER_ID": sdc_properties.SDC_DESIGNER_USER_ID,
+ "X-TransactionId": str(uuid.uuid4()),
+ "X-FromAppId": application_id,
+ },
+ "auth": (
+ sdc_properties.GLOBAL_SDC_USERNAME,
+ sdc_properties.GLOBAL_SDC_PASSWORD,
+ ),
+ },
}
diff --git a/onap-client/onap_client/sdc/service.py b/onap-client/onap_client/sdc/service.py
index 1b91c61..8b9c68b 100644
--- a/onap-client/onap_client/sdc/service.py
+++ b/onap-client/onap_client/sdc/service.py
@@ -43,6 +43,7 @@ from onap_client.sdc.vnf import get_vnf_id
from onap_client.sdc import SDC_PROPERTIES
from onap_client.util import utility
+import base64
import time
import json
import random
@@ -474,3 +475,23 @@ def poll_distribution(service_name):
raise exceptions.DistributionTimeout(
"Distribution polling timed out waiting for {}".format(service_name)
)
+
+
+@utility
+def download_csar(service_name, output_file):
+ oc = Client()
+
+ service = get_service(service_name)
+ artifact_id = service.get("toscaArtifacts", {}).get("assettoscacsar", {}).get("uniqueId")
+
+ csar_data = oc.sdc.service.get_sdc_csar(
+ catalog_service_id=service.get("uniqueId"),
+ csar_artifact_id=artifact_id
+ ).response_data
+
+ data = base64.b64decode(csar_data.get("base64Contents"))
+
+ output_file = f"{output_file}.csar" if not output_file.endswith(".csar") else output_file
+
+ with open(output_file, "wb") as f:
+ f.write(data)
diff --git a/onap-client/setup.py b/onap-client/setup.py
index c8f0fd9..6f16e46 100644
--- a/onap-client/setup.py
+++ b/onap-client/setup.py
@@ -47,7 +47,7 @@ for file in os.listdir("etc/payloads"):
setuptools.setup(
name="onap-client",
- version="0.6.4",
+ version="0.7.0",
author="Steven Stark",
author_email="steven.stark@att.com",
description="Python API wrapper for ONAP applications",