View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.syncope.common.rest.api.service;
20  
21  import io.swagger.v3.oas.annotations.responses.ApiResponse;
22  import io.swagger.v3.oas.annotations.responses.ApiResponses;
23  import java.util.List;
24  import javax.validation.constraints.Min;
25  import javax.validation.constraints.NotNull;
26  import javax.ws.rs.BeanParam;
27  import javax.ws.rs.DELETE;
28  import javax.ws.rs.DefaultValue;
29  import javax.ws.rs.GET;
30  import javax.ws.rs.POST;
31  import javax.ws.rs.Path;
32  import javax.ws.rs.PathParam;
33  import javax.ws.rs.Produces;
34  import javax.ws.rs.QueryParam;
35  import javax.ws.rs.core.MediaType;
36  import javax.ws.rs.core.Response;
37  import org.apache.syncope.common.lib.to.ExecTO;
38  import org.apache.syncope.common.lib.to.JobTO;
39  import org.apache.syncope.common.lib.to.PagedResult;
40  import org.apache.syncope.common.lib.types.JobAction;
41  import org.apache.syncope.common.rest.api.RESTHeaders;
42  import org.apache.syncope.common.rest.api.beans.ExecQuery;
43  import org.apache.syncope.common.rest.api.beans.ExecSpecs;
44  
45  public interface ExecutableService extends JAXRSService {
46  
47      /**
48       * Returns a paged list of executions matching the given query.
49       *
50       * @param query query conditions
51       * @return paged list of executions the given query
52       */
53      @GET
54      @Path("{key}/executions")
55      @Produces({ MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML })
56      PagedResult<ExecTO> listExecutions(@BeanParam ExecQuery query);
57  
58      /**
59       * Returns the list of recently completed executions, ordered by end date descendent.
60       *
61       * @param max the maximum number of executions to return
62       * @return list of recently completed executions, ordered by end date descendent
63       */
64      @GET
65      @Path("executions/recent")
66      @Produces({ MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML })
67      List<ExecTO> listRecentExecutions(@Min(1) @QueryParam(JAXRSService.PARAM_MAX) @DefaultValue("25") int max);
68  
69      /**
70       * Deletes the executable execution matching the provided key.
71       *
72       * @param executionKey key of executable execution to be deleted
73       */
74      @ApiResponses(
75              @ApiResponse(responseCode = "204", description = "Operation was successful"))
76      @DELETE
77      @Path("executions/{executionKey}")
78      @Produces({ MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML })
79      void deleteExecution(@NotNull @PathParam("executionKey") String executionKey);
80  
81      /**
82       * Deletes the executions matching the given query.
83       *
84       * @param query query conditions
85       * @return batch results as Response entity
86       */
87      @DELETE
88      @ApiResponses(
89              @ApiResponse(responseCode = "200",
90                      description = "Batch results available, returned as Response entity"))
91      @Path("{key}/executions")
92      @Produces(RESTHeaders.MULTIPART_MIXED)
93      Response deleteExecutions(@BeanParam ExecQuery query);
94  
95      /**
96       * Executes the executable matching the given specs.
97       *
98       * @param specs conditions to exec
99       * @return execution report for the executable matching the given specs
100      */
101     @POST
102     @Path("{key}/execute")
103     @Produces({ MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML })
104     ExecTO execute(@BeanParam ExecSpecs specs);
105 
106     /**
107      * Returns job (running or scheduled) for the executable matching the given key.
108      *
109      * @param key executable key
110      * @return job (running or scheduled) for the given key
111      */
112     @GET
113     @Path("jobs/{key}")
114     @Produces({ MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML })
115     JobTO getJob(@PathParam("key") String key);
116 
117     /**
118      * List jobs (running and / or scheduled).
119      *
120      * @return jobs (running and / or scheduled)
121      */
122     @GET
123     @Path("jobs")
124     @Produces({ MediaType.APPLICATION_JSON, RESTHeaders.APPLICATION_YAML, MediaType.APPLICATION_XML })
125     List<JobTO> listJobs();
126 
127     /**
128      * Executes an action on an existing executable's job.
129      *
130      * @param key executable key
131      * @param action action to execute
132      */
133     @ApiResponses(
134             @ApiResponse(responseCode = "204", description = "Operation was successful"))
135     @POST
136     @Path("jobs/{key}")
137     void actionJob(@NotNull @PathParam("key") String key, @QueryParam("action") JobAction action);
138 }