2a61ee16060d8c04fcc9d4aefce7cd7061c38f93
[netconf.git] / restconf / restconf-nb-rfc8040 / src / main / java / org / opendaylight / restconf / nb / rfc8040 / Rfc8040.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;
9
10 import com.google.common.annotations.Beta;
11 import org.eclipse.jdt.annotation.NonNull;
12 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.monitoring.rev170126.RestconfState;
13 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.monitoring.rev170126.restconf.state.Streams;
14 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.monitoring.rev170126.restconf.state.streams.Stream;
15 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.$YangModuleInfoImpl;
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.module.list.Module;
17 import org.opendaylight.yangtools.yang.common.QName;
18 import org.opendaylight.yangtools.yang.common.QNameModule;
19 import org.opendaylight.yangtools.yang.common.Revision;
20 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
21 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
22 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
23
24 /**
25  * Common constants defined and relating to RFC8040.
26  */
27 public final class Rfc8040 {
28     private static final YangInstanceIdentifier RESTCONF_STATE_STREAMS = YangInstanceIdentifier.create(
29         NodeIdentifier.create(RestconfState.QNAME), NodeIdentifier.create(Streams.QNAME),
30         NodeIdentifier.create(Stream.QNAME));
31     private static final QName NAME_QNAME = QName.create(Stream.QNAME, "name").intern();
32
33     private Rfc8040() {
34         // Hidden on purpose
35     }
36
37     @Beta
38     // FIXME: move this method somewhere else
39     public static @NonNull YangInstanceIdentifier restconfStateStreamPath(final String streamName) {
40         return restconfStateStreamPath(NodeIdentifierWithPredicates.of(Stream.QNAME, NAME_QNAME, streamName));
41     }
42
43     @Beta
44     // FIXME: move this method somewhere else
45     public static @NonNull YangInstanceIdentifier restconfStateStreamPath(final NodeIdentifierWithPredicates arg) {
46         return RESTCONF_STATE_STREAMS.node(arg);
47     }
48
49     /**
50      * Constants for <a href="https://datatracker.ietf.org/doc/html/rfc8040#section-11.4">RESTCONF Capability URNs</a>.
51      */
52     public static final class Capabilities {
53         /**
54          * Support for <a href="https://datatracker.ietf.org/doc/html/rfc8040#section-4.8.2">depth</a> Query Parameter.
55          */
56         public static final String DEPTH = "urn:ietf:params:restconf:capability:depth:1.0";
57         /**
58          * Support for <a href="https://datatracker.ietf.org/doc/html/rfc8040#section-4.8.3">fields</a> Query Parameter.
59          */
60         public static final String FIELDS = "urn:ietf:params:restconf:capability:fields:1.0";
61         /**
62          * Support for <a href="https://datatracker.ietf.org/doc/html/rfc8040#section-4.8.4">filter</a> Query Parameter.
63          */
64         public static final String FILTER = "urn:ietf:params:restconf:capability:filter:1.0";
65         /**
66          * Support for <a href="https://datatracker.ietf.org/doc/html/rfc8040#section-4.8.7">start-time</a>
67          * and <a href="https://datatracker.ietf.org/doc/html/rfc8040#section-4.8.7">stop-time</a> Query Parameters.
68          */
69         public static final String REPLAY = "urn:ietf:params:restconf:capability:replay:1.0";
70         /**
71          * Support for
72          * <a href="https://datatracker.ietf.org/doc/html/rfc8040#section-4.8.9">with-defaults</a> Query Parameter.
73          */
74         public static final String WITH_DEFAULTS = "urn:ietf:params:restconf:capability:with-defaults:1.0";
75
76         private Capabilities() {
77             // Hidden on purpose
78         }
79     }
80
81     /**
82      * Constants for ietf-yang-library model.
83      */
84     // FIXME: split this out
85     public static final class IetfYangLibrary {
86         public static final QNameModule MODULE_QNAME = $YangModuleInfoImpl.getInstance().getName().getModule();
87         public static final Revision REVISION = MODULE_QNAME.getRevision().orElseThrow();
88
89         public static final QName MODULE_SET_ID_LEAF_QNAME = QName.create(MODULE_QNAME, "module-set-id").intern();
90
91         public static final QName MODULE_QNAME_LIST = Module.QNAME;
92
93         private IetfYangLibrary() {
94             // Hidden on purpose
95         }
96     }
97 }