Add ApiPath.empty()
[netconf.git] / restconf / restconf-nb / src / main / java / org / opendaylight / restconf / server / api / InvokeParams.java
1 /*
2  * Copyright (c) 2021 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 POST} HTTP operation when the request is to invoke a YANG operation, be it
18  * {@code rpc} or {@code action}. There is no such thing in RFC8040, but we support pretty-printing of the resulting
19  * {@code output} container.
20  */
21 public record InvokeParams(@NonNull PrettyPrintParam prettyPrint) implements FormatParameters {
22     public static final @NonNull InvokeParams COMPACT = new InvokeParams(PrettyPrintParam.FALSE);
23     public static final @NonNull InvokeParams PRETTY = new InvokeParams(PrettyPrintParam.TRUE);
24
25     public InvokeParams {
26         requireNonNull(prettyPrint);
27     }
28
29     /**
30      * Return {@link InvokeParams} for specified query parameters.
31      *
32      * @param params Parameters and their values
33      * @return A {@link InvokeParams}
34      * @throws NullPointerException if {@code queryParameters} is {@code null}
35      * @throws IllegalArgumentException if the parameters are invalid
36      */
37     public static @NonNull InvokeParams of(final QueryParams params) {
38         return FormatParametersHelper.of(params, COMPACT, PRETTY);
39     }
40 }