562b8bdcc9ecc1be240307888d4a37b6c94eadc7
[sdc.git] / openecomp-be / api / openecomp-sdc-rest-webapp / action-library-rest / action-library-rest-services / src / main / java / org / openecomp / sdcrests / action / rest / ActionsForSwaggerFileUpload.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 com.sun.jersey.multipart.FormDataParam;
24 import io.swagger.v3.oas.annotations.OpenAPIDefinition;
25 import io.swagger.v3.oas.annotations.Operation;
26 import io.swagger.v3.oas.annotations.info.Info;
27 import org.apache.cxf.jaxrs.ext.multipart.Multipart;
28 import org.springframework.validation.annotation.Validated;
29
30 import javax.servlet.http.HttpServletRequest;
31 import javax.ws.rs.*;
32 import javax.ws.rs.core.Context;
33 import javax.ws.rs.core.MediaType;
34 import javax.ws.rs.core.Response;
35 import java.io.InputStream;
36
37
38 @Path("/workflow/v1.0/actions")
39 @Produces(MediaType.APPLICATION_JSON)
40 @Consumes(MediaType.APPLICATION_JSON)
41 @OpenAPIDefinition(info =  @Info(title = "Actions"))
42 @Validated
43 public interface ActionsForSwaggerFileUpload {
44
45   /**
46    * Upload an artifact to an action.
47    *
48    * @param actionInvariantUuId Invariant UuId of the action to which the artifact is uploaded
49    * @param artifactName        Name of the artifact
50    * @param artifactLabel       Label of the artifact
51    * @param artifactCategory    Category of the artifact
52    * @param artifactDescription Description  of the artifact
53    * @param artifactProtection  Artifact protection mode
54    * @param checksum            Checksum of the artifact
55    * @param artifactToUpload    Artifact content object
56    * @param servletRequest      Servlet request object
57    * @return Generated UuId of the uploaded artifact
58    */
59   @POST
60   @Path("/{actionInvariantUuId}/artifacts")
61   @Operation(description = "Upload new Artifact")
62   @Consumes(MediaType.MULTIPART_FORM_DATA)
63   Response uploadArtifact(@PathParam("actionInvariantUuId") String actionInvariantUuId,
64                           @Multipart(value = "artifactName", required = false) String artifactName,
65                           @Multipart(value = "artifactLabel", required = false)
66                               String artifactLabel,
67                           @Multipart(value = "artifactCategory", required = false)
68                               String artifactCategory,
69                           @Multipart(value = "artifactDescription", required = false)
70                               String artifactDescription,
71                           @Multipart(value = "artifactProtection", required = false)
72                               String artifactProtection,
73                           @HeaderParam("Content-MD5") String checksum,
74                           @FormDataParam(value = "uploadArtifact") InputStream artifactToUpload,
75                           @Context HttpServletRequest servletRequest);
76
77
78   @PUT
79   @Path("/{actionInvariantUuId}/artifacts/{artifactUuId}")
80   @Operation(description = "Update an existing artifact")
81   @Consumes(MediaType.MULTIPART_FORM_DATA)
82   Response updateArtifact(@PathParam("actionInvariantUuId") String actionInvariantUuId,
83                           @PathParam("artifactUuId") String artifactUuId,
84                           @Multipart(value = "artifactName", required = false) String artifactName,
85                           @Multipart(value = "artifactLabel", required = false)
86                               String artifactLabel,
87                           @Multipart(value = "artifactCategory", required = false)
88                               String artifactCategory,
89                           @Multipart(value = "artifactDescription", required = false)
90                               String artifactDescription,
91                           @Multipart(value = "artifactProtection", required = false)
92                               String artifactProtection,
93                           @HeaderParam("Content-MD5") String checksum,
94                           @FormDataParam(value = "updateArtifact") InputStream artifactToUpdate,
95                           @Context HttpServletRequest servletRequest);
96
97 }