forked from aiven/aiven-go-client
-
Notifications
You must be signed in to change notification settings - Fork 1
/
clickhouse_query.go
42 lines (35 loc) · 1002 Bytes
/
clickhouse_query.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package aiven
type (
// ClickhouseQueryHandler aiven go-client handler for Clickhouse Queries
ClickhouseQueryHandler struct {
client *Client
}
ClickhouseQueryRequest struct {
Database string `json:"database"`
Query string `json:"query"`
}
ClickhouseQueryColumnMeta struct {
Name string `json:"name"`
Type string `json:"type"`
}
// ClickhouseQueryResponse aiven go-client clickhouse query response
ClickhouseQueryResponse struct {
APIResponse
Meta []ClickhouseQueryColumnMeta
Data []interface{}
}
)
// Create creates a ClickHouse job
func (h *ClickhouseQueryHandler) Query(project, service, database, query string) (*ClickhouseQueryResponse, error) {
path := buildPath("project", project, "service", service, "clickhouse", "query")
bts, err := h.client.doPostRequest(path, ClickhouseQueryRequest{
Database: database,
Query: query,
})
if err != nil {
return nil, err
}
var r ClickhouseQueryResponse
errR := checkAPIResponse(bts, &r)
return &r, errR
}