2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.sdcrests.action.rest;
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;
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;
46 * Defines various CRUD API that can be performed on Action.
48 @Path("/workflow/v1.0/actions")
49 @Produces(MediaType.APPLICATION_JSON)
50 @Consumes(MediaType.APPLICATION_JSON)
51 @Api(value = "Actions")
53 public interface Actions {
56 * List All Major, Last Minor and Candidate version if any for Given Action Invariant UuId
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
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);
70 * Get list of actions based on a filter criteria. If no filter is sent all actions will be
73 * @return List Of Last Major and Last Minor of All Actions based on filter criteria
76 @ApiOperation(value = "List Filtered Actions ",
77 notes = "Get list of actions based on a filter criteria | If no filter is sent all actions "
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);
88 * List OPENECOMP Components supported by Action Library.
90 * @return List of OPENECOMP Components supported by Action Library
94 @ApiOperation(value = "List OPENECOMP Components supported by Action Library",
95 responseContainer = "List")
96 Response getOpenEcompComponents(@Context HttpServletRequest servletRequest);
99 * Create a new Action based on request JSON.
101 * @return Metadata object {@link ActionResponseDto ActionResponseDto} object for created Action
104 @ApiOperation(value = "Create a new Action")
105 Response createAction(String requestJson, @Context HttpServletRequest servletRequest);
108 * Update an existing action with parameters provided in requestJson.
110 * @return Metadata object {@link ActionResponseDto ActionResponseDto} object for created Action
113 @Path("/{actionInvariantUuId}")
114 @ApiOperation(value = "Update an existing action")
115 Response updateAction(@PathParam("actionInvariantUuId") String actionInvariantUuId,
116 String requestJson, @Context HttpServletRequest servletRequest);
121 * @param actionInvariantUuId Invariant UuId of the action to be deleted
122 * @param servletRequest Servlet request object
123 * @return Empty response object
126 @Path("/{actionInvariantUuId}")
127 @ApiOperation(value = "Delete Action")
128 Response deleteAction(@PathParam("actionInvariantUuId") String actionInvariantUuId,
129 @Context HttpServletRequest servletRequest);
132 * Performs Checkout/Undo_Checkout/Checkin/Submit Operation on Action.
134 * @return Metadata object {@link ActionResponseDto ActionResponseDto} object for created Action
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 "
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);
149 * Upload an artifact to an action.
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
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);
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);
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);
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);