2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.freeboxos.internal.api.rest;
15 import javax.ws.rs.core.UriBuilder;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.openhab.binding.freeboxos.internal.api.FreeboxException;
20 import org.openhab.binding.freeboxos.internal.api.Response;
23 * The {@link AfpManager} is the Java class used to handle api requests related to Afp shares
25 * @author Gaƫl L'hopital - Initial contribution
28 public class AfpManager extends ConfigurableRest<AfpManager.Afp, AfpManager.ConfigResponse> {
29 private static final String AFP_PATH = "afp";
31 protected static class ConfigResponse extends Response<Afp> {
34 protected static record Afp(boolean enabled, boolean guestAllow, ServerType serverType, @Nullable String loginName,
35 @Nullable String loginPassword) {
36 private static enum ServerType {
52 public AfpManager(FreeboxOsSession session, UriBuilder uriBuilder) throws FreeboxException {
53 super(session, LoginManager.Permission.NONE, ConfigResponse.class, uriBuilder.path(AFP_PATH), null);
56 public boolean getStatus() throws FreeboxException {
57 return getConfig().enabled;
60 public boolean setStatus(boolean enabled) throws FreeboxException {
61 Afp config = getConfig();
62 Afp newConfig = new Afp(enabled, config.guestAllow, config.serverType, config.loginName, config.loginPassword);
63 return setConfig(newConfig).enabled;