]> git.basschouten.com Git - openhab-addons.git/blob
999783def7f622862ac433fca89960d30f44460b
[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.mikrotik.internal.model;
14
15 import java.time.LocalDateTime;
16 import java.util.Map;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20 import org.openhab.binding.mikrotik.internal.util.Converter;
21
22 /**
23  * The {@link RouterosL2TPCliInterface} is a model class for `l2tp-out` interface models having casting accessors for
24  * data that is specific to this network interface kind. Is a subclass of {@link RouterosInterfaceBase}.
25  *
26  * @author Oleg Vivtash - Initial contribution
27  */
28 @NonNullByDefault
29 public class RouterosL2TPCliInterface extends RouterosInterfaceBase {
30     public RouterosL2TPCliInterface(Map<String, String> props) {
31         super(props);
32     }
33
34     @Override
35     public RouterosInterfaceType getDesignedType() {
36         return RouterosInterfaceType.L2TP_SERVER;
37     }
38
39     @Override
40     public String getApiType() {
41         return "l2tp-client";
42     }
43
44     @Override
45     public boolean hasDetailedReport() {
46         return false;
47     }
48
49     @Override
50     public boolean hasMonitor() {
51         return true;
52     }
53
54     public @Nullable String getStatus() {
55         return getProp("status");
56     }
57
58     public @Nullable String getEncoding() {
59         return String.format("Encoding: %s", getProp("encoding", "None"));
60     }
61
62     public @Nullable String getServerAddress() {
63         return getProp("connect-to");
64     }
65
66     public @Nullable String getLocalAddress() {
67         return getProp("local-address");
68     }
69
70     public @Nullable String getRemoteAddress() {
71         return getProp("remote-address");
72     }
73
74     public @Nullable String getUptime() {
75         return getProp("uptime");
76     }
77
78     public @Nullable LocalDateTime getUptimeStart() {
79         return Converter.routerosPeriodBack(getUptime());
80     }
81 }