Add ApiPath.empty()
[netconf.git] / restconf / restconf-nb / src / main / java / org / opendaylight / restconf / server / api / DataYangPatchParams.java
1 /*
2  * Copyright (c) 2024 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.server.api;
9
10 import static java.util.Objects.requireNonNull;
11
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.opendaylight.restconf.api.FormatParameters;
14 import org.opendaylight.restconf.api.query.PrettyPrintParam;
15
16 /**
17  * Supported query parameters of {@code PATCH} HTTP operation when the request is to invoke a YANG Patch operation.
18  * There is no such thing in RFC8073, but we support pretty-printing of the resulting {@code yang-patch-status}.
19  */
20 public record DataYangPatchParams(@NonNull PrettyPrintParam prettyPrint) implements FormatParameters {
21     public static final @NonNull DataYangPatchParams COMPACT = new DataYangPatchParams(PrettyPrintParam.FALSE);
22     public static final @NonNull DataYangPatchParams PRETTY = new DataYangPatchParams(PrettyPrintParam.TRUE);
23
24     public DataYangPatchParams {
25         requireNonNull(prettyPrint);
26     }
27
28     /**
29      * Return {@link DataYangPatchParams} for specified query parameters.
30      *
31      * @param params Parameters and their values
32      * @return A {@link DataYangPatchParams}
33      * @throws NullPointerException if {@code queryParameters} is {@code null}
34      * @throws IllegalArgumentException if the parameters are invalid
35      */
36     public static @NonNull DataYangPatchParams of(final QueryParams params) {
37         return FormatParametersHelper.of(params, COMPACT, PRETTY);
38     }
39 }