]> git.basschouten.com Git - openhab-addons.git/blob
92c8a132a3d45685261c08dad4a2e067f34aba1e
[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.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
38     private int httpsPort = 15682;
39     private boolean httpsAvailable;
40
41     private String getScheme() {
42         return httpsAvailable ? "https" : "http";
43     }
44
45     private int getPort() {
46         return httpsAvailable ? httpsPort : 80;
47     }
48
49     public UriBuilder getUriBuilder(String path) {
50         return UriBuilder.fromPath("/").scheme(getScheme()).port(getPort()).host(apiDomain).path(path).clone();
51     }
52 }