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