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 org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.freeboxos.internal.api.FreeboxException;
17 import org.openhab.binding.freeboxos.internal.api.Response;
20 * The {@link FtpManager} is the Java class used to handle api requests related to ftp
22 * https://dev.freebox.fr/sdk/os/system/#
24 * @author Gaƫl L'hopital - Initial contribution
27 public class FtpManager extends ConfigurableRest<FtpManager.Config, FtpManager.ConfigResponse> {
28 private static final String PATH = "ftp";
30 protected static class ConfigResponse extends Response<Config> {
33 protected static record Config(boolean enabled, boolean allowAnonymous, boolean allowAnonymousWrite,
34 boolean allowRemoteAccess, boolean weakPassword, int portCtrl, int portData, String remoteDomain) {
37 public FtpManager(FreeboxOsSession session) throws FreeboxException {
38 super(session, LoginManager.Permission.NONE, ConfigResponse.class, session.getUriBuilder().path(PATH),
42 public boolean getStatus() throws FreeboxException {
43 return getConfig().enabled();
46 public boolean setStatus(boolean enabled) throws FreeboxException {
47 Config oldConfig = getConfig();
48 Config newConfig = new Config(enabled, oldConfig.allowAnonymous, oldConfig.allowAnonymousWrite,
49 oldConfig.allowRemoteAccess, oldConfig.weakPassword, oldConfig.portCtrl, oldConfig.portData,
50 oldConfig.remoteDomain);
51 return setConfig(newConfig).enabled();