OpenAPI: Delete no-op methods
[netconf.git] / restconf / restconf-openapi / src / main / java / org / opendaylight / restconf / openapi / model / DeleteEntity.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 static java.util.Objects.requireNonNull;
11 import static javax.ws.rs.core.Response.Status.NO_CONTENT;
12
13 import com.fasterxml.jackson.core.JsonGenerator;
14 import java.io.IOException;
15 import java.util.List;
16 import javax.ws.rs.HttpMethod;
17 import org.eclipse.jdt.annotation.NonNull;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
20
21 public final class DeleteEntity extends OperationEntity {
22
23     public DeleteEntity(final @NonNull SchemaNode schema, final @NonNull String deviceName,
24             final @NonNull String moduleName, final @NonNull List<ParameterEntity> parameters,
25             final @Nullable String refPath) {
26         super(requireNonNull(schema), deviceName, moduleName, requireNonNull(parameters), refPath);
27     }
28
29     @Override
30     protected @NonNull String operation() {
31         return "delete";
32     }
33
34     @Override
35     @NonNull String summary() {
36         return SUMMARY_TEMPLATE.formatted(HttpMethod.DELETE, deviceName(), moduleName(), nodeName());
37     }
38
39     @Override
40     void generateRequestBody(@NonNull JsonGenerator generator) throws IOException {
41         // no-op
42     }
43
44     @Override
45     void generateResponses(final @NonNull JsonGenerator generator) throws IOException {
46         generator.writeObjectFieldStart(RESPONSES);
47         generator.writeObjectFieldStart(String.valueOf(NO_CONTENT.getStatusCode()));
48         generator.writeStringField(DESCRIPTION, "Deleted");
49         generator.writeEndObject();
50         generator.writeEndObject();
51     }
52 }