c161828050cd1747c9fc16c4481e764dc3320388
[netconf.git] / restconf / restconf-openapi / src / main / java / org / opendaylight / restconf / openapi / model / Operation.java
1 /*
2  * Copyright (c) 2023 PANTHEON.tech s.r.o 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.openapi.model;
9
10 import com.fasterxml.jackson.annotation.JsonInclude;
11 import com.fasterxml.jackson.databind.node.ArrayNode;
12 import com.fasterxml.jackson.databind.node.ObjectNode;
13 import java.util.List;
14
15 @JsonInclude(JsonInclude.Include.NON_NULL)
16 public record Operation(boolean deprecated, List<String> tags, List<Parameter> parameters, ArrayNode security,
17         ArrayNode servers, ObjectNode callbacks, ObjectNode externalDocs, ObjectNode requestBody,
18         ObjectNode responses, String description, String operationId, String summary) {
19
20     private Operation(final Builder builder) {
21         this(builder.deprecated, builder.tags, builder.parameters, builder.security, builder.servers, builder.callbacks,
22             builder.externalDocs, builder.requestBody, builder.responses, builder.description, builder.operationId,
23             builder.summary);
24     }
25
26     @SuppressWarnings("checkstyle:hiddenField")
27     public static class Builder {
28         private boolean deprecated;
29         private List<String> tags;
30         private List<Parameter> parameters;
31         private ArrayNode security;
32         private ArrayNode servers;
33         private ObjectNode callbacks;
34         private ObjectNode externalDocs;
35         private ObjectNode requestBody;
36         private ObjectNode responses;
37         private String description;
38         private String operationId;
39         private String summary;
40
41         public Builder deprecated(final boolean deprecated) {
42             this.deprecated = deprecated;
43             return this;
44         }
45
46         public Builder tags(final List<String> tags) {
47             this.tags = tags;
48             return this;
49         }
50
51         public Builder parameters(final List<Parameter> parameters) {
52             this.parameters = parameters;
53             return this;
54         }
55
56         public Builder security(final ArrayNode security) {
57             this.security = security;
58             return this;
59         }
60
61         public Builder servers(final ArrayNode servers) {
62             this.servers = servers;
63             return this;
64         }
65
66         public Builder callbacks(final ObjectNode callbacks) {
67             this.callbacks = callbacks;
68             return this;
69         }
70
71         public Builder externalDocs(final ObjectNode externalDocs) {
72             this.externalDocs = externalDocs;
73             return this;
74         }
75
76         public Builder requestBody(final ObjectNode requestBody) {
77             this.requestBody = requestBody;
78             return this;
79         }
80
81         public Builder responses(final ObjectNode responses) {
82             this.responses = responses;
83             return this;
84         }
85
86         public Builder description(final String description) {
87             this.description = description;
88             return this;
89         }
90
91         public Builder operationId(final String operationId) {
92             this.operationId = operationId;
93             return this;
94         }
95
96         public Builder summary(final String summary) {
97             this.summary = summary;
98             return this;
99         }
100
101         public Operation build() {
102             return new Operation(this);
103         }
104     }
105 }