aboutsummaryrefslogtreecommitdiffstats
path: root/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/util/MDSALUtil.java
blob: 5db09f92ece5279e26a98f418c4b7c84ed62ab67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
/*-
 * ============LICENSE_START=======================================================
 * openECOMP : SDN-C
 * ================================================================================
 * Copyright (C) 2017 AT&T Intellectual Property. All rights
 *                             reserved.
 * ================================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============LICENSE_END=========================================================
 */

package org.onap.sdnc.northbound.util;

import java.util.concurrent.Future;
import java.util.function.Consumer;
import java.util.function.Function;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.BrgTopologyOperationInputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.BrgTopologyOperationOutputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.ConnectionAttachmentTopologyOperationInputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.ConnectionAttachmentTopologyOperationOutputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.ContrailRouteTopologyOperationInputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.ContrailRouteTopologyOperationOutputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationInputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationOutputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadNetworkTopologyOperationInputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadNetworkTopologyOperationOutputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVfModuleTopologyOperationInputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVfModuleTopologyOperationOutputBuilder;

import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.GenericConfigurationTopologyOperationInputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.GenericConfigurationTopologyOperationOutputBuilder;

import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.GenericConfigurationNotificationInputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.GenericConfigurationNotificationOutputBuilder;

import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.GetpathsegmentTopologyOperationInputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.GetpathsegmentTopologyOperationOutputBuilder;

import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PolicyUpdateNotifyOperationInputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PolicyUpdateNotifyOperationOutputBuilder;

import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PortMirrorTopologyOperationInputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PortMirrorTopologyOperationOutputBuilder;

import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.SecurityZoneTopologyOperationInputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.SecurityZoneTopologyOperationOutputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.ServiceTopologyOperationInputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.ServiceTopologyOperationOutputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.TunnelxconnTopologyOperationInputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.TunnelxconnTopologyOperationOutputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VfModuleTopologyOperationInputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VfModuleTopologyOperationOutputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfTopologyOperationInputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfTopologyOperationOutputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PnfTopologyOperationInputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PnfTopologyOperationOutputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.brg.response.information.BrgResponseInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.connection.attachment.response.information.ConnectionAttachmentResponseInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.contrail.route.response.information.ContrailRouteResponseInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.network.information.NetworkInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.network.response.information.NetworkResponseInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.network.topology.identifier.structure.NetworkTopologyIdentifierStructureBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.preload.network.topology.information.PreloadNetworkTopologyInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.preload.vf.module.topology.information.PreloadVfModuleTopologyInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.request.information.RequestInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sdnc.request.header.SdncRequestHeaderBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.security.zone.response.information.SecurityZoneResponseInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.data.ServiceDataBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.information.ServiceInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.level.oper.status.ServiceLevelOperStatusBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.model.infrastructure.ServiceBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.response.information.ServiceResponseInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.status.ServiceStatusBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.tunnelxconn.response.information.TunnelxconnResponseInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vf.module.information.VfModuleInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vf.module.response.information.VfModuleResponseInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vf.module.topology.VfModuleTopologyBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vf.module.topology.identifier.VfModuleTopologyIdentifierBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.information.VnfInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.response.information.VnfResponseInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.topology.identifier.structure.VnfTopologyIdentifierStructureBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.pnf.details.PnfDetailsBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.pnf.response.information.PnfResponseInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.pnf.topology.identifier.structure.PnfTopologyIdentifierStructureBuilder;
import org.opendaylight.yangtools.yang.common.RpcResult;


/**
 * This uill class provides utility to build yang objects using a recursive syntax that resembles the tree structure
 * when defining the same yang object in json format.
 *
 * For Example
 * <pre>
 * {@code
 * import static org.onap.sdnc.northbound.util.MDSALUtil.*;
 * ServiceTopologyOperationInput input = build(
 *         serviceTopologyOperationInput()
 *                 .setSdncRequestHeader(build(sdncRequestHeader()
 *                         .setSvcRequestId("svc-request-id: xyz")
 *                         .setSvcAction(SvcAction.Assign)
 *                 ))
 *                 .setRequestInformation(build(requestInformation()
 *                         .setRequestId("request-id: xyz")
 *                        .setRequestAction(RequestInformation.RequestAction.CreateServiceInstance)
 *                 ))
 *                .setServiceInformation(build(serviceInformationBuilder()
 *                         .setServiceInstanceId("service-instance-id: xyz")
 *                ))
 * );
 * }
 * </pre>
 */
public class MDSALUtil {

    public static PreloadVfModuleTopologyOperationInputBuilder preloadVfModuleTopologyOperationInput() {
        return new PreloadVfModuleTopologyOperationInputBuilder();
    }

    public static GenericConfigurationTopologyOperationInputBuilder GenericConfigurationTopologyOperationInput() {
        return new GenericConfigurationTopologyOperationInputBuilder();
    }

    public static GenericConfigurationNotificationInputBuilder GenericConfigurationNotificationInput() {
        return new GenericConfigurationNotificationInputBuilder();
    }

    public static GetpathsegmentTopologyOperationInputBuilder GetpathsegmentTopologyOperationInput() {
        return new GetpathsegmentTopologyOperationInputBuilder();
    }

    public static PolicyUpdateNotifyOperationInputBuilder PolicyUpdateNotifyOperationInput() {
        return new PolicyUpdateNotifyOperationInputBuilder();
    }

    public static PortMirrorTopologyOperationInputBuilder PortMirrorTopologyOperationInput() {
        return new PortMirrorTopologyOperationInputBuilder();
    }

    public static PreloadVfModuleTopologyOperationOutputBuilder preloadVfModuleTopologyOperationOutput() {
        return new PreloadVfModuleTopologyOperationOutputBuilder();
    }

    public static PreloadNetworkTopologyOperationInputBuilder preloadNetworkTopologyOperationInput() {
        return new PreloadNetworkTopologyOperationInputBuilder();
    }

    public static PreloadNetworkTopologyOperationOutputBuilder preloadNetworkTopologyOperationOutput() {
        return new PreloadNetworkTopologyOperationOutputBuilder();
    }

    public static BrgTopologyOperationInputBuilder brgTopologyOperationInput() {
        return new BrgTopologyOperationInputBuilder();
    }

    public static BrgTopologyOperationOutputBuilder brgTopologyOperationOutput() {
        return new BrgTopologyOperationOutputBuilder();
    }

    public static TunnelxconnTopologyOperationInputBuilder tunnelxconnTopologyOperationInput() {
        return new TunnelxconnTopologyOperationInputBuilder();
    }

    public static TunnelxconnTopologyOperationOutputBuilder tunnelxconnTopologyOperationOutput() {
        return new TunnelxconnTopologyOperationOutputBuilder();
    }

    public static SecurityZoneTopologyOperationInputBuilder securityZoneTopologyOperationInput() {
        return new SecurityZoneTopologyOperationInputBuilder();
    }

    public static SecurityZoneTopologyOperationOutputBuilder securityZoneTopologyOperationOutput() {
        return new SecurityZoneTopologyOperationOutputBuilder();
    }

    public static ContrailRouteTopologyOperationInputBuilder contrailRouteTopologyOperationInput() {
        return new ContrailRouteTopologyOperationInputBuilder();
    }

    public static ContrailRouteTopologyOperationOutputBuilder contrailRouteTopologyOperationOutput() {
        return new ContrailRouteTopologyOperationOutputBuilder();
    }

    public static VfModuleTopologyOperationInputBuilder vfModuleTopologyOperationInput() {
        return new VfModuleTopologyOperationInputBuilder();
    }

    public static VfModuleTopologyOperationOutputBuilder vfModuleTopologyOperationOutput() {
        return new VfModuleTopologyOperationOutputBuilder();
    }

    public static PnfTopologyOperationInputBuilder pnfTopologyOperationInput() {
        return new PnfTopologyOperationInputBuilder();
    }

    public static PnfTopologyOperationOutputBuilder pnfTopologyOperationOutput() {
        return new PnfTopologyOperationOutputBuilder();
    }

    public static VnfTopologyOperationInputBuilder vnfTopologyOperationInput() {
        return new VnfTopologyOperationInputBuilder();
    }

    public static VnfTopologyOperationOutputBuilder vnfTopologyOperationOutput() {
        return new VnfTopologyOperationOutputBuilder();
    }

    public static ServiceTopologyOperationInputBuilder serviceTopologyOperationInput() {
        return new ServiceTopologyOperationInputBuilder();
    }

    public static ServiceTopologyOperationOutputBuilder serviceTopologyOperationOutput() {
        return new ServiceTopologyOperationOutputBuilder();
    }


    public static SdncRequestHeaderBuilder sdncRequestHeader() {
        return new SdncRequestHeaderBuilder();
    }


    public static RequestInformationBuilder requestInformation() {
        return new RequestInformationBuilder();
    }

    public static ServiceResponseInformationBuilder serviceResponseInformation() {
        return new ServiceResponseInformationBuilder();
    }
    
    public static SecurityZoneResponseInformationBuilder securityZoneResponseInformation() {
        return new SecurityZoneResponseInformationBuilder();
    }

    public static TunnelxconnResponseInformationBuilder tunnelxconnResponseInformation() {
        return new TunnelxconnResponseInformationBuilder();
    }

    public static BrgResponseInformationBuilder brgResponseInformation() {
        return new BrgResponseInformationBuilder();
    }

    public static ContrailRouteResponseInformationBuilder contrailRouteResponseInformation() {
        return new ContrailRouteResponseInformationBuilder();
    }

    public static PnfResponseInformationBuilder pnfResponseInformation() {
        return new PnfResponseInformationBuilder();
    }

    public static VnfResponseInformationBuilder vnfResponseInformation() {
        return new VnfResponseInformationBuilder();
    }

    public static VfModuleResponseInformationBuilder vfModuleResponseInformation() {
        return new VfModuleResponseInformationBuilder();
    }

    public static ServiceInformationBuilder serviceInformationBuilder() {
        return new ServiceInformationBuilder();
    }

    public static PreloadNetworkTopologyInformationBuilder preloadNetworkTopologyInformationBuilder() {
        return new PreloadNetworkTopologyInformationBuilder();
    }

    public static NetworkTopologyIdentifierStructureBuilder networkTopologyIdentifierStructureBuilder(){
        return new NetworkTopologyIdentifierStructureBuilder();
    }

    public static PnfDetailsBuilder pnfDetailsBuilder() {
        return new PnfDetailsBuilder();
    }

    public static VnfInformationBuilder vnfInformationBuilder() {
        return new VnfInformationBuilder();
    }

    public static VfModuleInformationBuilder vfModuleInformationBuilder() {
        return new VfModuleInformationBuilder();
    }

    public static ServiceBuilder service() {
        return new ServiceBuilder();
    }

    public static ServiceDataBuilder serviceData() {
        return new ServiceDataBuilder();
    }

    public static ServiceStatusBuilder serviceStatus() {
        return new ServiceStatusBuilder();
    }

    public static NetworkInformationBuilder networkInformation() {
        return new NetworkInformationBuilder();
    }

    public static NetworkTopologyOperationInputBuilder networkTopologyOperationInput() {
        return new NetworkTopologyOperationInputBuilder();
    }

    public static NetworkTopologyOperationOutputBuilder networkTopologyOperationOutput() {
        return new NetworkTopologyOperationOutputBuilder();
    }

    public static PnfTopologyIdentifierStructureBuilder pnfTopologyIdentifierStructureBuilder() {
        return new PnfTopologyIdentifierStructureBuilder();
    }

    public static VnfTopologyIdentifierStructureBuilder vnfTopologyIdentifierStructureBuilder() {
        return new VnfTopologyIdentifierStructureBuilder();
    }

    public static PreloadVfModuleTopologyInformationBuilder preloadVfModuleTopologyInformationBuilder() {
        return new PreloadVfModuleTopologyInformationBuilder();
    }

    public static VfModuleTopologyBuilder vfModuleTopologyBuilder() {
        return new VfModuleTopologyBuilder();
    }
    
    public static VfModuleTopologyIdentifierBuilder vfModuleTopologyIdentifierBuilder() {
        return new VfModuleTopologyIdentifierBuilder();
    }
    
    public static NetworkResponseInformationBuilder networkResponseInformation() {
        return new NetworkResponseInformationBuilder();
    }

    public static ConnectionAttachmentTopologyOperationInputBuilder connectionAttachmentTopologyOperationInput() {
        return new ConnectionAttachmentTopologyOperationInputBuilder();
    }

    public static ConnectionAttachmentTopologyOperationOutputBuilder connectionAttachmentTopologyOperationOutput() {
        return new ConnectionAttachmentTopologyOperationOutputBuilder();
    }

    public static ConnectionAttachmentResponseInformationBuilder connectionAttachmentResponseInformation() {
        return new ConnectionAttachmentResponseInformationBuilder();
    }

    public static ServiceLevelOperStatusBuilder serviceLevelOperStatus() {
        return new ServiceLevelOperStatusBuilder();
    }

    public static <I, O> O exec(Function<I, Future<RpcResult<O>>> rpc, I rpcParameter,
        Function<RpcResult<O>, O> rpcResult) throws Exception {
        Future<RpcResult<O>> future = rpc.apply(rpcParameter);
        return rpcResult.apply(future.get());
    }

}