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.boschshc.internal.services;
15 import java.util.concurrent.ExecutionException;
16 import java.util.concurrent.TimeoutException;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.openhab.binding.boschshc.internal.devices.bridge.BridgeHandler;
20 import org.openhab.binding.boschshc.internal.services.dto.BoschSHCServiceState;
23 * Abstract implementation for services that allow setting states via HTTP POST requests containing a JSON request body.
24 * State-less services can not receive any states from the bridge.
26 * An example of such a service is the <code>arm</code> action of the intrusion detection system.
28 * The services of the devices and their official APIs can be found
29 * <a href="https://apidocs.bosch-smarthome.com/local/">here</a>.
31 * @param <TRequest> Type to represent JSON requests sent by this service
33 * @author David Pace - Initial contribution
36 public abstract class AbstractStatelessBoschSHCServiceWithRequestBody<TRequest extends BoschSHCServiceState>
37 extends AbstractStatelessBoschSHCService {
39 protected AbstractStatelessBoschSHCServiceWithRequestBody(String serviceName, String endpoint) {
40 super(serviceName, endpoint);
44 * Sends a HTTP POST request containing the serialized request body to the endpoint specified by
45 * {@link #getEndpoint()}.
47 * @param request a JSON object representing the request body
48 * @throws InterruptedException
49 * @throws TimeoutException
50 * @throws ExecutionException
52 public void postAction(TRequest request) throws InterruptedException, TimeoutException, ExecutionException {
53 BridgeHandler bridgeHandler = getBridgeHandler();
54 if (bridgeHandler == null) {
58 bridgeHandler.postAction(getEndpoint(), request);