2 * Copyright (c) 2024 PANTHEON.tech, s.r.o. 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.server.spi;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.base.MoreObjects.ToStringHelper;
13 import java.io.IOException;
14 import java.io.Writer;
15 import org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
18 final class OneOperation extends OperationsBody {
19 private final QName rpc;
21 OneOperation(final EffectiveModelContext modelContext, final QName rpc) {
23 this.rpc = requireNonNull(rpc);
27 void formatToJSON(final Writer out) throws IOException {
28 // https://www.rfc-editor.org/rfc/rfc8040#page-84:
30 // In JSON, the YANG module name identifies the module:
32 // { 'ietf-system:system-restart' : [null] }
34 appendJSON(out, jsonPrefix(rpc.getModule()), rpc);
39 void formatToXML(final Writer out) throws IOException {
40 // https://www.rfc-editor.org/rfc/rfc8040#page-84:
42 // In XML, the YANG module namespace identifies the module:
45 // xmlns='urn:ietf:params:xml:ns:yang:ietf-system'/>
50 protected ToStringHelper addToStringAttributes(final ToStringHelper helper) {
51 return helper.add("rpc", rpc);