]> git.basschouten.com Git - openhab-addons.git/blob
32d3698da74d9f7824eb767b148eac3d8c9a5e0b
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2024 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.config;
14
15 import javax.ws.rs.core.UriBuilder;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.binding.freeboxos.internal.api.FreeboxTlsCertificateProvider;
19
20 /**
21  * The {@link FreeboxOsConfiguration} is responsible for holding configuration informations needed to access the Freebox
22  * API
23  *
24  * @author GaĆ«l L'hopital - Initial contribution
25  */
26 @NonNullByDefault
27 public class FreeboxOsConfiguration {
28     public static final String API_DOMAIN = "apiDomain";
29     public static final String APP_TOKEN = "appToken";
30     public static final String HTTPS_PORT = "httpsPort";
31     public static final String HTTPS_AVAILABLE = "httpsAvailable";
32
33     private String apiDomain = FreeboxTlsCertificateProvider.DEFAULT_NAME;
34     public String appToken = "";
35     public boolean discoverNetDevice;
36     public int discoveryInterval = 10;
37     public int wsReconnectInterval = 60;
38
39     private int httpsPort = 15682;
40     private boolean httpsAvailable;
41
42     private String getScheme() {
43         return httpsAvailable ? "https" : "http";
44     }
45
46     private int getPort() {
47         return httpsAvailable ? httpsPort : 80;
48     }
49
50     public UriBuilder getUriBuilder(String path) {
51         return UriBuilder.fromPath("/").scheme(getScheme()).port(getPort()).host(apiDomain).path(path).clone();
52     }
53 }