]> git.basschouten.com Git - openhab-addons.git/blob
f73b151490702a7a8d6f5a06ba99db7e735abed6
[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.persistence.influxdb.internal;
14
15 import java.time.Instant;
16 import java.util.List;
17 import java.util.Map;
18
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.openhab.core.persistence.FilterCriteria;
21
22 /**
23  * Manages InfluxDB server interaction maintaining client connection
24  *
25  * @author Joan Pujol Espinar - Initial contribution
26  */
27 @NonNullByDefault
28 public interface InfluxDBRepository {
29     /**
30      * Returns if the client is successfully connected to server
31      *
32      * @return True if it's connected, otherwise false
33      */
34     boolean isConnected();
35
36     /**
37      * Connect to InfluxDB server
38      *
39      * @return <code>true</code> if successful, otherwise <code>false</code>
40      */
41     boolean connect();
42
43     /**
44      * Disconnect from InfluxDB server
45      */
46     void disconnect();
47
48     /**
49      * Check if connection is currently ready
50      *
51      * @return True if it's ready, otherwise false
52      */
53     boolean checkConnectionStatus();
54
55     /**
56      * Return all stored item names with its count of stored points
57      *
58      * @return Map with <ItemName,ItemCount> entries
59      */
60     Map<String, Integer> getStoredItemsCount();
61
62     /**
63      * Executes Flux query
64      *
65      * @param filter the query filter
66      * @return Query results
67      * 
68      */
69     List<InfluxRow> query(FilterCriteria filter, String retentionPolicy);
70
71     /**
72      * Write points to database
73      *
74      * @param influxPoints {@link List<InfluxPoint>} to write
75      * @returns <code>true</code> if points have been written, <code>false</code> otherwise
76      */
77     boolean write(List<InfluxPoint> influxPoints);
78
79     /**
80      * Execute delete query
81      *
82      * @param filter the query filter
83      * @return <code>true</code> if query executed successfully, <code>false</code> otherwise
84      */
85     boolean remove(FilterCriteria filter);
86
87     record InfluxRow(Instant time, String itemName, Object value) {
88     }
89 }