re base code
[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.annotations.Api;
24 import io.swagger.annotations.ApiOperation;
25 import org.apache.cxf.jaxrs.ext.multipart.Attachment;
26 import org.apache.cxf.jaxrs.ext.multipart.Multipart;
27 import org.openecomp.sdcrests.action.types.ActionResponseDto;
28 import org.springframework.validation.annotation.Validated;
29
30 import javax.servlet.http.HttpServletRequest;
31 import javax.ws.rs.*;
32 import javax.ws.rs.core.Context;
33 import javax.ws.rs.core.MediaType;
34 import javax.ws.rs.core.Response;
35
36 /**
37  * Defines various CRUD API that can be performed on Action.
38  */
39 @Path("/workflow/v1.0/actions")
40 @Produces(MediaType.APPLICATION_JSON)
41 @Consumes(MediaType.APPLICATION_JSON)
42 @Api(value = "Actions")
43 @Validated
44 public interface Actions {
45
46   /**
47    * List All Major, Last Minor and Candidate version if any for Given Action Invariant UuId
48    *
49    * @return List of All Major, Last Minor and Candidate version if any Of Action with given
50     actionInvariantUuId. If actionUuId is provided then only action with given actionInvariantUuId
51     and actionUuId
52    */
53   @GET
54   @Path("/{actionInvariantUuId}")
55   @ApiOperation(value = "List Actions For Given Action Invariant UuId", responseContainer = "List")
56   Response getActionsByActionInvariantUuId(
57       @PathParam("actionInvariantUuId") String actionInvariantUuId,
58       @QueryParam("version") String actionUuId, @Context HttpServletRequest servletRequest);
59
60   /**
61    * Get list of actions based on a filter criteria. If no filter is sent all actions will be
62    * returned
63    *
64    * @return List Of Last Major and Last Minor of All Actions based on filter criteria
65    */
66   @GET
67   @ApiOperation(value = "List Filtered Actions ",
68       notes = "Get list of actions based on a filter criteria | If no filter is sent all actions "
69           + "will be returned",
70       responseContainer = "List")
71   Response getFilteredActions(@QueryParam("vendor") String vendor,
72                               @QueryParam("category") String category,
73                               @QueryParam("name") String name,
74                               @QueryParam("modelId") String modelId,
75                               @QueryParam("componentId") String componentId,
76                               @Context HttpServletRequest servletRequest);
77
78   /**
79    * List OPENECOMP Components supported by Action Library.
80    *
81    * @return List of OPENECOMP Components supported by Action Library
82    */
83   @GET
84   @Path("/components")
85   @ApiOperation(value = "List OPENECOMP Components supported by Action Library",
86       responseContainer = "List")
87   Response getOpenEcompComponents(@Context HttpServletRequest servletRequest);
88
89   /**
90    * Create a new Action based on request JSON.
91    *
92    * @return Metadata object {@link ActionResponseDto ActionResponseDto} object for created Action
93    */
94   @POST
95   @ApiOperation(value = "Create a new Action")
96   Response createAction(String requestJson, @Context HttpServletRequest servletRequest);
97
98   /**
99    * Update an existing action with parameters provided in requestJson.
100    *
101    * @return Metadata object {@link ActionResponseDto ActionResponseDto} object for created Action
102    */
103   @PUT
104   @Path("/{actionInvariantUuId}")
105   @ApiOperation(value = "Update an existing action")
106   Response updateAction(@PathParam("actionInvariantUuId") String actionInvariantUuId,
107                         String requestJson, @Context HttpServletRequest servletRequest);
108
109   /**
110    * Delete an action.
111    *
112    * @param actionInvariantUuId Invariant UuId of the action to be deleted
113    * @param servletRequest      Servlet request object
114    * @return Empty response object
115    */
116   @DELETE
117   @Path("/{actionInvariantUuId}")
118   @ApiOperation(value = "Delete Action")
119   Response deleteAction(@PathParam("actionInvariantUuId") String actionInvariantUuId,
120                         @Context HttpServletRequest servletRequest);
121
122   /**
123    * Performs Checkout/Undo_Checkout/Checkin/Submit Operation on Action.
124    *
125    * @return Metadata object {@link ActionResponseDto ActionResponseDto} object for created Action
126    */
127   @POST
128   @Path("/{actionInvariantUuId}")
129   @ApiOperation(value = "Actions on a action",
130       notes = "Performs one of the following actions on a action: |"
131           + "Checkout: Locks it for edits by other users. Only the locking user sees the edited "
132           + "version.|"
133           + "Undo_Checkout: Unlocks it and deletes the edits that were done.|"
134           + "Checkin: Unlocks it and activates the edited version to all users.| "
135           + "Submit: Finalize its active version.|")
136   Response actOnAction(@PathParam("actionInvariantUuId") String actionInvariantUuId,
137                        String requestJson, @Context HttpServletRequest servletRequest);
138
139   /**
140    * Upload an artifact to an action.
141    *
142    * @param actionInvariantUuId Invariant UuId of the action to which the artifact is uploaded
143    * @param artifactName        Name of the artifact
144    * @param artifactLabel       Label of the artifact
145    * @param artifactCategory    Category of the artifact
146    * @param artifactDescription Description  of the artifact
147    * @param artifactProtection  Artifact protection mode
148    * @param checksum            Checksum of the artifact
149    * @param artifactToUpload    Artifact content object
150    * @param servletRequest      Servlet request object
151    * @return Generated UuId of the uploaded artifact
152    */
153   @POST
154   @Path("/{actionInvariantUuId}/artifacts")
155   @Consumes(MediaType.MULTIPART_FORM_DATA)
156   Response uploadArtifact(@PathParam("actionInvariantUuId") String actionInvariantUuId,
157        @Multipart(value = "artifactName", required = false) String artifactName,
158        @Multipart(value = "artifactLabel", required = false) String artifactLabel,
159        @Multipart(value = "artifactCategory", required = false) String artifactCategory,
160        @Multipart(value = "artifactDescription", required = false) String artifactDescription,
161        @Multipart(value = "artifactProtection", required = false) String artifactProtection,
162        @HeaderParam("Content-MD5") String checksum,
163        @Multipart(value = "uploadArtifact", required = false) Attachment artifactToUpload,
164        @Context HttpServletRequest servletRequest);
165
166   @GET
167   @Path("/{actionUuId}/artifacts/{artifactUuId}")
168   @Produces(MediaType.APPLICATION_OCTET_STREAM)
169   @ApiOperation(value = "Downloads artifact for action")
170   Response downloadArtifact(@PathParam("actionUuId") String actionUuId,
171                             @PathParam("artifactUuId") String artifactUuId,
172                             @Context HttpServletRequest servletRequest);
173
174   @DELETE
175   @Path("/{actionInvariantUuId}/artifacts/{artifactUuId}")
176   @ApiOperation(value = "Delete Artifact")
177   Response deleteArtifact(@PathParam("actionInvariantUuId") String actionInvariantUuId,
178                           @PathParam("artifactUuId") String artifactUuId,
179                           @Context HttpServletRequest servletRequest);
180
181   @PUT
182   @Path("/{actionInvariantUuId}/artifacts/{artifactUuId}")
183   @Consumes(MediaType.MULTIPART_FORM_DATA)
184   Response updateArtifact(@PathParam("actionInvariantUuId") String actionInvariantUuId,
185        @PathParam("artifactUuId") String artifactUuId,
186        @Multipart(value = "artifactName", required = false) String artifactName,
187        @Multipart(value = "artifactLabel", required = false) String artifactLabel,
188        @Multipart(value = "artifactCategory", required = false) String artifactCategory,
189        @Multipart(value = "artifactDescription", required = false) String artifactDescription,
190        @Multipart(value = "artifactProtection", required = false) String artifactProtection,
191        @HeaderParam("Content-MD5") String checksum,
192        @Multipart(value = "updateArtifact", required = false) Attachment artifactToUpdate,
193        @Context HttpServletRequest servletRequest);
194
195 }