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.utils;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.collect.ImmutableMap;
13 import com.google.common.collect.Maps;
14 import java.util.Arrays;
16 import org.eclipse.jdt.annotation.NonNull;
17 import org.eclipse.jdt.annotation.Nullable;
18 import org.opendaylight.yangtools.yang.common.QName;
19 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
22 * Constants for RestconfDataService.
25 public final class RestconfDataServiceConstant {
26 public static final QName NETCONF_BASE_QNAME = SchemaContext.NAME;
28 private RestconfDataServiceConstant() {
33 * Constants for read data.
36 public static final class ReadData {
38 public static final String CONTENT = "content";
39 public static final String DEPTH = "depth";
40 public static final String FIELDS = "fields";
43 public static final String CONFIG = "config";
44 public static final String ALL = "all";
45 public static final String NONCONFIG = "nonconfig";
48 public static final String UNBOUNDED = "unbounded";
49 public static final int MIN_DEPTH = 1;
50 public static final int MAX_DEPTH = 65535;
52 public static final String WITH_DEFAULTS = "with-defaults";
55 * With-default values, as per
56 * <a href="https://tools.ietf.org/html/rfc8040#section-4.8.9">RFC8040 section 4.8.9</a>.
60 * All data nodes are reported.
62 REPORT_ALL("report-all"),
64 * Data nodes set to the YANG default are not reported.
68 * Data nodes set to the YANG default by the client are reported.
72 * All data nodes are reported, and defaults are tagged.
74 REPORT_ALL_TAGGED("report-all-tagged");
76 private static final ImmutableMap<String, WithDefaults> VALUES =
77 Maps.uniqueIndex(Arrays.asList(values()), WithDefaults::value);
79 private @NonNull String value;
81 WithDefaults(final @NonNull String value) {
85 public @NonNull String value() {
89 static @Nullable WithDefaults forValue(final String value) {
90 return VALUES.get(requireNonNull(value));
93 static @Nullable Set<String> possibleValues() {
94 return VALUES.keySet();
104 * Common for PostData and PutData.
106 public static final class PostPutQueryParameters {
107 public static final String INSERT = "insert";
108 public static final String POINT = "point";
111 * Insert values, as per <a href="https://tools.ietf.org/html/rfc8040#section-4.8.5">RFC8040 section 4.8.5</a>.
115 * Insert the new data as the new first entry.
119 * Insert the new data as the new last entry.
123 * Insert the new data before the insertion point, as specified by the value of the "point" parameter.
127 * Insert the new data after the insertion point, as specified by the value of the "point" parameter.
131 private static final ImmutableMap<String, Insert> VALUES =
132 Maps.uniqueIndex(Arrays.asList(values()), Insert::value);
134 private @NonNull String value;
136 Insert(final @NonNull String value) {
140 public @NonNull String value() {
144 public static @Nullable Insert forValue(final String value) {
145 return VALUES.get(requireNonNull(value));
149 private PostPutQueryParameters() {