2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.ccsdk.features.sdnr.northbound.a1Adapter;
24 import java.util.Properties;
26 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
27 import org.onap.ccsdk.sli.core.sli.provider.MdsalHelper;
28 import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService;
29 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.*;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
34 public class A1AdapterClient {
36 private static final Logger LOG = LoggerFactory.getLogger(A1AdapterClient.class);
38 private SvcLogicService svcLogicService = null;
40 public A1AdapterClient(final SvcLogicService svcLogicService) {
41 this.svcLogicService = svcLogicService;
44 public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException
46 return svcLogicService.hasGraph(module, rpc, version, mode);
49 // Client for GetNearRTRICs
51 public Properties execute(String module, String rpc, String version, String mode, GetNearRTRICsOutputBuilder serviceData)
52 throws SvcLogicException {
54 Properties parms = new Properties();
56 return execute(module,rpc,version, mode,serviceData,parms);
59 public Properties execute(String module, String rpc, String version, String mode, GetNearRTRICsOutputBuilder serviceData, Properties parms)
60 throws SvcLogicException {
62 localProp = MdsalHelper.toProperties(parms, serviceData);
64 if (LOG.isDebugEnabled())
66 LOG.debug("Parameters passed to SLI");
68 for (Object key : localProp.keySet()) {
69 String parmName = (String) key;
70 String parmValue = localProp.getProperty(parmName);
72 LOG.debug(parmName+" = "+parmValue);
77 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
79 if (LOG.isDebugEnabled())
81 LOG.debug("Parameters returned by SLI");
83 for (Object key : respProps.keySet()) {
84 String parmName = (String) key;
85 String parmValue = respProps.getProperty(parmName);
87 LOG.debug(parmName+" = "+parmValue);
91 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
95 MdsalHelper.toBuilder(respProps, serviceData);
100 // Client for GetHealthCheck
102 public Properties execute(String module, String rpc, String version, String mode, GetHealthCheckOutputBuilder serviceData)
103 throws SvcLogicException {
105 Properties parms = new Properties();
107 return execute(module,rpc,version, mode,serviceData,parms);
110 public Properties execute(String module, String rpc, String version, String mode, GetHealthCheckOutputBuilder serviceData, Properties parms)
111 throws SvcLogicException {
112 Properties localProp;
113 localProp = MdsalHelper.toProperties(parms, serviceData);
115 if (LOG.isDebugEnabled())
117 LOG.debug("Parameters passed to SLI");
119 for (Object key : localProp.keySet()) {
120 String parmName = (String) key;
121 String parmValue = localProp.getProperty(parmName);
123 LOG.debug(parmName+" = "+parmValue);
128 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
130 if (LOG.isDebugEnabled())
132 LOG.debug("Parameters returned by SLI");
134 for (Object key : respProps.keySet()) {
135 String parmName = (String) key;
136 String parmValue = respProps.getProperty(parmName);
138 LOG.debug(parmName+" = "+parmValue);
142 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
146 MdsalHelper.toBuilder(respProps, serviceData);
152 // Client for getPolicyTypes
154 public Properties execute(String module, String rpc, String version, String mode, GetPolicyTypesOutputBuilder serviceData)
155 throws SvcLogicException {
157 Properties parms = new Properties();
159 return execute(module,rpc,version, mode,serviceData,parms);
162 public Properties execute(String module, String rpc, String version, String mode, GetPolicyTypesOutputBuilder serviceData, Properties parms)
163 throws SvcLogicException {
164 Properties localProp;
165 localProp = MdsalHelper.toProperties(parms, serviceData);
167 if (LOG.isDebugEnabled())
169 LOG.debug("Parameters passed to SLI");
171 for (Object key : localProp.keySet()) {
172 String parmName = (String) key;
173 String parmValue = localProp.getProperty(parmName);
175 LOG.debug(parmName+" = "+parmValue);
180 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
182 if (LOG.isDebugEnabled())
184 LOG.debug("Parameters returned by SLI");
186 for (Object key : respProps.keySet()) {
187 String parmName = (String) key;
188 String parmValue = respProps.getProperty(parmName);
190 LOG.debug(parmName+" = "+parmValue);
194 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
198 MdsalHelper.toBuilder(respProps, serviceData);
204 // Client for createPolicyType
207 public Properties execute(String module, String rpc, String version, String mode, CreatePolicyTypeOutputBuilder serviceData)
208 throws SvcLogicException {
210 Properties parms = new Properties();
212 return execute(module,rpc,version, mode,serviceData,parms);
215 public Properties execute(String module, String rpc, String version, String mode, CreatePolicyTypeOutputBuilder serviceData, Properties parms)
216 throws SvcLogicException {
217 Properties localProp;
218 localProp = MdsalHelper.toProperties(parms, serviceData);
220 if (LOG.isDebugEnabled())
222 LOG.debug("Parameters passed to SLI");
224 for (Object key : localProp.keySet()) {
225 String parmName = (String) key;
226 String parmValue = localProp.getProperty(parmName);
228 LOG.debug(parmName+" = "+parmValue);
233 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
235 if (LOG.isDebugEnabled())
237 LOG.debug("Parameters returned by SLI");
239 for (Object key : respProps.keySet()) {
240 String parmName = (String) key;
241 String parmValue = respProps.getProperty(parmName);
243 LOG.debug(parmName+" = "+parmValue);
247 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
251 MdsalHelper.toBuilder(respProps, serviceData);
256 // Client for getPolicyType
258 public Properties execute(String module, String rpc, String version, String mode, GetPolicyTypeOutputBuilder serviceData)
259 throws SvcLogicException {
261 Properties parms = new Properties();
263 return execute(module,rpc,version, mode,serviceData,parms);
266 public Properties execute(String module, String rpc, String version, String mode, GetPolicyTypeOutputBuilder serviceData, Properties parms)
267 throws SvcLogicException {
268 Properties localProp;
269 localProp = MdsalHelper.toProperties(parms, serviceData);
271 if (LOG.isDebugEnabled())
273 LOG.debug("Parameters passed to SLI");
275 for (Object key : localProp.keySet()) {
276 String parmName = (String) key;
277 String parmValue = localProp.getProperty(parmName);
279 LOG.debug(parmName+" = "+parmValue);
284 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
286 if (LOG.isDebugEnabled())
288 LOG.debug("Parameters returned by SLI");
290 for (Object key : respProps.keySet()) {
291 String parmName = (String) key;
292 String parmValue = respProps.getProperty(parmName);
294 LOG.debug(parmName+" = "+parmValue);
298 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
302 MdsalHelper.toBuilder(respProps, serviceData);
308 // Client for deletePolicyType
310 public Properties execute(String module, String rpc, String version, String mode, DeletePolicyTypeOutputBuilder serviceData)
311 throws SvcLogicException {
313 Properties parms = new Properties();
315 return execute(module,rpc,version, mode,serviceData,parms);
318 public Properties execute(String module, String rpc, String version, String mode, DeletePolicyTypeOutputBuilder serviceData, Properties parms)
319 throws SvcLogicException {
320 Properties localProp;
321 localProp = MdsalHelper.toProperties(parms, serviceData);
323 if (LOG.isDebugEnabled())
325 LOG.debug("Parameters passed to SLI");
327 for (Object key : localProp.keySet()) {
328 String parmName = (String) key;
329 String parmValue = localProp.getProperty(parmName);
331 LOG.debug(parmName+" = "+parmValue);
336 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
338 if (LOG.isDebugEnabled())
340 LOG.debug("Parameters returned by SLI");
342 for (Object key : respProps.keySet()) {
343 String parmName = (String) key;
344 String parmValue = respProps.getProperty(parmName);
346 LOG.debug(parmName+" = "+parmValue);
350 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
354 MdsalHelper.toBuilder(respProps, serviceData);
360 // Client for getPolicyInstances
362 public Properties execute(String module, String rpc, String version, String mode, GetPolicyInstancesOutputBuilder serviceData)
363 throws SvcLogicException {
365 Properties parms = new Properties();
367 return execute(module,rpc,version, mode,serviceData,parms);
370 public Properties execute(String module, String rpc, String version, String mode, GetPolicyInstancesOutputBuilder serviceData, Properties parms)
371 throws SvcLogicException {
372 Properties localProp;
373 localProp = MdsalHelper.toProperties(parms, serviceData);
375 if (LOG.isDebugEnabled())
377 LOG.debug("Parameters passed to SLI");
379 for (Object key : localProp.keySet()) {
380 String parmName = (String) key;
381 String parmValue = localProp.getProperty(parmName);
383 LOG.debug(parmName+" = "+parmValue);
388 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
390 if (LOG.isDebugEnabled())
392 LOG.debug("Parameters returned by SLI");
394 for (Object key : respProps.keySet()) {
395 String parmName = (String) key;
396 String parmValue = respProps.getProperty(parmName);
398 LOG.debug(parmName+" = "+parmValue);
402 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
406 MdsalHelper.toBuilder(respProps, serviceData);
413 // Client for createPolicyInstance
415 public Properties execute(String module, String rpc, String version, String mode, CreatePolicyInstanceOutputBuilder serviceData)
416 throws SvcLogicException {
418 Properties parms = new Properties();
420 return execute(module,rpc,version, mode,serviceData,parms);
423 public Properties execute(String module, String rpc, String version, String mode, CreatePolicyInstanceOutputBuilder serviceData, Properties parms)
424 throws SvcLogicException {
425 Properties localProp;
426 localProp = MdsalHelper.toProperties(parms, serviceData);
428 if (LOG.isDebugEnabled())
430 LOG.debug("Parameters passed to SLI");
432 for (Object key : localProp.keySet()) {
433 String parmName = (String) key;
434 String parmValue = localProp.getProperty(parmName);
436 LOG.debug(parmName+" = "+parmValue);
441 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
443 if (LOG.isDebugEnabled())
445 LOG.debug("Parameters returned by SLI");
447 for (Object key : respProps.keySet()) {
448 String parmName = (String) key;
449 String parmValue = respProps.getProperty(parmName);
451 LOG.debug(parmName+" = "+parmValue);
455 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
459 MdsalHelper.toBuilder(respProps, serviceData);
465 // Client for getPolicyInstance
467 public Properties execute(String module, String rpc, String version, String mode, GetPolicyInstanceOutputBuilder serviceData)
468 throws SvcLogicException {
470 Properties parms = new Properties();
472 return execute(module,rpc,version, mode,serviceData,parms);
475 public Properties execute(String module, String rpc, String version, String mode, GetPolicyInstanceOutputBuilder serviceData, Properties parms)
476 throws SvcLogicException {
477 Properties localProp;
478 localProp = MdsalHelper.toProperties(parms, serviceData);
480 if (LOG.isDebugEnabled())
482 LOG.debug("Parameters passed to SLI");
484 for (Object key : localProp.keySet()) {
485 String parmName = (String) key;
486 String parmValue = localProp.getProperty(parmName);
488 LOG.debug(parmName+" = "+parmValue);
493 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
495 if (LOG.isDebugEnabled())
497 LOG.debug("Parameters returned by SLI");
499 for (Object key : respProps.keySet()) {
500 String parmName = (String) key;
501 String parmValue = respProps.getProperty(parmName);
503 LOG.debug(parmName+" = "+parmValue);
507 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
511 MdsalHelper.toBuilder(respProps, serviceData);
516 // Client for deletePolicyInstance
518 public Properties execute(String module, String rpc, String version, String mode, DeletePolicyInstanceOutputBuilder serviceData)
519 throws SvcLogicException {
521 Properties parms = new Properties();
523 return execute(module,rpc,version, mode,serviceData,parms);
526 public Properties execute(String module, String rpc, String version, String mode, DeletePolicyInstanceOutputBuilder serviceData, Properties parms)
527 throws SvcLogicException {
528 Properties localProp;
529 localProp = MdsalHelper.toProperties(parms, serviceData);
531 if (LOG.isDebugEnabled())
533 LOG.debug("Parameters passed to SLI");
535 for (Object key : localProp.keySet()) {
536 String parmName = (String) key;
537 String parmValue = localProp.getProperty(parmName);
539 LOG.debug(parmName+" = "+parmValue);
544 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
546 if (LOG.isDebugEnabled())
548 LOG.debug("Parameters returned by SLI");
550 for (Object key : respProps.keySet()) {
551 String parmName = (String) key;
552 String parmValue = respProps.getProperty(parmName);
554 LOG.debug(parmName+" = "+parmValue);
558 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
562 MdsalHelper.toBuilder(respProps, serviceData);
567 // Client for getStatus
570 public Properties execute(String module, String rpc, String version, String mode, GetStatusOutputBuilder serviceData)
571 throws SvcLogicException {
573 Properties parms = new Properties();
575 return execute(module,rpc,version, mode,serviceData,parms);
578 public Properties execute(String module, String rpc, String version, String mode, GetStatusOutputBuilder serviceData, Properties parms)
579 throws SvcLogicException {
580 Properties localProp;
581 localProp = MdsalHelper.toProperties(parms, serviceData);
583 if (LOG.isDebugEnabled())
585 LOG.debug("Parameters passed to SLI");
587 for (Object key : localProp.keySet()) {
588 String parmName = (String) key;
589 String parmValue = localProp.getProperty(parmName);
591 LOG.debug(parmName+" = "+parmValue);
596 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
598 if (LOG.isDebugEnabled())
600 LOG.debug("Parameters returned by SLI");
602 for (Object key : respProps.keySet()) {
603 String parmName = (String) key;
604 String parmValue = respProps.getProperty(parmName);
606 LOG.debug(parmName+" = "+parmValue);
610 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
614 MdsalHelper.toBuilder(respProps, serviceData);