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 java.util.List;
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;
22 import inet.ipaddr.IPAddress;
25 * The {@link ConnectionManager} is the Java class used to handle api requests related to connection
27 * https://dev.freebox.fr/sdk/os/system/#
29 * @author Gaƫl L'hopital - Initial contribution
32 public class ConnectionManager extends ConfigurableRest<ConnectionManager.Status, ConnectionManager.StatusResponse> {
33 private static final String PATH = "connection";
35 protected static class StatusResponse extends Response<Status> {
38 private static enum State {
46 private static enum Type {
53 private static enum Media {
61 public static record Status(State state, Type type, Media media, @Nullable List<Integer> ipv4PortRange,
62 @Nullable IPAddress ipv4, // This can be null if state is not up
63 @Nullable IPAddress ipv6, // This can be null if state is not up
64 long rateUp, // current upload rate in byte/s
65 long rateDown, // current download rate in byte/s
66 long bandwidthUp, // available upload bandwidth in bit/s
67 long bandwidthDown, // available download bandwidth in bit/s
68 long bytesUp, // total uploaded bytes since last connection
69 long bytesDown // total downloaded bytes since last connection
73 public ConnectionManager(FreeboxOsSession session) throws FreeboxException {
74 super(session, LoginManager.Permission.NONE, StatusResponse.class, session.getUriBuilder().path(PATH), null);