http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9bdc752a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerServiceResource.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerServiceResource.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerServiceResource.java index f9bfda3..1581722 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerServiceResource.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerServiceResource.java @@ -17,6 +17,11 @@ package org.apache.nifi.web.api; import com.wordnik.swagger.annotations.Api; +import com.wordnik.swagger.annotations.ApiOperation; +import com.wordnik.swagger.annotations.ApiParam; +import com.wordnik.swagger.annotations.ApiResponse; +import com.wordnik.swagger.annotations.ApiResponses; +import com.wordnik.swagger.annotations.Authorization; import java.net.URI; import java.net.URISyntaxException; import java.util.HashMap; @@ -123,7 +128,8 @@ public class ControllerServiceResource extends ApplicationResource { } /** - * Parses the availability and ensure that the specified availability makes sense for the given NiFi instance. + * Parses the availability and ensure that the specified availability makes + * sense for the given NiFi instance. * * @param availability avail * @return avail @@ -147,17 +153,50 @@ public class ControllerServiceResource extends ApplicationResource { /** * Retrieves all the of controller services in this NiFi. * - * @param clientId Optional client id. If the client id is not specified, a new one will be generated. This value (whether specified or generated) is included in the response. - * @param availability Whether the controller service is available on the NCM only (ncm) or on the nodes only (node). If this instance is not clustered all services should use the node - * availability. + * @param clientId Optional client id. If the client id is not specified, a + * new one will be generated. This value (whether specified or generated) is + * included in the response. + * @param availability Whether the controller service is available on the + * NCM only (ncm) or on the nodes only (node). If this instance is not + * clustered all services should use the node availability. * @return A controllerServicesEntity. */ @GET + @Consumes(MediaType.WILDCARD) @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) @Path("/{availability}") @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')") @TypeHint(ControllerServicesEntity.class) - public Response getControllerServices(@QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId, @PathParam("availability") String availability) { + @ApiOperation( + value = "Gets all controller services", + response = ControllerServicesEntity.class, + authorizations = { + @Authorization(value = "Read Only", type = "ROLE_MONITOR"), + @Authorization(value = "Data Flow Manager", type = "ROLE_DFM"), + @Authorization(value = "Administrator", type = "ROLE_ADMIN") + } + ) + @ApiResponses( + value = { + @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), + @ApiResponse(code = 401, message = "Client could not be authenticated."), + @ApiResponse(code = 403, message = "Client is not authorized to make this request."), + @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") + } + ) + public Response getControllerServices( + @ApiParam( + value = "If the client id is not specified, new one will be generated. This value (whether specified or generated) is included in the response.", + required = false + ) + @QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId, + @ApiParam( + value = "Whether the controller is available on the NCM or nodes. If the NiFi is standalone the availability should be NODE.", + allowableValues = "NCM, NODE", + required = true + ) + @PathParam("availability") String availability) { + final Availability avail = parseAvailability(availability); // replicate if cluster manager @@ -185,10 +224,14 @@ public class ControllerServiceResource extends ApplicationResource { * Creates a new controller service. * * @param httpServletRequest request - * @param version The revision is used to verify the client is working with the latest version of the flow. - * @param clientId Optional client id. If the client id is not specified, a new one will be generated. This value (whether specified or generated) is included in the response. - * @param availability Whether the controller service is available on the NCM only (ncm) or on the nodes only (node). If this instance is not clustered all services should use the node - * availability. + * @param version The revision is used to verify the client is working with + * the latest version of the flow. + * @param clientId Optional client id. If the client id is not specified, a + * new one will be generated. This value (whether specified or generated) is + * included in the response. + * @param availability Whether the controller service is available on the + * NCM only (ncm) or on the nodes only (node). If this instance is not + * clustered all services should use the node availability. * @param type The type of controller service to create. * @return A controllerServiceEntity. */ @@ -228,8 +271,9 @@ public class ControllerServiceResource extends ApplicationResource { * Creates a new Controller Service. * * @param httpServletRequest request - * @param availability Whether the controller service is available on the NCM only (ncm) or on the nodes only (node). If this instance is not clustered all services should use the node - * availability. + * @param availability Whether the controller service is available on the + * NCM only (ncm) or on the nodes only (node). If this instance is not + * clustered all services should use the node availability. * @param controllerServiceEntity A controllerServiceEntity. * @return A controllerServiceEntity. */ @@ -239,10 +283,33 @@ public class ControllerServiceResource extends ApplicationResource { @Path("/{availability}") @PreAuthorize("hasRole('ROLE_DFM')") @TypeHint(ControllerServiceEntity.class) + @ApiOperation( + value = "Creates a new controller service", + response = ControllerServiceEntity.class, + authorizations = { + @Authorization(value = "Data Flow Manager", type = "ROLE_DFM") + } + ) + @ApiResponses( + value = { + @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), + @ApiResponse(code = 401, message = "Client could not be authenticated."), + @ApiResponse(code = 403, message = "Client is not authorized to make this request."), + @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") + } + ) public Response createControllerService( @Context HttpServletRequest httpServletRequest, + @ApiParam( + value = "Whether the controller is available on the NCM or nodes. If the NiFi is standalone the availability should be NODE.", + allowableValues = "NCM, NODE", + required = true + ) @PathParam("availability") String availability, - ControllerServiceEntity controllerServiceEntity) { + @ApiParam( + value = "The controller service configuration details.", + required = true + ) ControllerServiceEntity controllerServiceEntity) { final Availability avail = parseAvailability(availability); @@ -317,19 +384,56 @@ public class ControllerServiceResource extends ApplicationResource { /** * Retrieves the specified controller service. * - * @param clientId Optional client id. If the client id is not specified, a new one will be generated. This value (whether specified or generated) is included in the response. - * @param availability Whether the controller service is available on the NCM only (ncm) or on the nodes only (node). If this instance is not clustered all services should use the node - * availability. + * @param clientId Optional client id. If the client id is not specified, a + * new one will be generated. This value (whether specified or generated) is + * included in the response. + * @param availability Whether the controller service is available on the + * NCM only (ncm) or on the nodes only (node). If this instance is not + * clustered all services should use the node availability. * @param id The id of the controller service to retrieve * @return A controllerServiceEntity. */ @GET + @Consumes(MediaType.WILDCARD) @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) @Path("/{availability}/{id}") @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')") @TypeHint(ControllerServiceEntity.class) - public Response getControllerService(@QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId, - @PathParam("availability") String availability, @PathParam("id") String id) { + @ApiOperation( + value = "Gets a controller service", + response = ControllerServiceEntity.class, + authorizations = { + @Authorization(value = "Read Only", type = "ROLE_MONITOR"), + @Authorization(value = "Data Flow Manager", type = "ROLE_DFM"), + @Authorization(value = "Administrator", type = "ROLE_ADMIN") + } + ) + @ApiResponses( + value = { + @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), + @ApiResponse(code = 401, message = "Client could not be authenticated."), + @ApiResponse(code = 403, message = "Client is not authorized to make this request."), + @ApiResponse(code = 404, message = "The specified resource could not be found."), + @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") + } + ) + public Response getControllerService( + @ApiParam( + value = "If the client id is not specified, new one will be generated. This value (whether specified or generated) is included in the response.", + required = false + ) + @QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId, + @ApiParam( + value = "Whether the controller is available on the NCM or nodes. If the NiFi is standalone the availability should be NODE.", + allowableValues = "NCM, NODE", + required = true + ) + @PathParam("availability") String availability, + @ApiParam( + value = "The controller service id.", + required = true + ) + @PathParam("id") String id) { final Availability avail = parseAvailability(availability); @@ -356,20 +460,59 @@ public class ControllerServiceResource extends ApplicationResource { /** * Returns the descriptor for the specified property. * - * @param clientId Optional client id. If the client id is not specified, a new one will be generated. This value (whether specified or generated) is included in the response. + * @param clientId Optional client id. If the client id is not specified, a + * new one will be generated. This value (whether specified or generated) is + * included in the response. * @param availability avail * @param id The id of the controller service. * @param propertyName The property * @return a propertyDescriptorEntity */ @GET + @Consumes(MediaType.WILDCARD) @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) @Path("/{availability}/{id}/descriptors") @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')") @TypeHint(PropertyDescriptorEntity.class) + @ApiOperation( + value = "Gets a controller service property descriptor", + response = PropertyDescriptorEntity.class, + authorizations = { + @Authorization(value = "Read Only", type = "ROLE_MONITOR"), + @Authorization(value = "Data Flow Manager", type = "ROLE_DFM"), + @Authorization(value = "Administrator", type = "ROLE_ADMIN") + } + ) + @ApiResponses( + value = { + @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), + @ApiResponse(code = 401, message = "Client could not be authenticated."), + @ApiResponse(code = 403, message = "Client is not authorized to make this request."), + @ApiResponse(code = 404, message = "The specified resource could not be found."), + @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") + } + ) public Response getPropertyDescriptor( + @ApiParam( + value = "If the client id is not specified, new one will be generated. This value (whether specified or generated) is included in the response.", + required = false + ) @QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId, - @PathParam("availability") String availability, @PathParam("id") String id, + @ApiParam( + value = "Whether the controller is available on the NCM or nodes. If the NiFi is standalone the availability should be NODE.", + allowableValues = "NCM, NODE", + required = true + ) + @PathParam("availability") String availability, + @ApiParam( + value = "The controller service id.", + required = true + ) + @PathParam("id") String id, + @ApiParam( + value = "The property name to return the descriptor for.", + required = true + ) @QueryParam("propertyName") String propertyName) { final Availability avail = parseAvailability(availability); @@ -403,20 +546,56 @@ public class ControllerServiceResource extends ApplicationResource { /** * Retrieves the references of the specified controller service. * - * @param clientId Optional client id. If the client id is not specified, a new one will be generated. This value (whether specified or generated) is included in the response. - * @param availability Whether the controller service is available on the NCM only (ncm) or on the nodes only (node). If this instance is not clustered all services should use the node - * availability. + * @param clientId Optional client id. If the client id is not specified, a + * new one will be generated. This value (whether specified or generated) is + * included in the response. + * @param availability Whether the controller service is available on the + * NCM only (ncm) or on the nodes only (node). If this instance is not + * clustered all services should use the node availability. * @param id The id of the controller service to retrieve * @return A controllerServiceEntity. */ @GET + @Consumes(MediaType.WILDCARD) @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) @Path("/{availability}/{id}/references") @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')") @TypeHint(ControllerServiceEntity.class) + @ApiOperation( + value = "Gets a controller service", + response = ControllerServiceEntity.class, + authorizations = { + @Authorization(value = "Read Only", type = "ROLE_MONITOR"), + @Authorization(value = "Data Flow Manager", type = "ROLE_DFM"), + @Authorization(value = "Administrator", type = "ROLE_ADMIN") + } + ) + @ApiResponses( + value = { + @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), + @ApiResponse(code = 401, message = "Client could not be authenticated."), + @ApiResponse(code = 403, message = "Client is not authorized to make this request."), + @ApiResponse(code = 404, message = "The specified resource could not be found."), + @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") + } + ) public Response getControllerServiceReferences( + @ApiParam( + value = "If the client id is not specified, new one will be generated. This value (whether specified or generated) is included in the response.", + required = false + ) @QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId, - @PathParam("availability") String availability, @PathParam("id") String id) { + @ApiParam( + value = "Whether the controller is available on the NCM or nodes. If the NiFi is standalone the availability should be NODE.", + allowableValues = "NCM, NODE", + required = true + ) + @PathParam("availability") String availability, + @ApiParam( + value = "The controller service id.", + required = true + ) + @PathParam("id") String id) { final Availability avail = parseAvailability(availability); @@ -444,26 +623,71 @@ public class ControllerServiceResource extends ApplicationResource { * Updates the references of the specified controller service. * * @param httpServletRequest request - * @param version The revision is used to verify the client is working with the latest version of the flow. - * @param clientId Optional client id. If the client id is not specified, a new one will be generated. This value (whether specified or generated) is included in the response. - * @param availability Whether the controller service is available on the NCM only (ncm) or on the nodes only (node). If this instance is not clustered all services should use the node - * availability. + * @param version The revision is used to verify the client is working with + * the latest version of the flow. + * @param clientId Optional client id. If the client id is not specified, a + * new one will be generated. This value (whether specified or generated) is + * included in the response. + * @param availability Whether the controller service is available on the + * NCM only (ncm) or on the nodes only (node). If this instance is not + * clustered all services should use the node availability. * @param id The id of the controller service to retrieve - * @param state Sets the state of referencing components. A value of RUNNING or STOPPED will update referencing schedulable components (Processors and Reporting Tasks). A value of ENABLED or - * DISABLED will update referencing controller services. + * @param state Sets the state of referencing components. A value of RUNNING + * or STOPPED will update referencing schedulable components (Processors and + * Reporting Tasks). A value of ENABLED or DISABLED will update referencing + * controller services. * @return A controllerServiceEntity. */ @PUT @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) @Path("/{availability}/{id}/references") - @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')") + @PreAuthorize("hasRole('ROLE_DFM')") @TypeHint(ControllerServiceEntity.class) + @ApiOperation( + value = "Updates a controller services references", + response = ControllerServiceEntity.class, + authorizations = { + @Authorization(value = "Data Flow Manager", type = "ROLE_DFM") + } + ) + @ApiResponses( + value = { + @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), + @ApiResponse(code = 401, message = "Client could not be authenticated."), + @ApiResponse(code = 403, message = "Client is not authorized to make this request."), + @ApiResponse(code = 404, message = "The specified resource could not be found."), + @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") + } + ) public Response updateControllerServiceReferences( @Context HttpServletRequest httpServletRequest, + @ApiParam( + value = "The revision is used to verify the client is working with the latest version of the flow.", + required = false + ) @FormParam(VERSION) LongParameter version, + @ApiParam( + value = "If the client id is not specified, new one will be generated. This value (whether specified or generated) is included in the response.", + required = false + ) @FormParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId, - @PathParam("availability") String availability, @PathParam("id") String id, + @ApiParam( + value = "Whether the controller is available on the NCM or nodes. If the NiFi is standalone the availability should be NODE.", + allowableValues = "NCM, NODE", + required = true + ) + @PathParam("availability") String availability, + @ApiParam( + value = "The controller service id.", + required = true + ) + @PathParam("id") String id, + @ApiParam( + value = "The new state of the references for the controller service.", + allowableValues = "ENABLED, DISABLED, RUNNING, STOPPED", + required = true + ) @FormParam("state") @DefaultValue(StringUtils.EMPTY) String state) { // parse the state to determine the desired action @@ -538,18 +762,26 @@ public class ControllerServiceResource extends ApplicationResource { * Updates the specified controller service. * * @param httpServletRequest request - * @param version The revision is used to verify the client is working with the latest version of the flow. - * @param clientId Optional client id. If the client id is not specified, a new one will be generated. This value (whether specified or generated) is included in the response. - * @param availability Whether the controller service is available on the NCM only (ncm) or on the nodes only (node). If this instance is not clustered all services should use the node - * availability. + * @param version The revision is used to verify the client is working with + * the latest version of the flow. + * @param clientId Optional client id. If the client id is not specified, a + * new one will be generated. This value (whether specified or generated) is + * included in the response. + * @param availability Whether the controller service is available on the + * NCM only (ncm) or on the nodes only (node). If this instance is not + * clustered all services should use the node availability. * @param id The id of the controller service to update. * @param name The name of the controller service * @param annotationData The annotation data for the controller service * @param comments The comments for the controller service - * @param state The state of this controller service. Should be ENABLED or DISABLED. - * @param markedForDeletion Array of property names whose value should be removed. - * @param formParams Additionally, the processor properties and styles are specified in the form parameters. Because the property names and styles differ from processor to processor they are - * specified in a map-like fashion: + * @param state The state of this controller service. Should be ENABLED or + * DISABLED. + * @param markedForDeletion Array of property names whose value should be + * removed. + * @param formParams Additionally, the processor properties and styles are + * specified in the form parameters. Because the property names and styles + * differ from processor to processor they are specified in a map-like + * fashion: * <br> * <ul> * <li>properties[required.file.path]=/path/to/file</li> @@ -634,8 +866,9 @@ public class ControllerServiceResource extends ApplicationResource { * Updates the specified a new Controller Service. * * @param httpServletRequest request - * @param availability Whether the controller service is available on the NCM only (ncm) or on the nodes only (node). If this instance is not clustered all services should use the node - * availability. + * @param availability Whether the controller service is available on the + * NCM only (ncm) or on the nodes only (node). If this instance is not + * clustered all services should use the node availability. * @param id The id of the controller service to update. * @param controllerServiceEntity A controllerServiceEntity. * @return A controllerServiceEntity. @@ -646,11 +879,39 @@ public class ControllerServiceResource extends ApplicationResource { @Path("/{availability}/{id}") @PreAuthorize("hasRole('ROLE_DFM')") @TypeHint(ControllerServiceEntity.class) + @ApiOperation( + value = "Updates a controller service", + response = ControllerServiceEntity.class, + authorizations = { + @Authorization(value = "Data Flow Manager", type = "ROLE_DFM") + } + ) + @ApiResponses( + value = { + @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), + @ApiResponse(code = 401, message = "Client could not be authenticated."), + @ApiResponse(code = 403, message = "Client is not authorized to make this request."), + @ApiResponse(code = 404, message = "The specified resource could not be found."), + @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") + } + ) public Response updateControllerService( @Context HttpServletRequest httpServletRequest, + @ApiParam( + value = "Whether the controller is available on the NCM or nodes. If the NiFi is standalone the availability should be NODE.", + allowableValues = "NCM, NODE", + required = true + ) @PathParam("availability") String availability, + @ApiParam( + value = "The controller service id.", + required = true + ) @PathParam("id") String id, - ControllerServiceEntity controllerServiceEntity) { + @ApiParam( + value = "The controller service configuration details.", + required = true + ) ControllerServiceEntity controllerServiceEntity) { final Availability avail = parseAvailability(availability); @@ -711,23 +972,62 @@ public class ControllerServiceResource extends ApplicationResource { * Removes the specified controller service. * * @param httpServletRequest request - * @param version The revision is used to verify the client is working with the latest version of the flow. - * @param clientId Optional client id. If the client id is not specified, a new one will be generated. This value (whether specified or generated) is included in the response. - * @param availability Whether the controller service is available on the NCM only (ncm) or on the nodes only (node). If this instance is not clustered all services should use the node - * availability. + * @param version The revision is used to verify the client is working with + * the latest version of the flow. + * @param clientId Optional client id. If the client id is not specified, a + * new one will be generated. This value (whether specified or generated) is + * included in the response. + * @param availability Whether the controller service is available on the + * NCM only (ncm) or on the nodes only (node). If this instance is not + * clustered all services should use the node availability. * @param id The id of the controller service to remove. * @return A entity containing the client id and an updated revision. */ @DELETE + @Consumes(MediaType.WILDCARD) @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) @Path("/{availability}/{id}") @PreAuthorize("hasRole('ROLE_DFM')") @TypeHint(ControllerServiceEntity.class) + @ApiOperation( + value = "Deletes a controller service", + response = ControllerServiceEntity.class, + authorizations = { + @Authorization(value = "Data Flow Manager", type = "ROLE_DFM") + } + ) + @ApiResponses( + value = { + @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), + @ApiResponse(code = 401, message = "Client could not be authenticated."), + @ApiResponse(code = 403, message = "Client is not authorized to make this request."), + @ApiResponse(code = 404, message = "The specified resource could not be found."), + @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") + } + ) public Response removeControllerService( @Context HttpServletRequest httpServletRequest, + @ApiParam( + value = "The revision is used to verify the client is working with the latest version of the flow.", + required = false + ) @QueryParam(VERSION) LongParameter version, + @ApiParam( + value = "If the client id is not specified, new one will be generated. This value (whether specified or generated) is included in the response.", + required = false + ) @QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId, - @PathParam("availability") String availability, @PathParam("id") String id) { + @ApiParam( + value = "Whether the controller is available on the NCM or nodes. If the NiFi is standalone the availability should be NODE.", + allowableValues = "NCM, NODE", + required = true + ) + @PathParam("availability") String availability, + @ApiParam( + value = "The controller service id.", + required = true + ) + @PathParam("id") String id) { final Availability avail = parseAvailability(availability);
http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9bdc752a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FunnelResource.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FunnelResource.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FunnelResource.java index 73742e7..e71218c 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FunnelResource.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FunnelResource.java @@ -17,6 +17,11 @@ package org.apache.nifi.web.api; import com.wordnik.swagger.annotations.Api; +import com.wordnik.swagger.annotations.ApiOperation; +import com.wordnik.swagger.annotations.ApiParam; +import com.wordnik.swagger.annotations.ApiResponse; +import com.wordnik.swagger.annotations.ApiResponses; +import com.wordnik.swagger.annotations.Authorization; import java.net.URI; import java.net.URISyntaxException; import java.util.HashMap; @@ -97,14 +102,40 @@ public class FunnelResource extends ApplicationResource { /** * Retrieves all the of funnels in this NiFi. * - * @param clientId Optional client id. If the client id is not specified, a new one will be generated. This value (whether specified or generated) is included in the response. + * @param clientId Optional client id. If the client id is not specified, a + * new one will be generated. This value (whether specified or generated) is + * included in the response. * @return A funnelsEntity. */ @GET + @Consumes(MediaType.WILDCARD) @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Path("") // necessary due to bug in swagger @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')") @TypeHint(FunnelsEntity.class) - public Response getFunnels(@QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId) { + @ApiOperation( + value = "Gets all funnels", + response = FunnelsEntity.class, + authorizations = { + @Authorization(value = "Read Only", type = "ROLE_MONITOR"), + @Authorization(value = "Data Flow Manager", type = "ROLE_DFM"), + @Authorization(value = "Administrator", type = "ROLE_ADMIN") + } + ) + @ApiResponses( + value = { + @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), + @ApiResponse(code = 401, message = "Client could not be authenticated."), + @ApiResponse(code = 403, message = "Client is not authorized to make this request."), + @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") + } + ) + public Response getFunnels( + @ApiParam( + value = "If the client id is not specified, new one will be generated. This value (whether specified or generated) is included in the response.", + required = false + ) + @QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId) { // replicate if cluster manager if (properties.isClusterManager()) { @@ -131,8 +162,11 @@ public class FunnelResource extends ApplicationResource { * Creates a new funnel. * * @param httpServletRequest request - * @param version The revision is used to verify the client is working with the latest version of the flow. - * @param clientId Optional client id. If the client id is not specified, a new one will be generated. This value (whether specified or generated) is included in the response. + * @param version The revision is used to verify the client is working with + * the latest version of the flow. + * @param clientId Optional client id. If the client id is not specified, a + * new one will be generated. This value (whether specified or generated) is + * included in the response. * @param x The x coordinate for this funnels position. * @param y The y coordinate for this funnels position. * @return A funnelEntity. @@ -140,6 +174,7 @@ public class FunnelResource extends ApplicationResource { @POST @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Path("") // necessary due to bug in swagger @PreAuthorize("hasRole('ROLE_DFM')") @TypeHint(FunnelEntity.class) public Response createFunnel( @@ -183,11 +218,30 @@ public class FunnelResource extends ApplicationResource { @POST @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Path("") // necessary due to bug in swagger @PreAuthorize("hasRole('ROLE_DFM')") @TypeHint(FunnelEntity.class) + @ApiOperation( + value = "Creates a funnel", + response = FunnelEntity.class, + authorizations = { + @Authorization(value = "Data Flow Manager", type = "ROLE_DFM") + } + ) + @ApiResponses( + value = { + @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), + @ApiResponse(code = 401, message = "Client could not be authenticated."), + @ApiResponse(code = 403, message = "Client is not authorized to make this request."), + @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") + } + ) public Response createFunnel( @Context HttpServletRequest httpServletRequest, - FunnelEntity funnelEntity) { + @ApiParam( + value = "The funnel configuration details.", + required = true + ) FunnelEntity funnelEntity) { if (funnelEntity == null || funnelEntity.getFunnel() == null) { throw new IllegalArgumentException("Funnel details must be specified."); @@ -256,16 +310,47 @@ public class FunnelResource extends ApplicationResource { /** * Retrieves the specified funnel. * - * @param clientId Optional client id. If the client id is not specified, a new one will be generated. This value (whether specified or generated) is included in the response. + * @param clientId Optional client id. If the client id is not specified, a + * new one will be generated. This value (whether specified or generated) is + * included in the response. * @param id The id of the funnel to retrieve * @return A funnelEntity. */ @GET + @Consumes(MediaType.WILDCARD) @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) @Path("{id}") @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')") @TypeHint(FunnelEntity.class) - public Response getFunnel(@QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId, @PathParam("id") String id) { + @ApiOperation( + value = "Gets a funnel", + response = FunnelEntity.class, + authorizations = { + @Authorization(value = "Read Only", type = "ROLE_MONITOR"), + @Authorization(value = "Data Flow Manager", type = "ROLE_DFM"), + @Authorization(value = "Administrator", type = "ROLE_ADMIN") + } + ) + @ApiResponses( + value = { + @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), + @ApiResponse(code = 401, message = "Client could not be authenticated."), + @ApiResponse(code = 403, message = "Client is not authorized to make this request."), + @ApiResponse(code = 404, message = "The specified resource could not be found."), + @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") + } + ) + public Response getFunnel( + @ApiParam( + value = "If the client id is not specified, new one will be generated. This value (whether specified or generated) is included in the response.", + required = false + ) + @QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId, + @ApiParam( + value = "The funnel id.", + required = true + ) + @PathParam("id") String id) { // replicate if cluster manager if (properties.isClusterManager()) { @@ -291,8 +376,11 @@ public class FunnelResource extends ApplicationResource { * Updates the specified funnel. * * @param httpServletRequest request - * @param version The revision is used to verify the client is working with the latest version of the flow. - * @param clientId Optional client id. If the client id is not specified, a new one will be generated. This value (whether specified or generated) is included in the response. + * @param version The revision is used to verify the client is working with + * the latest version of the flow. + * @param clientId Optional client id. If the client id is not specified, a + * new one will be generated. This value (whether specified or generated) is + * included in the response. * @param id The id of the funnel to update. * @param parentGroupId The id of the process group to move this funnel to. * @param x The x coordinate for this funnels position. @@ -353,10 +441,33 @@ public class FunnelResource extends ApplicationResource { @Path("{id}") @PreAuthorize("hasRole('ROLE_DFM')") @TypeHint(FunnelEntity.class) + @ApiOperation( + value = "Updates a funnel", + response = FunnelEntity.class, + authorizations = { + @Authorization(value = "Data Flow Manager", type = "ROLE_DFM") + } + ) + @ApiResponses( + value = { + @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), + @ApiResponse(code = 401, message = "Client could not be authenticated."), + @ApiResponse(code = 403, message = "Client is not authorized to make this request."), + @ApiResponse(code = 404, message = "The specified resource could not be found."), + @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") + } + ) public Response updateFunnel( @Context HttpServletRequest httpServletRequest, + @ApiParam( + value = "The funnel id.", + required = true + ) @PathParam("id") String id, - FunnelEntity funnelEntity) { + @ApiParam( + value = "The funnel configuration details.", + required = true + ) FunnelEntity funnelEntity) { if (funnelEntity == null || funnelEntity.getFunnel() == null) { throw new IllegalArgumentException("Funnel details must be specified."); @@ -415,20 +526,52 @@ public class FunnelResource extends ApplicationResource { * Removes the specified funnel. * * @param httpServletRequest request - * @param version The revision is used to verify the client is working with the latest version of the flow. - * @param clientId Optional client id. If the client id is not specified, a new one will be generated. This value (whether specified or generated) is included in the response. + * @param version The revision is used to verify the client is working with + * the latest version of the flow. + * @param clientId Optional client id. If the client id is not specified, a + * new one will be generated. This value (whether specified or generated) is + * included in the response. * @param id The id of the funnel to remove. * @return A entity containing the client id and an updated revision. */ @DELETE + @Consumes(MediaType.WILDCARD) @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) @Path("{id}") @PreAuthorize("hasRole('ROLE_DFM')") @TypeHint(FunnelEntity.class) + @ApiOperation( + value = "Deletes a funnel", + response = FunnelEntity.class, + authorizations = { + @Authorization(value = "Data Flow Manager", type = "ROLE_DFM") + } + ) + @ApiResponses( + value = { + @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), + @ApiResponse(code = 401, message = "Client could not be authenticated."), + @ApiResponse(code = 403, message = "Client is not authorized to make this request."), + @ApiResponse(code = 404, message = "The specified resource could not be found."), + @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") + } + ) public Response removeFunnel( @Context HttpServletRequest httpServletRequest, + @ApiParam( + value = "The revision is used to verify the client is working with the latest version of the flow.", + required = false + ) @QueryParam(VERSION) LongParameter version, + @ApiParam( + value = "If the client id is not specified, new one will be generated. This value (whether specified or generated) is included in the response.", + required = false + ) @QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId, + @ApiParam( + value = "The funnel id.", + required = true + ) @PathParam("id") String id) { // replicate if cluster manager http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/9bdc752a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/InputPortResource.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/InputPortResource.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/InputPortResource.java index 4c6b313..ec5a83c 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/InputPortResource.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/InputPortResource.java @@ -17,6 +17,11 @@ package org.apache.nifi.web.api; import com.wordnik.swagger.annotations.Api; +import com.wordnik.swagger.annotations.ApiOperation; +import com.wordnik.swagger.annotations.ApiParam; +import com.wordnik.swagger.annotations.ApiResponse; +import com.wordnik.swagger.annotations.ApiResponses; +import com.wordnik.swagger.annotations.Authorization; import java.net.URI; import java.net.URISyntaxException; import java.util.HashMap; @@ -103,10 +108,34 @@ public class InputPortResource extends ApplicationResource { * @return A inputPortsEntity. */ @GET + @Consumes(MediaType.WILDCARD) @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Path("") // necessary due to bug in swagger @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')") @TypeHint(InputPortsEntity.class) - public Response getInputPorts(@QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId) { + @ApiOperation( + value = "Gets all input ports", + response = InputPortsEntity.class, + authorizations = { + @Authorization(value = "Read Only", type = "ROLE_MONITOR"), + @Authorization(value = "Data Flow Manager", type = "ROLE_DFM"), + @Authorization(value = "Administrator", type = "ROLE_ADMIN") + } + ) + @ApiResponses( + value = { + @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), + @ApiResponse(code = 401, message = "Client could not be authenticated."), + @ApiResponse(code = 403, message = "Client is not authorized to make this request."), + @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") + } + ) + public Response getInputPorts( + @ApiParam( + value = "If the client id is not specified, new one will be generated. This value (whether specified or generated) is included in the response.", + required = false + ) + @QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId) { // replicate if cluster manager if (properties.isClusterManager()) { @@ -143,6 +172,7 @@ public class InputPortResource extends ApplicationResource { @POST @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Path("") // necessary due to bug in swagger @PreAuthorize("hasRole('ROLE_DFM')") @TypeHint(InputPortEntity.class) public Response createInputPort( @@ -189,11 +219,30 @@ public class InputPortResource extends ApplicationResource { @POST @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Path("") // necessary due to bug in swagger @PreAuthorize("hasRole('ROLE_DFM')") @TypeHint(InputPortEntity.class) + @ApiOperation( + value = "Creates an input port", + response = InputPortEntity.class, + authorizations = { + @Authorization(value = "Data Flow Manager", type = "ROLE_DFM") + } + ) + @ApiResponses( + value = { + @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), + @ApiResponse(code = 401, message = "Client could not be authenticated."), + @ApiResponse(code = 403, message = "Client is not authorized to make this request."), + @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") + } + ) public Response createInputPort( @Context HttpServletRequest httpServletRequest, - InputPortEntity portEntity) { + @ApiParam( + value = "The input port configuration details.", + required = true + ) InputPortEntity portEntity) { if (portEntity == null || portEntity.getInputPort() == null) { throw new IllegalArgumentException("Port details must be specified."); @@ -268,11 +317,40 @@ public class InputPortResource extends ApplicationResource { * @return A inputPortEntity. */ @GET + @Consumes(MediaType.WILDCARD) @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) @Path("{id}") @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')") @TypeHint(InputPortEntity.class) - public Response getInputPort(@QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId, @PathParam("id") String id) { + @ApiOperation( + value = "Getrs an input port", + response = InputPortEntity.class, + authorizations = { + @Authorization(value = "Read Only", type = "ROLE_MONITOR"), + @Authorization(value = "Data Flow Manager", type = "ROLE_DFM"), + @Authorization(value = "Administrator", type = "ROLE_ADMIN") + } + ) + @ApiResponses( + value = { + @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), + @ApiResponse(code = 401, message = "Client could not be authenticated."), + @ApiResponse(code = 403, message = "Client is not authorized to make this request."), + @ApiResponse(code = 404, message = "The specified resource could not be found."), + @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") + } + ) + public Response getInputPort( + @ApiParam( + value = "If the client id is not specified, new one will be generated. This value (whether specified or generated) is included in the response.", + required = false + ) + @QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId, + @ApiParam( + value = "The input port id.", + required = true + ) + @PathParam("id") String id) { // replicate if cluster manager if (properties.isClusterManager()) { @@ -389,10 +467,33 @@ public class InputPortResource extends ApplicationResource { @Path("{id}") @PreAuthorize("hasRole('ROLE_DFM')") @TypeHint(InputPortEntity.class) + @ApiOperation( + value = "Updates an input port", + response = InputPortEntity.class, + authorizations = { + @Authorization(value = "Data Flow Manager", type = "ROLE_DFM") + } + ) + @ApiResponses( + value = { + @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), + @ApiResponse(code = 401, message = "Client could not be authenticated."), + @ApiResponse(code = 403, message = "Client is not authorized to make this request."), + @ApiResponse(code = 404, message = "The specified resource could not be found."), + @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") + } + ) public Response updateInputPort( @Context HttpServletRequest httpServletRequest, + @ApiParam( + value = "The input port id.", + required = true + ) @PathParam("id") String id, - InputPortEntity portEntity) { + @ApiParam( + value = "The input port configuration details.", + required = true + ) InputPortEntity portEntity) { if (portEntity == null || portEntity.getInputPort() == null) { throw new IllegalArgumentException("Input port details must be specified."); @@ -458,14 +559,43 @@ public class InputPortResource extends ApplicationResource { * @return A inputPortEntity. */ @DELETE + @Consumes(MediaType.WILDCARD) @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) @Path("{id}") @PreAuthorize("hasRole('ROLE_DFM')") @TypeHint(InputPortEntity.class) + @ApiOperation( + value = "Deletes an input port", + response = InputPortEntity.class, + authorizations = { + @Authorization(value = "Data Flow Manager", type = "ROLE_DFM") + } + ) + @ApiResponses( + value = { + @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), + @ApiResponse(code = 401, message = "Client could not be authenticated."), + @ApiResponse(code = 403, message = "Client is not authorized to make this request."), + @ApiResponse(code = 404, message = "The specified resource could not be found."), + @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") + } + ) public Response removeInputPort( @Context HttpServletRequest httpServletRequest, + @ApiParam( + value = "The revision is used to verify the client is working with the latest version of the flow.", + required = false + ) @QueryParam(VERSION) LongParameter version, + @ApiParam( + value = "If the client id is not specified, new one will be generated. This value (whether specified or generated) is included in the response.", + required = false + ) @QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId, + @ApiParam( + value = "The input port id.", + required = true + ) @PathParam("id") String id) { // replicate if cluster manager
