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.v3.oas.annotations.Operation;
24 import io.swagger.v3.oas.annotations.info.Info;
25 import io.swagger.v3.oas.annotations.media.Content;
26 import io.swagger.v3.oas.annotations.media.Schema;
27 import io.swagger.v3.oas.annotations.responses.ApiResponse;
28 import io.swagger.v3.oas.annotations.tags.Tag;
29 import io.swagger.v3.oas.annotations.tags.Tags;
30 import org.apache.cxf.jaxrs.ext.multipart.Attachment;
31 import org.apache.cxf.jaxrs.ext.multipart.Multipart;
32 import org.openecomp.sdcrests.action.types.ActionResponseDto;
33 import org.openecomp.sdcrests.action.types.ListResponseWrapper;
34 import org.springframework.validation.annotation.Validated;
36 import javax.servlet.http.HttpServletRequest;
38 import javax.ws.rs.core.Context;
39 import javax.ws.rs.core.MediaType;
40 import javax.ws.rs.core.Response;
43 * Defines various CRUD API that can be performed on Action.
45 @Path("/workflow/v1.0/actions")
46 @Produces(MediaType.APPLICATION_JSON)
47 @Consumes(MediaType.APPLICATION_JSON)
48 @Tags({@Tag(name = "SDCE-1 APIs"), @Tag(name = "Actions")})
50 public interface Actions {
53 * List All Major, Last Minor and Candidate version if any for Given Action Invariant UuId
55 * @return List of All Major, Last Minor and Candidate version if any Of Action with given
56 actionInvariantUuId. If actionUuId is provided then only action with given actionInvariantUuId
60 @Path("/{actionInvariantUuId}")
61 @Operation(description = "List Actions For Given Action Invariant UuId", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ListResponseWrapper.class))))
62 Response getActionsByActionInvariantUuId(
63 @PathParam("actionInvariantUuId") String actionInvariantUuId,
64 @QueryParam("version") String actionUuId, @Context HttpServletRequest servletRequest);
67 * Get list of actions based on a filter criteria. If no filter is sent all actions will be
70 * @return List Of Last Major and Last Minor of All Actions based on filter criteria
73 @Operation(description = "List Filtered Actions ",
74 summary = "Get list of actions based on a filter criteria | If no filter is sent all actions "
76 responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ListResponseWrapper.class))))
77 Response getFilteredActions(@QueryParam("vendor") String vendor,
78 @QueryParam("category") String category,
79 @QueryParam("name") String name,
80 @QueryParam("modelId") String modelId,
81 @QueryParam("componentId") String componentId,
82 @Context HttpServletRequest servletRequest);
85 * List OPENECOMP Components supported by Action Library.
87 * @return List of OPENECOMP Components supported by Action Library
91 @Operation(description = "List OPENECOMP Components supported by Action Library", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ListResponseWrapper.class))))
92 Response getOpenEcompComponents(@Context HttpServletRequest servletRequest);
95 * Create a new Action based on request JSON.
97 * @return Metadata object {@link ActionResponseDto ActionResponseDto} object for created Action
100 @Operation(description = "Create a new Action")
101 Response createAction(String requestJson, @Context HttpServletRequest servletRequest);
104 * Update an existing action with parameters provided in requestJson.
106 * @return Metadata object {@link ActionResponseDto ActionResponseDto} object for created Action
109 @Path("/{actionInvariantUuId}")
110 @Operation(description = "Update an existing action")
111 Response updateAction(@PathParam("actionInvariantUuId") String actionInvariantUuId,
112 String requestJson, @Context HttpServletRequest servletRequest);
117 * @param actionInvariantUuId Invariant UuId of the action to be deleted
118 * @param servletRequest Servlet request object
119 * @return Empty response object
122 @Path("/{actionInvariantUuId}")
123 @Operation(description = "Delete Action")
124 Response deleteAction(@PathParam("actionInvariantUuId") String actionInvariantUuId,
125 @Context HttpServletRequest servletRequest);
128 * Performs Checkout/Undo_Checkout/Checkin/Submit Operation on Action.
130 * @return Metadata object {@link ActionResponseDto ActionResponseDto} object for created Action
133 @Path("/{actionInvariantUuId}")
134 @Operation(description = "Actions on a action",
135 summary = "Performs one of the following actions on a action: |"
136 + "Checkout: Locks it for edits by other users. Only the locking user sees the edited "
138 + "Undo_Checkout: Unlocks it and deletes the edits that were done.|"
139 + "Checkin: Unlocks it and activates the edited version to all users.| "
140 + "Submit: Finalize its active version.|")
141 Response actOnAction(@PathParam("actionInvariantUuId") String actionInvariantUuId,
142 String requestJson, @Context HttpServletRequest servletRequest);
145 * Upload an artifact to an action.
147 * @param actionInvariantUuId Invariant UuId of the action to which the artifact is uploaded
148 * @param artifactName Name of the artifact
149 * @param artifactLabel Label of the artifact
150 * @param artifactCategory Category of the artifact
151 * @param artifactDescription Description of the artifact
152 * @param artifactProtection Artifact protection mode
153 * @param checksum Checksum of the artifact
154 * @param artifactToUpload Artifact content object
155 * @param servletRequest Servlet request object
156 * @return Generated UuId of the uploaded artifact
159 @Path("/{actionInvariantUuId}/artifacts")
160 @Consumes(MediaType.MULTIPART_FORM_DATA)
161 Response uploadArtifact(@PathParam("actionInvariantUuId") String actionInvariantUuId,
162 @Multipart(value = "artifactName", required = false) String artifactName,
163 @Multipart(value = "artifactLabel", required = false) String artifactLabel,
164 @Multipart(value = "artifactCategory", required = false) String artifactCategory,
165 @Multipart(value = "artifactDescription", required = false) String artifactDescription,
166 @Multipart(value = "artifactProtection", required = false) String artifactProtection,
167 @HeaderParam("Content-MD5") String checksum,
168 @Multipart(value = "uploadArtifact", required = false) Attachment artifactToUpload,
169 @Context HttpServletRequest servletRequest);
172 @Path("/{actionUuId}/artifacts/{artifactUuId}")
173 @Produces(MediaType.APPLICATION_OCTET_STREAM)
174 @Operation(description = "Downloads artifact for action")
175 Response downloadArtifact(@PathParam("actionUuId") String actionUuId,
176 @PathParam("artifactUuId") String artifactUuId,
177 @Context HttpServletRequest servletRequest);
180 @Path("/{actionInvariantUuId}/artifacts/{artifactUuId}")
181 @Operation(description = "Delete Artifact")
182 Response deleteArtifact(@PathParam("actionInvariantUuId") String actionInvariantUuId,
183 @PathParam("artifactUuId") String artifactUuId,
184 @Context HttpServletRequest servletRequest);
187 @Path("/{actionInvariantUuId}/artifacts/{artifactUuId}")
188 @Consumes(MediaType.MULTIPART_FORM_DATA)
189 Response updateArtifact(@PathParam("actionInvariantUuId") String actionInvariantUuId,
190 @PathParam("artifactUuId") String artifactUuId,
191 @Multipart(value = "artifactName", required = false) String artifactName,
192 @Multipart(value = "artifactLabel", required = false) String artifactLabel,
193 @Multipart(value = "artifactCategory", required = false) String artifactCategory,
194 @Multipart(value = "artifactDescription", required = false) String artifactDescription,
195 @Multipart(value = "artifactProtection", required = false) String artifactProtection,
196 @HeaderParam("Content-MD5") String checksum,
197 @Multipart(value = "updateArtifact", required = false) Attachment artifactToUpdate,
198 @Context HttpServletRequest servletRequest);