SOL003 Adapter Package Management - Fetch VNF Package Artifacts
[so.git] / adapters / mso-vnfm-adapter / mso-vnfm-etsi-adapter / src / main / java / org / onap / so / adapters / vnfmadapter / extclients / etsicatalog / EtsiCatalogUrlProvider.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2019 Nordix Foundation.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.so.adapters.vnfmadapter.extclients.etsicatalog;
22
23 import static org.slf4j.LoggerFactory.getLogger;
24 import org.slf4j.Logger;
25 import org.springframework.beans.factory.annotation.Value;
26 import org.springframework.stereotype.Service;
27
28 /**
29  * Provides the URLs for the REST Requests to the ETSI Catalog Manager.
30  * 
31  * @author gareth.roper@est.tech
32  */
33 @Service
34 public class EtsiCatalogUrlProvider {
35
36     private static final Logger logger = getLogger(EtsiCatalogUrlProvider.class);
37
38     @Value("${msb.endpoint:#{\"http://msb_iag.onap:80\"}}")
39     private String msbEndpoint;
40     @Value("${msb.catalogServiceUrl:#{null}}")
41     private String catalogServiceUrl;
42     @Value("${msb.vnfpkgmServiceUrl:#{\"/api/vnfpkgm/v1\"}}")
43     private String vnfpkgmServiceUrl;
44
45     public EtsiCatalogUrlProvider() {}
46
47     /**
48      * Get the URL for retrieving the Package Content from the ETSI Catalog.".
49      *
50      * @param vnfPkgId The ID of the VNF Package
51      * @return the URL for the GET operation
52      */
53     public String getVnfPackageContentUrl(final String vnfPkgId) {
54         final String url = msbEndpoint + vnfpkgmServiceUrl + "/vnf_packages/" + vnfPkgId + "/package_content";
55         logger.info("getEtsiCatalogVnfPackageContentUrl: {}", url);
56         return url;
57     }
58
59     /**
60      * Get the URL for retrieving VNF packages information from ETSI Catalog.".
61      *
62      * @return the URL for the GET operation
63      */
64     public String getVnfPackagesUrl() {
65         final String url = msbEndpoint + vnfpkgmServiceUrl + "/vnf_packages";
66         logger.info("getEtsiCatalogVnfPackagesEndpoint: {}", url);
67         return url;
68     }
69
70     /**
71      * Get the URL for retrieving specific VNF package information from the ETSI Catalog.".
72      *
73      * @param vnfPkgId The ID of the VNF Package
74      * @return the URL for the GET operation
75      */
76     public String getVnfPackageUrl(final String vnfPkgId) {
77         final String url = msbEndpoint + vnfpkgmServiceUrl + "/vnf_packages/" + vnfPkgId;
78         logger.info("getEtsiCatalogVnfPackageEndpoint: {}", url);
79         return url;
80     }
81
82     /**
83      * Get the URL for retrieving VNF Package Artifacts
84      *
85      * @param vnfPkgId The ID of the VNF Package
86      * @param artifactPath The path to the Artifact
87      * @return the URL for the GET operation
88      */
89     public String getVnfPackageArtifactUrl(final String vnfPkgId, final String artifactPath) {
90         final String url = msbEndpoint + vnfpkgmServiceUrl + "/vnf_packages/" + vnfPkgId + "/artifacts/" + artifactPath;
91         logger.info("getVnfPackageArtifactUrl: {}", url);
92         return url;
93     }
94 }