generated from hashicorp/terraform-provider-scaffolding
-
Notifications
You must be signed in to change notification settings - Fork 0
/
queue.go
71 lines (51 loc) · 1.4 KB
/
queue.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package client
import (
"context"
)
func (c *ClearMLClient) CreateQueue(ctx context.Context, name string, tags []string) (string, error) {
payload := map[string]interface{}{
"name": name,
"tags": tags,
}
res, err := c.request(ctx, "POST", "/queues.create", nil, payload)
if err != nil {
return "", err
}
dataObj := res.(map[string]interface{})
queueObj := dataObj["data"].(map[string]interface{})
return queueObj["id"].(string), nil
}
func (c *ClearMLClient) GetQueue(ctx context.Context, id string) (map[string]interface{}, error) {
payload := map[string]interface{}{
"queue": id,
}
res, err := c.request(ctx, "POST", "/queues.get_by_id", nil, payload)
if err != nil {
return nil, err
}
dataObj := res.(map[string]interface{})
queueObj := dataObj["data"].(map[string]interface{})
return queueObj["queue"].(map[string]interface{}), nil
}
func (c *ClearMLClient) UpdateQueue(ctx context.Context, id string, name string, tags []string) error {
payload := map[string]interface{}{
"queue": id,
"name": name,
"tags": tags,
}
_, err := c.request(ctx, "POST", "/queues.update", nil, payload)
if err != nil {
return err
}
return nil
}
func (c *ClearMLClient) DeleteQueue(ctx context.Context, id string) error {
payload := map[string]interface{}{
"queue": id,
}
_, err := c.request(ctx, "POST", "/queues.delete", nil, payload)
if err != nil {
return err
}
return nil
}