Publish swagger files for SDC APIs
[sdc.git] / openecomp-be / api / openecomp-sdc-rest-webapp / action-library-rest / action-library-rest-services / src / main / java / org / openecomp / sdcrests / action / rest / Actions.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.sdcrests.action.rest;
22
23 import io.swagger.v3.oas.annotations.Operation;
24 import io.swagger.v3.oas.annotations.info.Info;
25 import io.swagger.v3.oas.annotations.media.Content;
26 import io.swagger.v3.oas.annotations.media.Schema;
27 import io.swagger.v3.oas.annotations.responses.ApiResponse;
28 import io.swagger.v3.oas.annotations.tags.Tag;
29 import io.swagger.v3.oas.annotations.tags.Tags;
30 import org.apache.cxf.jaxrs.ext.multipart.Attachment;
31 import org.apache.cxf.jaxrs.ext.multipart.Multipart;
32 import org.openecomp.sdcrests.action.types.ActionResponseDto;
33 import org.openecomp.sdcrests.action.types.ListResponseWrapper;
34 import org.springframework.validation.annotation.Validated;
35
36 import javax.servlet.http.HttpServletRequest;
37 import javax.ws.rs.*;
38 import javax.ws.rs.core.Context;
39 import javax.ws.rs.core.MediaType;
40 import javax.ws.rs.core.Response;
41
42 /**
43  * Defines various CRUD API that can be performed on Action.
44  */
45 @Path("/workflow/v1.0/actions")
46 @Produces(MediaType.APPLICATION_JSON)
47 @Consumes(MediaType.APPLICATION_JSON)
48 @Tags({@Tag(name = "SDCE-1 APIs"), @Tag(name = "Actions")})
49 @Validated
50 public interface Actions {
51
52   /**
53    * List All Major, Last Minor and Candidate version if any for Given Action Invariant UuId
54    *
55    * @return List of All Major, Last Minor and Candidate version if any Of Action with given
56     actionInvariantUuId. If actionUuId is provided then only action with given actionInvariantUuId
57     and actionUuId
58    */
59   @GET
60   @Path("/{actionInvariantUuId}")
61   @Operation(description = "List Actions For Given Action Invariant UuId", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ListResponseWrapper.class))))
62   Response getActionsByActionInvariantUuId(
63       @PathParam("actionInvariantUuId") String actionInvariantUuId,
64       @QueryParam("version") String actionUuId, @Context HttpServletRequest servletRequest);
65
66   /**
67    * Get list of actions based on a filter criteria. If no filter is sent all actions will be
68    * returned
69    *
70    * @return List Of Last Major and Last Minor of All Actions based on filter criteria
71    */
72   @GET
73   @Operation(description = "List Filtered Actions ",
74       summary = "Get list of actions based on a filter criteria | If no filter is sent all actions "
75           + "will be returned",
76           responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ListResponseWrapper.class))))
77   Response getFilteredActions(@QueryParam("vendor") String vendor,
78                               @QueryParam("category") String category,
79                               @QueryParam("name") String name,
80                               @QueryParam("modelId") String modelId,
81                               @QueryParam("componentId") String componentId,
82                               @Context HttpServletRequest servletRequest);
83
84   /**
85    * List OPENECOMP Components supported by Action Library.
86    *
87    * @return List of OPENECOMP Components supported by Action Library
88    */
89   @GET
90   @Path("/components")
91   @Operation(description = "List OPENECOMP Components supported by Action Library", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ListResponseWrapper.class))))
92   Response getOpenEcompComponents(@Context HttpServletRequest servletRequest);
93
94   /**
95    * Create a new Action based on request JSON.
96    *
97    * @return Metadata object {@link ActionResponseDto ActionResponseDto} object for created Action
98    */
99   @POST
100   @Operation(description = "Create a new Action")
101   Response createAction(String requestJson, @Context HttpServletRequest servletRequest);
102
103   /**
104    * Update an existing action with parameters provided in requestJson.
105    *
106    * @return Metadata object {@link ActionResponseDto ActionResponseDto} object for created Action
107    */
108   @PUT
109   @Path("/{actionInvariantUuId}")
110   @Operation(description = "Update an existing action")
111   Response updateAction(@PathParam("actionInvariantUuId") String actionInvariantUuId,
112                         String requestJson, @Context HttpServletRequest servletRequest);
113
114   /**
115    * Delete an action.
116    *
117    * @param actionInvariantUuId Invariant UuId of the action to be deleted
118    * @param servletRequest      Servlet request object
119    * @return Empty response object
120    */
121   @DELETE
122   @Path("/{actionInvariantUuId}")
123   @Operation(description = "Delete Action")
124   Response deleteAction(@PathParam("actionInvariantUuId") String actionInvariantUuId,
125                         @Context HttpServletRequest servletRequest);
126
127   /**
128    * Performs Checkout/Undo_Checkout/Checkin/Submit Operation on Action.
129    *
130    * @return Metadata object {@link ActionResponseDto ActionResponseDto} object for created Action
131    */
132   @POST
133   @Path("/{actionInvariantUuId}")
134   @Operation(description = "Actions on a action",
135       summary = "Performs one of the following actions on a action: |"
136           + "Checkout: Locks it for edits by other users. Only the locking user sees the edited "
137           + "version.|"
138           + "Undo_Checkout: Unlocks it and deletes the edits that were done.|"
139           + "Checkin: Unlocks it and activates the edited version to all users.| "
140           + "Submit: Finalize its active version.|")
141   Response actOnAction(@PathParam("actionInvariantUuId") String actionInvariantUuId,
142                        String requestJson, @Context HttpServletRequest servletRequest);
143
144   /**
145    * Upload an artifact to an action.
146    *
147    * @param actionInvariantUuId Invariant UuId of the action to which the artifact is uploaded
148    * @param artifactName        Name of the artifact
149    * @param artifactLabel       Label of the artifact
150    * @param artifactCategory    Category of the artifact
151    * @param artifactDescription Description  of the artifact
152    * @param artifactProtection  Artifact protection mode
153    * @param checksum            Checksum of the artifact
154    * @param artifactToUpload    Artifact content object
155    * @param servletRequest      Servlet request object
156    * @return Generated UuId of the uploaded artifact
157    */
158   @POST
159   @Path("/{actionInvariantUuId}/artifacts")
160   @Consumes(MediaType.MULTIPART_FORM_DATA)
161   Response uploadArtifact(@PathParam("actionInvariantUuId") String actionInvariantUuId,
162        @Multipart(value = "artifactName", required = false) String artifactName,
163        @Multipart(value = "artifactLabel", required = false) String artifactLabel,
164        @Multipart(value = "artifactCategory", required = false) String artifactCategory,
165        @Multipart(value = "artifactDescription", required = false) String artifactDescription,
166        @Multipart(value = "artifactProtection", required = false) String artifactProtection,
167        @HeaderParam("Content-MD5") String checksum,
168        @Multipart(value = "uploadArtifact", required = false) Attachment artifactToUpload,
169        @Context HttpServletRequest servletRequest);
170
171   @GET
172   @Path("/{actionUuId}/artifacts/{artifactUuId}")
173   @Produces(MediaType.APPLICATION_OCTET_STREAM)
174   @Operation(description = "Downloads artifact for action")
175   Response downloadArtifact(@PathParam("actionUuId") String actionUuId,
176                             @PathParam("artifactUuId") String artifactUuId,
177                             @Context HttpServletRequest servletRequest);
178
179   @DELETE
180   @Path("/{actionInvariantUuId}/artifacts/{artifactUuId}")
181   @Operation(description = "Delete Artifact")
182   Response deleteArtifact(@PathParam("actionInvariantUuId") String actionInvariantUuId,
183                           @PathParam("artifactUuId") String artifactUuId,
184                           @Context HttpServletRequest servletRequest);
185
186   @PUT
187   @Path("/{actionInvariantUuId}/artifacts/{artifactUuId}")
188   @Consumes(MediaType.MULTIPART_FORM_DATA)
189   Response updateArtifact(@PathParam("actionInvariantUuId") String actionInvariantUuId,
190        @PathParam("artifactUuId") String artifactUuId,
191        @Multipart(value = "artifactName", required = false) String artifactName,
192        @Multipart(value = "artifactLabel", required = false) String artifactLabel,
193        @Multipart(value = "artifactCategory", required = false) String artifactCategory,
194        @Multipart(value = "artifactDescription", required = false) String artifactDescription,
195        @Multipart(value = "artifactProtection", required = false) String artifactProtection,
196        @HeaderParam("Content-MD5") String checksum,
197        @Multipart(value = "updateArtifact", required = false) Attachment artifactToUpdate,
198        @Context HttpServletRequest servletRequest);
199
200 }