]> git.basschouten.com Git - openhab-addons.git/blob
c8be49c48d172a15ce6fea92c96ab47fac416cf5
[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 java.util.List;
16
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;
21
22 import inet.ipaddr.IPAddress;
23
24 /**
25  * The {@link ConnectionManager} is the Java class used to handle api requests related to connection
26  *
27  * https://dev.freebox.fr/sdk/os/system/#
28  *
29  * @author GaĆ«l L'hopital - Initial contribution
30  */
31 @NonNullByDefault
32 public class ConnectionManager extends ConfigurableRest<ConnectionManager.Status, ConnectionManager.StatusResponse> {
33     private static final String PATH = "connection";
34
35     protected static class StatusResponse extends Response<Status> {
36     }
37
38     private enum State {
39         GOING_UP,
40         UP,
41         GOING_DOWN,
42         DOWN,
43         UNKNOWN
44     }
45
46     private enum Type {
47         ETHERNET,
48         RFC2684,
49         PPPOATM,
50         UNKNOWN
51     }
52
53     private enum Media {
54         FTTH,
55         ETHERNET,
56         XDSL,
57         BACKUP_4G,
58         UNKNOWN
59     }
60
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
70     ) {
71     }
72
73     public ConnectionManager(FreeboxOsSession session) throws FreeboxException {
74         super(session, LoginManager.Permission.NONE, StatusResponse.class, session.getUriBuilder().path(PATH), null);
75     }
76 }