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