[SDC-29] Amdocs OnBoard 1707 initial commit.
[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 be
71    * 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 OPENECOMP Components supported by Action Library.
89    *
90    * @return List of OPENECOMP Components supported by Action Library
91    */
92   @GET
93   @Path("/components")
94   @ApiOperation(value = "List OPENECOMP Components supported by Action Library",
95       responseContainer = "List")
96   Response getOpenEcompComponents(@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   @Consumes(MediaType.MULTIPART_FORM_DATA)
165   Response uploadArtifact(@PathParam("actionInvariantUuId") String actionInvariantUuId,
166        @Multipart(value = "artifactName", required = false) String artifactName,
167        @Multipart(value = "artifactLabel", required = false) String artifactLabel,
168        @Multipart(value = "artifactCategory", required = false) String artifactCategory,
169        @Multipart(value = "artifactDescription", required = false) String artifactDescription,
170        @Multipart(value = "artifactProtection", required = false) String artifactProtection,
171        @HeaderParam("Content-MD5") String checksum,
172        @Multipart(value = "uploadArtifact", required = false) Attachment artifactToUpload,
173        @Context HttpServletRequest servletRequest);
174
175   @GET
176   @Path("/{actionUuId}/artifacts/{artifactUuId}")
177   @Produces(MediaType.APPLICATION_OCTET_STREAM)
178   @ApiOperation(value = "Downloads artifact for action")
179   Response downloadArtifact(@PathParam("actionUuId") String actionUuId,
180                             @PathParam("artifactUuId") String artifactUuId,
181                             @Context HttpServletRequest servletRequest);
182
183   @DELETE
184   @Path("/{actionInvariantUuId}/artifacts/{artifactUuId}")
185   @ApiOperation(value = "Delete Artifact")
186   Response deleteArtifact(@PathParam("actionInvariantUuId") String actionInvariantUuId,
187                           @PathParam("artifactUuId") String artifactUuId,
188                           @Context HttpServletRequest servletRequest);
189
190   @PUT
191   @Path("/{actionInvariantUuId}/artifacts/{artifactUuId}")
192   @Consumes(MediaType.MULTIPART_FORM_DATA)
193   Response updateArtifact(@PathParam("actionInvariantUuId") String actionInvariantUuId,
194        @PathParam("artifactUuId") String artifactUuId,
195        @Multipart(value = "artifactName", required = false) String artifactName,
196        @Multipart(value = "artifactLabel", required = false) String artifactLabel,
197        @Multipart(value = "artifactCategory", required = false) String artifactCategory,
198        @Multipart(value = "artifactDescription", required = false) String artifactDescription,
199        @Multipart(value = "artifactProtection", required = false) String artifactProtection,
200        @HeaderParam("Content-MD5") String checksum,
201        @Multipart(value = "updateArtifact", required = false) Attachment artifactToUpdate,
202        @Context HttpServletRequest servletRequest);
203
204 }