1b5cdf31f086f093d1cf7f176df71c041b045c5c
[netconf.git] / restconf / restconf-nb-bierman02 / src / main / java / org / opendaylight / restconf / restful / utils / RestconfDataServiceConstant.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.restful.utils;
9
10 import java.net.URI;
11 import java.net.URISyntaxException;
12 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
13 import org.opendaylight.restconf.common.errors.RestconfError.ErrorTag;
14 import org.opendaylight.restconf.common.errors.RestconfError.ErrorType;
15 import org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.common.QNameModule;
17
18 /**
19  * Constants for RestconfDataService.
20  *
21  */
22 public final class RestconfDataServiceConstant {
23
24     public static final QName NETCONF_BASE_QNAME;
25
26     static {
27         try {
28             NETCONF_BASE_QNAME = QName.create(
29                     QNameModule.create(new URI(PutData.NETCONF_BASE), null), PutData.NETCONF_BASE_PAYLOAD_NAME);
30         } catch (final URISyntaxException e) {
31             final String errMsg = "It wasn't possible to create instance of URI class with " + PutData.NETCONF_BASE
32                     + " URI";
33             throw new RestconfDocumentedException(errMsg, ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED);
34         }
35     }
36
37     private RestconfDataServiceConstant() {
38         throw new UnsupportedOperationException("Util class.");
39     }
40
41     /**
42      * Constants for read data.
43      *
44      */
45     public final class ReadData {
46         // URI parameters
47         public static final String CONTENT = "content";
48         public static final String DEPTH = "depth";
49         public static final String FIELDS = "fields";
50
51         // content values
52         public static final String CONFIG = "config";
53         public static final String ALL = "all";
54         public static final String NONCONFIG = "nonconfig";
55
56         // depth values
57         public static final String UNBOUNDED = "unbounded";
58         public static final int MIN_DEPTH = 1;
59         public static final int MAX_DEPTH = 65535;
60
61         public static final String READ_TYPE_TX = "READ";
62         public static final String WITH_DEFAULTS = "with-defaults";
63
64         private ReadData() {
65             throw new UnsupportedOperationException("Util class.");
66         }
67     }
68
69     /**
70      * Constants for data to put.
71      *
72      */
73     public final class PutData {
74         public static final String NETCONF_BASE = "urn:ietf:params:xml:ns:netconf:base:1.0";
75         public static final String NETCONF_BASE_PAYLOAD_NAME = "data";
76         public static final String PUT_TX_TYPE = "PUT";
77
78         private PutData() {
79             throw new UnsupportedOperationException("Util class.");
80         }
81     }
82
83     /**
84      * Constants for data to post.
85      *
86      */
87     public final class PostData {
88         public static final String POST_TX_TYPE = "POST";
89
90         private PostData() {
91             throw new UnsupportedOperationException("Util class.");
92         }
93     }
94
95     /**
96      * Constants for data to delete.
97      *
98      */
99     public final class DeleteData {
100         public static final String DELETE_TX_TYPE = "DELETE";
101
102         private DeleteData() {
103             throw new UnsupportedOperationException("Util class.");
104         }
105     }
106
107     /**
108      * Constants for data to yang patch.
109      *
110      */
111     public final class PatchData {
112         public static final String PATCH_TX_TYPE = "Patch";
113
114         private PatchData() {
115             throw new UnsupportedOperationException("Util class.");
116         }
117     }
118 }