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