001    /*
002     *  Licensed to the Apache Software Foundation (ASF) under one
003     *  or more contributor license agreements.  See the NOTICE file
004     *  distributed with this work for additional information
005     *  regarding copyright ownership.  The ASF licenses this file
006     *  to you under the Apache License, Version 2.0 (the
007     *  "License"); you may not use this file except in compliance
008     *  with the License.  You may obtain a copy of the License at
009     *
010     *        http://www.apache.org/licenses/LICENSE-2.0
011     *
012     *  Unless required by applicable law or agreed to in writing,
013     *  software distributed under the License is distributed on an
014     *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015     *  KIND, either express or implied.  See the License for the
016     *  specific language governing permissions and limitations
017     *  under the License.
018     */
019    package org.apache.isis.viewer.restfulobjects.domainobjects;
020    
021    import java.io.InputStream;
022    
023    import javax.ws.rs.Consumes;
024    import javax.ws.rs.GET;
025    import javax.ws.rs.POST;
026    import javax.ws.rs.PUT;
027    import javax.ws.rs.Path;
028    import javax.ws.rs.PathParam;
029    import javax.ws.rs.Produces;
030    import javax.ws.rs.core.MediaType;
031    import javax.ws.rs.core.Response;
032    
033    import org.jboss.resteasy.annotations.ClientResponseType;
034    
035    import org.apache.isis.viewer.restfulobjects.applib.RestfulMediaType;
036    
037    @Path("/services")
038    public interface DomainServiceResource {
039    
040        @GET
041        @Path("/")
042        @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_LIST, RestfulMediaType.APPLICATION_JSON_ERROR })
043        @ClientResponseType(entityType = String.class)
044        public Response services();
045    
046        // //////////////////////////////////////////////////////////
047        // domain service
048        // //////////////////////////////////////////////////////////
049    
050        @GET
051        @Path("/{serviceId}")
052        @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_DOMAIN_OBJECT, RestfulMediaType.APPLICATION_JSON_ERROR })
053        @ClientResponseType(entityType = String.class)
054        public Response service(@PathParam("serviceId") final String serviceId);
055    
056        // //////////////////////////////////////////////////////////
057        // domain service property
058        // //////////////////////////////////////////////////////////
059    
060        @GET
061        @Path("/{serviceId}/properties/{propertyId}")
062        @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_OBJECT_PROPERTY, RestfulMediaType.APPLICATION_JSON_ERROR })
063        public Response propertyDetails(@PathParam("serviceId") final String serviceId, @PathParam("propertyId") final String propertyId);
064    
065        // //////////////////////////////////////////////////////////
066        // domain service action
067        // //////////////////////////////////////////////////////////
068    
069        @GET
070        @Path("/{serviceId}/actions/{actionId}")
071        @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_OBJECT_ACTION, RestfulMediaType.APPLICATION_JSON_ERROR })
072        @ClientResponseType(entityType = String.class)
073        public Response actionPrompt(@PathParam("serviceId") final String serviceId, @PathParam("actionId") final String actionId);
074    
075        // //////////////////////////////////////////////////////////
076        // domain service action invoke
077        // //////////////////////////////////////////////////////////
078    
079        @GET
080        @Path("/{serviceId}/actions/{actionId}/invoke")
081        @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ACTION_RESULT, RestfulMediaType.APPLICATION_JSON_ERROR })
082        @ClientResponseType(entityType = String.class)
083        public Response invokeActionQueryOnly(@PathParam("serviceId") final String serviceId, @PathParam("actionId") final String actionId);
084    
085        @PUT
086        @Path("/{serviceId}/actions/{actionId}/invoke")
087        @Consumes({ MediaType.APPLICATION_JSON })
088        @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ACTION_RESULT, RestfulMediaType.APPLICATION_JSON_ERROR })
089        @ClientResponseType(entityType = String.class)
090        public Response invokeActionIdempotent(@PathParam("serviceId") final String serviceId, @PathParam("actionId") final String actionId, final InputStream arguments);
091    
092        @POST
093        @Path("/{serviceId}/actions/{actionId}/invoke")
094        @Consumes({ MediaType.APPLICATION_JSON })
095        @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ACTION_RESULT, RestfulMediaType.APPLICATION_JSON_ERROR })
096        @ClientResponseType(entityType = String.class)
097        public Response invokeAction(@PathParam("serviceId") final String serviceId, @PathParam("actionId") final String actionId, final InputStream arguments);
098    }