2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.restconf.nb.rfc8040.rests.services.impl;
10 import static java.util.Objects.requireNonNull;
12 import javax.ws.rs.GET;
13 import javax.ws.rs.Path;
14 import javax.ws.rs.PathParam;
15 import javax.ws.rs.Produces;
16 import javax.ws.rs.core.MediaType;
17 import org.opendaylight.restconf.nb.rfc8040.MediaTypes;
18 import org.opendaylight.restconf.nb.rfc8040.databind.DatabindProvider;
19 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
22 * Container that provides access to the data-model specific operations supported by the server.
25 public final class RestconfOperationsServiceImpl {
26 private final MdsalRestconfServer server;
29 * Set {@link DatabindProvider} for getting actual {@link EffectiveModelContext}.
31 * @param server a {@link MdsalRestconfServer}
33 public RestconfOperationsServiceImpl(final MdsalRestconfServer server) {
34 this.server = requireNonNull(server);
38 * List RPC and action operations in RFC7951 format.
40 * @return A string containing a JSON document conforming to both RFC8040 and RFC7951.
44 @Produces({ MediaTypes.APPLICATION_YANG_DATA_JSON, MediaType.APPLICATION_JSON })
45 public String getOperationsJSON() {
46 return OperationsContent.JSON.bodyFor(server.bindRequestRoot().inference());
50 * Retrieve list of operations and actions supported by the server or device in JSON format.
52 * @param identifier path parameter to identify device and/or operation
53 * @return A string containing a JSON document conforming to both RFC8040 and RFC7951.
56 @Path("/operations/{identifier:.+}")
57 @Produces({ MediaTypes.APPLICATION_YANG_DATA_JSON, MediaType.APPLICATION_JSON })
58 public String getOperationJSON(@PathParam("identifier") final String identifier) {
59 return OperationsContent.JSON.bodyFor(server.bindRequestPath(identifier).inference());
63 * List RPC and action operations in RFC8040 XML format.
65 * @return A string containing an XML document conforming to both RFC8040 section 11.3.1 and page 84.
69 @Produces({ MediaTypes.APPLICATION_YANG_DATA_XML, MediaType.APPLICATION_XML, MediaType.TEXT_XML })
70 public String getOperationsXML() {
71 return OperationsContent.XML.bodyFor(server.bindRequestRoot().inference());
75 * Retrieve list of operations and actions supported by the server or device in XML format.
77 * @param identifier path parameter to identify device and/or operation
78 * @return A string containing an XML document conforming to both RFC8040 section 11.3.1 and page 84.
81 @Path("/operations/{identifier:.+}")
82 @Produces({ MediaTypes.APPLICATION_YANG_DATA_XML, MediaType.APPLICATION_XML, MediaType.TEXT_XML })
83 public String getOperationXML(@PathParam("identifier") final String identifier) {
84 return OperationsContent.XML.bodyFor(server.bindRequestPath(identifier).inference());