]> git.basschouten.com Git - openhab-addons.git/blob
035df9a9923bafbe4ddfacfb67af1053e5e1b73d
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.freeboxos.internal.api.rest;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.freeboxos.internal.api.FreeboxException;
17 import org.openhab.binding.freeboxos.internal.api.Response;
18
19 /**
20  * The {@link UPnPAVManager} is the Java class used to handle api requests related to UPnP AV
21  *
22  * @author GaĆ«l L'hopital - Initial contribution
23  */
24 @NonNullByDefault
25 public class UPnPAVManager extends ConfigurableRest<UPnPAVManager.Config, UPnPAVManager.ConfigResponse> {
26     private static final String PATH = "upnpav";
27
28     protected static class ConfigResponse extends Response<Config> {
29     }
30
31     protected static record Config(boolean enabled) {
32     }
33
34     public UPnPAVManager(FreeboxOsSession session) throws FreeboxException {
35         super(session, LoginManager.Permission.NONE, ConfigResponse.class, session.getUriBuilder().path(PATH),
36                 CONFIG_PATH);
37     }
38
39     public boolean getStatus() throws FreeboxException {
40         return getConfig().enabled();
41     }
42
43     public boolean setStatus(boolean enabled) throws FreeboxException {
44         return setConfig(new Config(enabled)).enabled();
45     }
46 }