Revert "Renaming Files having BluePrint to have Blueprint"
[ccsdk/cds.git] / components / model-catalog / blueprint-model / test-blueprint / resource-audit / Scripts / kotlin / cba / resource / audit / DeviceResourceDefinitions.kt
1 /*
2  *  Copyright © 2019 IBM.
3  *
4  *  Licensed under the Apache License, Version 2.0 (the "License");
5  *  you may not use this file except in compliance with the License.
6  *  You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *  Unless required by applicable law or agreed to in writing, software
11  *  distributed under the License is distributed on an "AS IS" BASIS,
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *  See the License for the specific language governing permissions and
14  *  limitations under the License.
15  */
16
17 package cba.resource.audit
18
19 import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.resourceDefinitions
20 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
21 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintTypes
22
23 const val SOURCE_SDNO = "SDN-O"
24 const val SOURCE_SDNC = "SDNC"
25 const val SOURCE_AAI = "AAI"
26
27 val deviceResourceDefinitions = BluePrintTypes.resourceDefinitions {
28     // Port Speed Definitions
29     resourceDefinition(name = "port-speed", description = "Port Speed") {
30         property(type = "string", required = true)
31         sources {
32             sourceCapability(id = SOURCE_SDNO, description = "SDN-O Source") {
33                 definedProperties {
34                     type(BluePrintConstants.SCRIPT_KOTLIN)
35                     scriptClassReference("cba.resource.audit.processor.PortSpeedRAProcessor")
36                     keyDependencies(arrayListOf("device-id"))
37                 }
38             }
39             sourceDb(id = SOURCE_SDNC, description = "SDNC Controller") {
40                 definedProperties {
41                     endpointSelector("processor-db")
42                     query("SELECT PORT_SPEED FROM XXXX WHERE DEVICE_ID = :device_id")
43                     inputKeyMapping {
44                         map("device_id", "\$device-id")
45                     }
46                     keyDependencies(arrayListOf("device-id"))
47                 }
48             }
49             sourceRest(id = SOURCE_AAI, description = "AAI Source") {
50                 definedProperties {
51                     endpointSelector("aai")
52                     urlPath("/vnf/\$device_id")
53                     path(".\$port-speed")
54                     inputKeyMapping {
55                         map("device_id", "\$device-id")
56                     }
57                     keyDependencies(arrayListOf("device-id"))
58                 }
59             }
60         }
61     }
62 }