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.config;
15 import javax.ws.rs.core.UriBuilder;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.binding.freeboxos.internal.api.FreeboxTlsCertificateProvider;
21 * The {@link FreeboxOsConfiguration} is responsible for holding configuration informations needed to access the Freebox
24 * @author Gaƫl L'hopital - Initial contribution
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";
33 private String apiDomain = FreeboxTlsCertificateProvider.DEFAULT_NAME;
34 public String appToken = "";
35 public boolean discoverNetDevice;
36 public int discoveryInterval = 10;
38 private int httpsPort = 15682;
39 private boolean httpsAvailable;
41 private String getScheme() {
42 return httpsAvailable ? "https" : "http";
45 private int getPort() {
46 return httpsAvailable ? httpsPort : 80;
49 public UriBuilder getUriBuilder(String path) {
50 return UriBuilder.fromPath("/").scheme(getScheme()).port(getPort()).host(apiDomain).path(path).clone();