Update the license for 2017-2018 license
[aai/aai-common.git] / aai-core / src / main / java / org / onap / aai / util / swagger / Api.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *    http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20 package org.onap.aai.util.swagger;
21
22 import java.util.List;
23 import java.util.Map;
24
25 public class Api {
26
27     private String path;
28
29     private List<HttpVerb> httpMethods;
30
31     private String tag;
32
33     public List<HttpVerb> getHttpMethods() {
34         return httpMethods;
35     }
36
37     public void setHttpMethods(List<HttpVerb> httpMethods) {
38         this.httpMethods = httpMethods;
39     }
40
41     public String getTag(){
42
43         if(this.tag != null){
44             return this.tag;
45         }
46
47         if(this.httpMethods != null){
48             if(this.httpMethods.size() != 0){
49                 if(this.httpMethods.get(0).getTags() != null){
50                     if(this.httpMethods.get(0).getTags().size() != 0){
51                         this.tag = this.httpMethods.get(0).getTags().get(0);
52                     }
53                 }
54             }
55         }
56
57         if(this.tag == null){
58             this.tag = "";
59         }
60
61         return this.tag;
62     }
63
64     @Override
65     public String toString() {
66         return "Api{" +
67                 "path='" + path + '\'' +
68                 ", httpMethods=" + httpMethods +
69                 '}';
70     }
71
72     public void setPath(String path) {
73         this.path = path;
74     }
75
76     public String getPath() {
77         return this.path;
78     }
79
80     public String getOperation(){
81
82         if(this.path != null){
83             return this.path.replaceAll("[^a-zA-Z0-9\\-]", "-") + "-";
84         }
85
86         return "";
87     }
88
89     public static class HttpVerb {
90
91         private List<String> tags;
92
93         private String type;
94
95         private String summary;
96
97         private String operationId;
98
99         private List<String> consumes;
100
101         private boolean consumerEnabled;
102
103         private List<String> produces;
104
105         private List<Response> responses;
106
107         private List<Map<String, Object>> parameters;
108
109         private Map<String, Object> bodyParameters;
110
111         private boolean bodyParametersEnabled;
112
113         private boolean parametersEnabled;
114
115         private String schemaLink;
116
117         private String schemaType;
118
119         private boolean hasReturnSchema;
120
121         private String returnSchemaLink;
122
123         private String returnSchemaObject;
124
125         public void setConsumerEnabled(boolean consumerEnabled){
126             this.consumerEnabled = consumerEnabled;
127         }
128
129         public boolean isConsumerEnabled() {
130             return consumerEnabled;
131         }
132
133
134         public List<String> getTags() {
135             return tags;
136         }
137
138         public void setTags(List<String> tags) {
139             this.tags = tags;
140         }
141
142         public String getType() {
143             return type;
144         }
145
146         public void setType(String type) {
147             this.type = type;
148         }
149
150         public String getSummary() {
151             return summary;
152         }
153
154         public void setSummary(String summary) {
155             this.summary = summary;
156         }
157
158         public String getOperationId() {
159             return operationId;
160         }
161
162         public void setOperationId(String operationId) {
163             this.operationId = operationId;
164         }
165
166         public List<String> getConsumes() {
167             return consumes;
168         }
169
170         public void setConsumes(List<String> consumes) {
171             this.consumes = consumes;
172         }
173
174         public List<String> getProduces() {
175             return produces;
176         }
177
178         public void setProduces(List<String> produces) {
179             this.produces = produces;
180         }
181
182         public List<Response> getResponses() {
183             return responses;
184         }
185
186         public void setResponses(List<Response> responses) {
187             this.responses = responses;
188         }
189
190         public List<Map<String, Object>> getParameters() {
191             return parameters;
192         }
193
194         public void setParameters(List<Map<String, Object>> parameters) {
195             this.parameters = parameters;
196         }
197
198         @Override
199         public String toString() {
200             return "HttpVerb{" +
201                     "tags=" + tags +
202                     ", type='" + type + '\'' +
203                     ", summary='" + summary + '\'' +
204                     ", operationId='" + operationId + '\'' +
205                     ", consumes=" + consumes +
206                     ", produces=" + produces +
207                     ", responses=" + responses +
208                     ", parameters=" + parameters +
209                     '}';
210         }
211
212         public void setParametersEnabled(boolean b) {
213             this.parametersEnabled = b;
214         }
215
216         public boolean isParametersEnabled() {
217             return parametersEnabled;
218         }
219
220         public boolean isBodyParametersEnabled() {
221             return bodyParametersEnabled;
222         }
223
224         public void setBodyParametersEnabled(boolean bodyParametersEnabled) {
225             this.bodyParametersEnabled = bodyParametersEnabled;
226         }
227
228         public Map<String, Object> getBodyParameters() {
229             return bodyParameters;
230         }
231
232         public void setBodyParameters(Map<String, Object> bodyParameters) {
233             this.bodyParameters = bodyParameters;
234         }
235
236         public String getSchemaLink() {
237             return schemaLink;
238         }
239
240         public void setSchemaLink(String schemaLink) {
241             this.schemaLink = schemaLink;
242         }
243
244         public String getSchemaType() {
245             return schemaType;
246         }
247
248         public void setSchemaType(String schemaType) {
249             this.schemaType = schemaType;
250         }
251
252         public boolean isHasReturnSchema() {
253             return hasReturnSchema;
254         }
255
256         public void setHasReturnSchema(boolean hasReturnSchema) {
257             this.hasReturnSchema = hasReturnSchema;
258         }
259
260         public String getReturnSchemaLink() {
261             return returnSchemaLink;
262         }
263
264         public void setReturnSchemaLink(String returnSchemaLink) {
265             this.returnSchemaLink = returnSchemaLink;
266         }
267
268         public String getReturnSchemaObject() {
269             return returnSchemaObject;
270         }
271
272         public void setReturnSchemaObject(String returnSchemaObject) {
273             this.returnSchemaObject = returnSchemaObject;
274         }
275
276         public static class Response {
277
278             private String responseCode;
279
280             private String description;
281
282             public String getResponseCode() {
283                 return responseCode;
284             }
285
286             public void setResponseCode(String responseCode) {
287                 this.responseCode = responseCode;
288             }
289
290             public String getDescription() {
291                 return description;
292             }
293
294             public void setDescription(String description) {
295                 this.description = description;
296             }
297
298             @Override
299             public String toString() {
300                 return "Response{" +
301                         "responseCode='" + responseCode + '\'' +
302                         ", description='" + description + '\'' +
303                         '}';
304             }
305         }
306
307     }
308
309 }