d229e68cb51be316ff607b76755452921f3ff4cc
[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)
259             throws PfModelException {
260
261         return ResponseEntity.ok().body(provider.deleteInstanceProperties(name, version));
262     }
263
264     /**
265      * Queries details of all control loops.
266      *
267      * @param requestId request ID used in ONAP logging
268      * @param name the name of the control loop to get, null for all control loops
269      * @param version the version of the control loop to get, null for all control loops
270      * @return the control loops
271      * @throws PfModelException on errors getting commissioning of control loop
272      */
273     // @formatter:off
274     @GetMapping(value = "/instantiation",
275             produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
276     @ApiOperation(value = "Query details of the requested control loops",
277             notes = "Queries details of the requested control loops, returning all control loop details",
278             response = ControlLoops.class,
279             tags = {TAGS},
280             authorizations = @Authorization(value = AUTHORIZATION_TYPE),
281             responseHeaders = {
282                 @ResponseHeader(
283                     name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
284                     response = String.class),
285                 @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
286                     response = String.class),
287                 @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
288                     response = String.class),
289                 @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
290                     response = UUID.class)},
291             extensions = {
292                 @Extension
293                      (
294                          name = EXTENSION_NAME,
295                          properties = {
296                              @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
297                              @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
298                          }
299                     )
300                 }
301         )
302     @ApiResponses(
303             value = {
304                 @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
305                 @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
306                 @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
307             }
308         )
309     // @formatter:on
310     public ResponseEntity<ControlLoops> query(
311             @RequestHeader(
312                     name = REQUEST_ID_NAME,
313                     required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
314             @ApiParam(value = "Control Loop definition name", required = false) @RequestParam(
315                     value = "name",
316                     required = false) String name,
317             @ApiParam(value = "Control Loop definition version", required = false) @RequestParam(
318                     value = "version",
319                     required = false) String version)
320             throws PfModelException {
321
322         return ResponseEntity.ok().body(provider.getControlLoops(name, version));
323     }
324
325     /**
326      * Updates a control loop.
327      *
328      * @param requestId request ID used in ONAP logging
329      * @param controlLoops the control loops
330      * @return a response
331      * @throws PfModelException on errors updating of control loops
332      */
333     // @formatter:off
334     @PutMapping(value = "/instantiation",
335             produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML},
336             consumes = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
337     @ApiOperation(
338             value = "Updates control loop definitions",
339             notes = "Updates control loop definitions, returning the updated control loop definition IDs",
340             response = InstantiationResponse.class,
341             tags = {TAGS},
342             authorizations = @Authorization(value = AUTHORIZATION_TYPE),
343             responseHeaders = {
344                 @ResponseHeader(
345                     name = VERSION_MINOR_NAME,
346                     description = VERSION_MINOR_DESCRIPTION,
347                     response = String.class),
348                 @ResponseHeader(
349                     name = VERSION_PATCH_NAME,
350                     description = VERSION_PATCH_DESCRIPTION,
351                     response = String.class),
352                 @ResponseHeader(
353                     name = VERSION_LATEST_NAME,
354                     description = VERSION_LATEST_DESCRIPTION,
355                     response = String.class),
356                 @ResponseHeader(
357                     name = REQUEST_ID_NAME,
358                     description = REQUEST_ID_HDR_DESCRIPTION,
359                     response = UUID.class)
360             },
361             extensions = {
362                 @Extension
363                     (
364                         name = EXTENSION_NAME,
365                         properties = {
366                             @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
367                             @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
368                         }
369                     )
370             }
371         )
372     @ApiResponses(
373             value = {
374                 @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
375                 @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
376                 @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
377             }
378         )
379     // @formatter:on
380     public ResponseEntity<InstantiationResponse> update(
381             @RequestHeader(
382                     name = REQUEST_ID_NAME,
383                     required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
384             @ApiParam(value = "Entity Body of Control Loop", required = true) @RequestBody ControlLoops controlLoops)
385             throws PfModelException {
386
387         return ResponseEntity.ok().body(provider.updateControlLoops(controlLoops));
388     }
389
390     /**
391      * Deletes a control loop definition.
392      *
393      * @param requestId request ID used in ONAP logging
394      * @param name the name of the control loop to delete
395      * @param version the version of the control loop to delete
396      * @return a response
397      * @throws PfModelException on errors deleting of control loop
398      */
399     // @formatter:off
400     @DeleteMapping(value = "/instantiation",
401             produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
402     @ApiOperation(value = "Delete a control loop",
403             notes = "Deletes a control loop, returning optional error details",
404             response = InstantiationResponse.class,
405             tags = {TAGS},
406             authorizations = @Authorization(value = AUTHORIZATION_TYPE),
407             responseHeaders = {
408                 @ResponseHeader(
409                     name = VERSION_MINOR_NAME,
410                     description = VERSION_MINOR_DESCRIPTION,
411                     response = String.class),
412                 @ResponseHeader(
413                     name = VERSION_PATCH_NAME,
414                     description = VERSION_PATCH_DESCRIPTION,
415                     response = String.class),
416                 @ResponseHeader(
417                     name = VERSION_LATEST_NAME,
418                     description = VERSION_LATEST_DESCRIPTION,
419                     response = String.class),
420                 @ResponseHeader(
421                     name = REQUEST_ID_NAME,
422                     description = REQUEST_ID_HDR_DESCRIPTION,
423                     response = UUID.class)},
424             extensions = {
425                 @Extension
426                     (
427                         name = EXTENSION_NAME,
428                         properties = {
429                             @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
430                             @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
431                         }
432                     )
433                 }
434         )
435     @ApiResponses(
436         value = {
437             @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
438             @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
439             @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
440         }
441     )
442     // @formatter:on
443
444     public ResponseEntity<InstantiationResponse> delete(
445             @RequestHeader(
446                     name = REQUEST_ID_NAME,
447                     required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
448             @ApiParam(value = "Control Loop definition name", required = true) @RequestParam("name") String name,
449             @ApiParam(value = "Control Loop definition version") @RequestParam(
450                     value = "version",
451                     required = true) String version)
452             throws PfModelException {
453
454         return ResponseEntity.ok().body(provider.deleteControlLoop(name, version));
455     }
456
457     /**
458      * Issues control loop commands to control loops.
459      *
460      * @param requestId request ID used in ONAP logging
461      * @param command the command to issue to control loops
462      * @return the control loop definitions
463      * @throws PfModelException on errors issuing a command
464      * @throws ControlLoopException on errors issuing a command
465      */
466     // @formatter:off
467     @PutMapping(value = "/instantiation/command",
468             produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML},
469             consumes = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
470     @ApiOperation(value = "Issue a command to the requested control loops",
471             notes = "Issues a command to a control loop, ordering a state change on the control loop",
472             response = InstantiationResponse.class,
473             tags = {TAGS},
474             authorizations = @Authorization(value = AUTHORIZATION_TYPE),
475             responseHeaders = {
476                 @ResponseHeader(
477                     name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
478                     response = String.class),
479                 @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
480                     response = String.class),
481                 @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
482                     response = String.class),
483                 @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
484                     response = UUID.class)},
485             extensions = {
486                 @Extension
487                     (
488                         name = EXTENSION_NAME,
489                         properties = {
490                             @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
491                             @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
492                         }
493                     )
494                 }
495         )
496     @ApiResponses(
497             value = {
498                 @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
499                 @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
500                 @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
501             }
502         )
503     // @formatter:on
504     public ResponseEntity<InstantiationResponse> issueControlLoopCommand(
505             @RequestHeader(
506                     name = REQUEST_ID_NAME,
507                     required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
508             @ApiParam(
509                     value = "Entity Body of control loop command",
510                     required = true) @RequestBody InstantiationCommand command)
511             throws ControlLoopException, PfModelException {
512
513         return ResponseEntity.accepted().body(provider.issueControlLoopCommand(command));
514     }
515
516     /**
517      * Queries details of all control loops.
518      *
519      * @param requestId request ID used in ONAP logging
520      * @param name the name of the control loop to get, null for all control loops
521      * @param version the version of the control loop to get, null for all control loops
522      * @return the control loops
523      * @throws PfModelException on errors getting commissioning of control loop
524      */
525     // @formatter:off
526     @GetMapping(value = "/instantiationState",
527         produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
528     @ApiOperation(value = "Query details of the requested control loops",
529         notes = "Queries details of the requested control loops, returning all control loop details",
530         response = ControlLoops.class,
531         tags = {TAGS},
532         authorizations = @Authorization(value = AUTHORIZATION_TYPE),
533         responseHeaders = {
534             @ResponseHeader(
535                 name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
536                 response = String.class),
537             @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
538                 response = String.class),
539             @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
540                 response = String.class),
541             @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
542                 response = UUID.class)},
543         extensions = {
544             @Extension
545                 (
546                     name = EXTENSION_NAME,
547                     properties = {
548                         @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
549                         @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
550                     }
551                 )
552         }
553     )
554     @ApiResponses(
555         value = {
556             @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
557             @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
558             @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
559         }
560     )
561     // @formatter:on
562     public ResponseEntity<ControlLoopOrderStateResponse> getInstantiationOrderState(
563             @RequestHeader(
564                     name = REQUEST_ID_NAME,
565                     required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
566             @ApiParam(value = "Control Loop name", required = false) @RequestParam(
567                     value = "name",
568                     required = false) String name,
569             @ApiParam(value = "Control Loop version", required = false) @RequestParam(
570                     value = "version",
571                     required = false) String version)
572             throws PfModelException {
573
574         return ResponseEntity.ok().body(provider.getInstantiationOrderState(name, version));
575     }
576
577     /**
578      * Queries Primed/De-Primed status of a control loop.
579      *
580      * @param requestId request ID used in ONAP logging
581      * @param name the name of the control loop to get, null for all control loops
582      * @param version the version of the control loop to get, null for all control loops
583      * @return the control loops
584      * @throws PfModelException on errors getting priming of control loop
585      */
586     // @formatter:off
587     @GetMapping(value = "/controlLoopPriming",
588         produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
589     @ApiOperation(value = "Query priming details of the requested control loops",
590         notes = "Queries priming details of the requested control loops, returning primed/deprimed control loops",
591         response = ControlLoopPrimedResponse.class,
592         tags = {TAGS},
593         authorizations = @Authorization(value = AUTHORIZATION_TYPE),
594         responseHeaders = {
595             @ResponseHeader(
596                 name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
597                 response = String.class),
598             @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
599                 response = String.class),
600             @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
601                 response = String.class),
602             @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
603                 response = UUID.class)},
604         extensions = {
605             @Extension
606                 (
607                     name = EXTENSION_NAME,
608                     properties = {
609                         @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
610                         @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
611                     }
612                 )
613         }
614     )
615     @ApiResponses(
616         value = {
617             @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
618             @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
619             @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
620         }
621     )
622     // @formatter:on
623     public ResponseEntity<ControlLoopPrimedResponse> getControlLoopPriming(
624             @RequestHeader(
625                     name = REQUEST_ID_NAME,
626                     required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
627             @ApiParam(value = "Control Loop definition name", required = false) @RequestParam(
628                     value = "name",
629                     required = false) String name,
630             @ApiParam(value = "Control Loop definition version", required = false) @RequestParam(
631                     value = "version",
632                     required = false) String version)
633             throws PfModelException {
634
635         return ResponseEntity.ok().body(provider.getControlLoopPriming(name, version));
636     }
637 }