Reduce exception guard
[netconf.git] / restconf / restconf-nb-rfc8040 / src / main / java / org / opendaylight / restconf / nb / rfc8040 / rests / services / api / RestconfInvokeOperationsService.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.restconf.nb.rfc8040.rests.services.api;
9
10 import javax.ws.rs.Consumes;
11 import javax.ws.rs.Encoded;
12 import javax.ws.rs.POST;
13 import javax.ws.rs.Path;
14 import javax.ws.rs.PathParam;
15 import javax.ws.rs.Produces;
16 import javax.ws.rs.container.AsyncResponse;
17 import javax.ws.rs.container.Suspended;
18 import javax.ws.rs.core.Context;
19 import javax.ws.rs.core.MediaType;
20 import javax.ws.rs.core.UriInfo;
21 import org.opendaylight.restconf.nb.rfc8040.MediaTypes;
22 import org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload;
23
24 /**
25  * An operation resource represents a protocol operation defined with the YANG {@code rpc} statement. It is invoked
26  * using a POST method on the operation resource.
27  */
28 public interface RestconfInvokeOperationsService {
29     /**
30      * Invoke RPC operation.
31      *
32      * @param identifier module name and rpc identifier string for the desired operation
33      * @param payload {@link NormalizedNodePayload} - the body of the operation
34      * @param uriInfo URI info
35      * @param ar {@link AsyncResponse} which needs to be completed with a {@link NormalizedNodePayload} output
36      */
37     @POST
38     @Path("/operations/{identifier:.+}")
39     @Produces({
40         MediaTypes.APPLICATION_YANG_DATA_JSON,
41         MediaTypes.APPLICATION_YANG_DATA_XML,
42         MediaType.APPLICATION_JSON,
43         MediaType.APPLICATION_XML,
44         MediaType.TEXT_XML
45     })
46     @Consumes({
47         MediaTypes.APPLICATION_YANG_DATA_JSON,
48         MediaTypes.APPLICATION_YANG_DATA_XML,
49         MediaType.APPLICATION_JSON,
50         MediaType.APPLICATION_XML,
51         MediaType.TEXT_XML
52     })
53     void invokeRpc(@Encoded @PathParam("identifier") String identifier, NormalizedNodePayload payload,
54         @Context UriInfo uriInfo, @Suspended AsyncResponse ar);
55 }