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
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 ECOMP Components supported by Action Library.
90 * @return List of ECOMP Components supported by Action Library.
94 @ApiOperation(value = "List ECOMP Components supported by Action Library",
95 responseContainer = "List")
96 Response getEcompComponents(@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 @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);
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);
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);
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);