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