b65d3b7845d965baa56331b9dd7d014e2b79ed6a
[policy/clamp.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2021 Nordix Foundation.
4  *  Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
5  * ================================================================================
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * SPDX-License-Identifier: Apache-2.0
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.clamp.controlloop.runtime.main.rest;
23
24 import io.swagger.annotations.ApiOperation;
25 import io.swagger.annotations.ApiParam;
26 import io.swagger.annotations.ApiResponse;
27 import io.swagger.annotations.ApiResponses;
28 import io.swagger.annotations.Authorization;
29 import io.swagger.annotations.Extension;
30 import io.swagger.annotations.ExtensionProperty;
31 import io.swagger.annotations.ResponseHeader;
32 import java.util.UUID;
33 import lombok.RequiredArgsConstructor;
34 import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
35 import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops;
36 import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.ControlLoopOrderStateResponse;
37 import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.ControlLoopPrimedResponse;
38 import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstancePropertiesResponse;
39 import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstantiationCommand;
40 import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstantiationResponse;
41 import org.onap.policy.clamp.controlloop.runtime.instantiation.ControlLoopInstantiationProvider;
42 import org.onap.policy.clamp.controlloop.runtime.main.web.AbstractRestController;
43 import org.onap.policy.models.base.PfModelException;
44 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
45 import org.springframework.http.MediaType;
46 import org.springframework.http.ResponseEntity;
47 import org.springframework.web.bind.annotation.DeleteMapping;
48 import org.springframework.web.bind.annotation.GetMapping;
49 import org.springframework.web.bind.annotation.PostMapping;
50 import org.springframework.web.bind.annotation.PutMapping;
51 import org.springframework.web.bind.annotation.RequestBody;
52 import org.springframework.web.bind.annotation.RequestHeader;
53 import org.springframework.web.bind.annotation.RequestParam;
54 import org.springframework.web.bind.annotation.RestController;
55
56 /**
57  * Class to provide REST end points for creating, deleting, query and commanding a control loop definition.
58  */
59 @RestController
60 @RequiredArgsConstructor
61 public class InstantiationController extends AbstractRestController {
62
63     private static final String TAGS = "Clamp Control Loop Instantiation API";
64
65     // The CL provider for instantiation requests
66     private final ControlLoopInstantiationProvider provider;
67
68     /**
69      * Creates a control loop.
70      *
71      * @param requestId request ID used in ONAP logging
72      * @param controlLoops the control loops
73      * @return a response
74      * @throws PfModelException on errors creating a control loop
75      */
76     // @formatter:off
77     @PostMapping(value = "/instantiation",
78             produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML},
79             consumes = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
80     @ApiOperation(
81             value = "Commissions control loop definitions",
82             notes = "Commissions control loop definitions, returning the control loop IDs",
83             response = InstantiationResponse.class,
84             tags = {TAGS},
85             authorizations = @Authorization(value = AUTHORIZATION_TYPE),
86             responseHeaders = {
87                 @ResponseHeader(
88                     name = VERSION_MINOR_NAME,
89                     description = VERSION_MINOR_DESCRIPTION,
90                     response = String.class),
91                 @ResponseHeader(
92                     name = VERSION_PATCH_NAME,
93                     description = VERSION_PATCH_DESCRIPTION,
94                     response = String.class),
95                 @ResponseHeader(
96                     name = VERSION_LATEST_NAME,
97                     description = VERSION_LATEST_DESCRIPTION,
98                     response = String.class),
99                 @ResponseHeader(
100                     name = REQUEST_ID_NAME,
101                     description = REQUEST_ID_HDR_DESCRIPTION,
102                     response = UUID.class)
103                 },
104             extensions = {
105                 @Extension
106                     (
107                         name = EXTENSION_NAME,
108                         properties = {
109                             @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
110                             @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
111                         }
112                     )
113             }
114         )
115     @ApiResponses(
116             value = {
117                 @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
118                 @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
119                 @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
120             }
121         )
122     // @formatter:on
123     public ResponseEntity<InstantiationResponse> create(
124             @RequestHeader(
125                     name = REQUEST_ID_NAME,
126                     required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
127             @ApiParam(value = "Entity Body of Control Loop", required = true) @RequestBody ControlLoops controlLoops)
128             throws PfModelException {
129
130         return ResponseEntity.ok().body(provider.createControlLoops(controlLoops));
131     }
132
133     /**
134      * Saves instance properties.
135      *
136      * @param requestId request ID used in ONAP logging
137      * @param body the body of control loop following TOSCA definition
138      * @return a response
139      */
140     // @formatter:off
141     @PostMapping(value = "/instanceProperties",
142         consumes = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML},
143         produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
144     @ApiOperation(
145         value = "Saves instance properties",
146         notes = "Saves instance properties, returning the saved instances properties and it's version",
147         response = InstancePropertiesResponse.class,
148         tags = {TAGS},
149         authorizations = @Authorization(value = AUTHORIZATION_TYPE),
150         responseHeaders = {
151             @ResponseHeader(
152                 name = VERSION_MINOR_NAME,
153                 description = VERSION_MINOR_DESCRIPTION,
154                 response = String.class),
155             @ResponseHeader(
156                 name = VERSION_PATCH_NAME,
157                 description = VERSION_PATCH_DESCRIPTION,
158                 response = String.class),
159             @ResponseHeader(
160                 name = VERSION_LATEST_NAME,
161                 description = VERSION_LATEST_DESCRIPTION,
162                 response = String.class),
163             @ResponseHeader(
164                 name = REQUEST_ID_NAME,
165                 description = REQUEST_ID_HDR_DESCRIPTION,
166                 response = UUID.class)
167         },
168         extensions = {
169             @Extension
170                 (
171                     name = EXTENSION_NAME,
172                     properties = {
173                         @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
174                         @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
175                     }
176                 )
177         }
178     )
179     @ApiResponses(
180         value = {
181             @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
182             @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
183             @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
184         }
185     )
186     // @formatter:on
187     public ResponseEntity<InstancePropertiesResponse> createInstanceProperties(
188             @RequestHeader(
189                 name = REQUEST_ID_NAME,
190                 required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
191             @ApiParam(value = "Body of instance properties", required = true) @RequestBody ToscaServiceTemplate body)
192         throws PfModelException {
193
194         return ResponseEntity.ok().body(provider.createInstanceProperties(body));
195     }
196
197     /**
198      * Deletes a control loop definition and instance properties.
199      *
200      * @param requestId request ID used in ONAP logging
201      * @param name the name of the control loop to delete
202      * @param version the version of the control loop to delete
203      * @return a response
204      * @throws PfModelException on errors deleting of control loop and instance properties
205      */
206     // @formatter:off
207     @DeleteMapping(value = "/instanceProperties",
208         produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
209     @ApiOperation(value = "Delete a control loop and instance properties",
210         notes = "Deletes a control loop and instance properties, returning optional error details",
211         response = InstantiationResponse.class,
212         tags = {TAGS},
213         authorizations = @Authorization(value = AUTHORIZATION_TYPE),
214         responseHeaders = {
215             @ResponseHeader(
216                 name = VERSION_MINOR_NAME,
217                 description = VERSION_MINOR_DESCRIPTION,
218                 response = String.class),
219             @ResponseHeader(
220                 name = VERSION_PATCH_NAME,
221                 description = VERSION_PATCH_DESCRIPTION,
222                 response = String.class),
223             @ResponseHeader(
224                 name = VERSION_LATEST_NAME,
225                 description = VERSION_LATEST_DESCRIPTION,
226                 response = String.class),
227             @ResponseHeader(
228                 name = REQUEST_ID_NAME,
229                 description = REQUEST_ID_HDR_DESCRIPTION,
230                 response = UUID.class)},
231         extensions = {
232             @Extension
233                 (
234                     name = EXTENSION_NAME,
235                     properties = {
236                         @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
237                         @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
238                     }
239                 )
240         }
241     )
242     @ApiResponses(
243         value = {
244             @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
245             @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
246             @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
247         }
248     )
249     // @formatter:on
250
251     public ResponseEntity<InstantiationResponse> deleteInstanceProperties(
252         @RequestHeader(
253             name = REQUEST_ID_NAME,
254             required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
255         @ApiParam(value = "Control Loop definition name", required = true) @RequestParam("name") String name,
256         @ApiParam(value = "Control Loop definition version") @RequestParam(
257             value = "version",
258             required = true) String version) throws PfModelException {
259
260         return ResponseEntity.ok().body(provider.deleteInstanceProperties(name, version));
261     }
262
263     /**
264      * Queries details of all control loops.
265      *
266      * @param requestId request ID used in ONAP logging
267      * @param name the name of the control loop to get, null for all control loops
268      * @param version the version of the control loop to get, null for all control loops
269      * @return the control loops
270      * @throws PfModelException on errors getting commissioning of control loop
271      */
272     // @formatter:off
273     @GetMapping(value = "/instantiation",
274             produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
275     @ApiOperation(value = "Query details of the requested control loops",
276             notes = "Queries details of the requested control loops, returning all control loop details",
277             response = ControlLoops.class,
278             tags = {TAGS},
279             authorizations = @Authorization(value = AUTHORIZATION_TYPE),
280             responseHeaders = {
281                 @ResponseHeader(
282                     name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
283                     response = String.class),
284                 @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
285                     response = String.class),
286                 @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
287                     response = String.class),
288                 @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
289                     response = UUID.class)},
290             extensions = {
291                 @Extension
292                      (
293                          name = EXTENSION_NAME,
294                          properties = {
295                              @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
296                              @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
297                          }
298                     )
299                 }
300         )
301     @ApiResponses(
302             value = {
303                 @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
304                 @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
305                 @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
306             }
307         )
308     // @formatter:on
309     public ResponseEntity<ControlLoops> query(
310             @RequestHeader(
311                     name = REQUEST_ID_NAME,
312                     required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
313             @ApiParam(value = "Control Loop definition name", required = false) @RequestParam(
314                     value = "name",
315                     required = false) String name,
316             @ApiParam(value = "Control Loop definition version", required = false) @RequestParam(
317                     value = "version",
318                     required = false) String version)
319             throws PfModelException {
320
321         return ResponseEntity.ok().body(provider.getControlLoops(name, version));
322     }
323
324     /**
325      * Updates a control loop.
326      *
327      * @param requestId request ID used in ONAP logging
328      * @param controlLoops the control loops
329      * @return a response
330      * @throws PfModelException on errors updating of control loops
331      */
332     // @formatter:off
333     @PutMapping(value = "/instantiation",
334             produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML},
335             consumes = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
336     @ApiOperation(
337             value = "Updates control loop definitions",
338             notes = "Updates control loop definitions, returning the updated control loop definition IDs",
339             response = InstantiationResponse.class,
340             tags = {TAGS},
341             authorizations = @Authorization(value = AUTHORIZATION_TYPE),
342             responseHeaders = {
343                 @ResponseHeader(
344                     name = VERSION_MINOR_NAME,
345                     description = VERSION_MINOR_DESCRIPTION,
346                     response = String.class),
347                 @ResponseHeader(
348                     name = VERSION_PATCH_NAME,
349                     description = VERSION_PATCH_DESCRIPTION,
350                     response = String.class),
351                 @ResponseHeader(
352                     name = VERSION_LATEST_NAME,
353                     description = VERSION_LATEST_DESCRIPTION,
354                     response = String.class),
355                 @ResponseHeader(
356                     name = REQUEST_ID_NAME,
357                     description = REQUEST_ID_HDR_DESCRIPTION,
358                     response = UUID.class)
359             },
360             extensions = {
361                 @Extension
362                     (
363                         name = EXTENSION_NAME,
364                         properties = {
365                             @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
366                             @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
367                         }
368                     )
369             }
370         )
371     @ApiResponses(
372             value = {
373                 @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
374                 @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
375                 @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
376             }
377         )
378     // @formatter:on
379     public ResponseEntity<InstantiationResponse> update(
380             @RequestHeader(
381                     name = REQUEST_ID_NAME,
382                     required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
383             @ApiParam(value = "Entity Body of Control Loop", required = true) @RequestBody ControlLoops controlLoops)
384             throws PfModelException {
385
386         return ResponseEntity.ok().body(provider.updateControlLoops(controlLoops));
387     }
388
389     /**
390      * Deletes a control loop definition.
391      *
392      * @param requestId request ID used in ONAP logging
393      * @param name the name of the control loop to delete
394      * @param version the version of the control loop to delete
395      * @return a response
396      * @throws PfModelException on errors deleting of control loop
397      */
398     // @formatter:off
399     @DeleteMapping(value = "/instantiation",
400             produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
401     @ApiOperation(value = "Delete a control loop",
402             notes = "Deletes a control loop, returning optional error details",
403             response = InstantiationResponse.class,
404             tags = {TAGS},
405             authorizations = @Authorization(value = AUTHORIZATION_TYPE),
406             responseHeaders = {
407                 @ResponseHeader(
408                     name = VERSION_MINOR_NAME,
409                     description = VERSION_MINOR_DESCRIPTION,
410                     response = String.class),
411                 @ResponseHeader(
412                     name = VERSION_PATCH_NAME,
413                     description = VERSION_PATCH_DESCRIPTION,
414                     response = String.class),
415                 @ResponseHeader(
416                     name = VERSION_LATEST_NAME,
417                     description = VERSION_LATEST_DESCRIPTION,
418                     response = String.class),
419                 @ResponseHeader(
420                     name = REQUEST_ID_NAME,
421                     description = REQUEST_ID_HDR_DESCRIPTION,
422                     response = UUID.class)},
423             extensions = {
424                 @Extension
425                     (
426                         name = EXTENSION_NAME,
427                         properties = {
428                             @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
429                             @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
430                         }
431                     )
432                 }
433         )
434     @ApiResponses(
435         value = {
436             @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
437             @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
438             @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
439         }
440     )
441     // @formatter:on
442
443     public ResponseEntity<InstantiationResponse> delete(
444             @RequestHeader(
445                     name = REQUEST_ID_NAME,
446                     required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
447             @ApiParam(value = "Control Loop definition name", required = true) @RequestParam("name") String name,
448             @ApiParam(value = "Control Loop definition version") @RequestParam(
449                     value = "version",
450                     required = false) String version)
451             throws PfModelException {
452
453         return ResponseEntity.ok().body(provider.deleteControlLoop(name, version));
454     }
455
456     /**
457      * Issues control loop commands to control loops.
458      *
459      * @param requestId request ID used in ONAP logging
460      * @param command the command to issue to control loops
461      * @return the control loop definitions
462      * @throws PfModelException on errors issuing a command
463      * @throws ControlLoopException on errors issuing a command
464      */
465     // @formatter:off
466     @PutMapping(value = "/instantiation/command",
467             produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML},
468             consumes = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
469     @ApiOperation(value = "Issue a command to the requested control loops",
470             notes = "Issues a command to a control loop, ordering a state change on the control loop",
471             response = InstantiationResponse.class,
472             tags = {TAGS},
473             authorizations = @Authorization(value = AUTHORIZATION_TYPE),
474             responseHeaders = {
475                 @ResponseHeader(
476                     name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
477                     response = String.class),
478                 @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
479                     response = String.class),
480                 @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
481                     response = String.class),
482                 @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
483                     response = UUID.class)},
484             extensions = {
485                 @Extension
486                     (
487                         name = EXTENSION_NAME,
488                         properties = {
489                             @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
490                             @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
491                         }
492                     )
493                 }
494         )
495     @ApiResponses(
496             value = {
497                 @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
498                 @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
499                 @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
500             }
501         )
502     // @formatter:on
503     public ResponseEntity<InstantiationResponse> issueControlLoopCommand(
504             @RequestHeader(
505                     name = REQUEST_ID_NAME,
506                     required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
507             @ApiParam(
508                     value = "Entity Body of control loop command",
509                     required = true) @RequestBody InstantiationCommand command)
510             throws ControlLoopException, PfModelException {
511
512         return ResponseEntity.accepted().body(provider.issueControlLoopCommand(command));
513     }
514
515     /**
516      * Queries details of all control loops.
517      *
518      * @param requestId request ID used in ONAP logging
519      * @param name the name of the control loop to get, null for all control loops
520      * @param version the version of the control loop to get, null for all control loops
521      * @return the control loops
522      * @throws PfModelException on errors getting commissioning of control loop
523      */
524     // @formatter:off
525     @GetMapping(value = "/instantiationState",
526         produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
527     @ApiOperation(value = "Query details of the requested control loops",
528         notes = "Queries details of the requested control loops, returning all control loop details",
529         response = ControlLoops.class,
530         tags = {TAGS},
531         authorizations = @Authorization(value = AUTHORIZATION_TYPE),
532         responseHeaders = {
533             @ResponseHeader(
534                 name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
535                 response = String.class),
536             @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
537                 response = String.class),
538             @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
539                 response = String.class),
540             @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
541                 response = UUID.class)},
542         extensions = {
543             @Extension
544                 (
545                     name = EXTENSION_NAME,
546                     properties = {
547                         @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
548                         @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
549                     }
550                 )
551         }
552     )
553     @ApiResponses(
554         value = {
555             @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
556             @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
557             @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
558         }
559     )
560     // @formatter:on
561     public ResponseEntity<ControlLoopOrderStateResponse> getInstantiationOrderState(
562         @RequestHeader(
563             name = REQUEST_ID_NAME,
564             required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
565         @ApiParam(value = "Control Loop name", required = false) @RequestParam(
566             value = "name",
567             required = false) String name,
568         @ApiParam(value = "Control Loop version", required = false) @RequestParam(
569             value = "version",
570             required = false) String version)
571         throws PfModelException {
572
573         return ResponseEntity.ok().body(provider.getInstantiationOrderState(name, version));
574     }
575
576     /**
577      * Queries Primed/De-Primed status of a control loop.
578      *
579      * @param requestId request ID used in ONAP logging
580      * @param name the name of the control loop to get, null for all control loops
581      * @param version the version of the control loop to get, null for all control loops
582      * @return the control loops
583      * @throws PfModelException on errors getting priming of control loop
584      */
585     // @formatter:off
586     @GetMapping(value = "/controlLoopPriming",
587         produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
588     @ApiOperation(value = "Query priming details of the requested control loops",
589         notes = "Queries priming details of the requested control loops, returning primed/deprimed control loops",
590         response = ControlLoopPrimedResponse.class,
591         tags = {TAGS},
592         authorizations = @Authorization(value = AUTHORIZATION_TYPE),
593         responseHeaders = {
594             @ResponseHeader(
595                 name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
596                 response = String.class),
597             @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
598                 response = String.class),
599             @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
600                 response = String.class),
601             @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
602                 response = UUID.class)},
603         extensions = {
604             @Extension
605                 (
606                     name = EXTENSION_NAME,
607                     properties = {
608                         @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
609                         @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
610                     }
611                 )
612         }
613     )
614     @ApiResponses(
615         value = {
616             @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
617             @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
618             @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
619         }
620     )
621     // @formatter:on
622     public ResponseEntity<ControlLoopPrimedResponse> getControlLoopPriming(
623         @RequestHeader(
624             name = REQUEST_ID_NAME,
625             required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
626         @ApiParam(value = "Control Loop definition name", required = false) @RequestParam(
627             value = "name",
628             required = false) String name,
629         @ApiParam(value = "Control Loop definition version", required = false) @RequestParam(
630             value = "version",
631             required = false) String version)
632         throws PfModelException {
633
634         return ResponseEntity.ok().body(provider.getControlLoopPriming(name, version));
635     }
636 }