-
Notifications
You must be signed in to change notification settings - Fork 11
/
array.go
90 lines (73 loc) · 2.23 KB
/
array.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
Copyright 2018 David Evans
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package pure1
// ArrayService type creates a service to expose array endpoints
type ArrayService struct {
client *Client
}
// GetArrays returns a list of FlashArray and FlashBlade objects
func (a *ArrayService) GetArrays(params map[string]string) ([]Array, error) {
req, err := a.client.NewRequest("GET", "arrays", params, nil)
if err != nil {
return nil, err
}
m := []Array{}
_, err = a.client.Do(req, &m, false)
if err != nil {
return nil, err
}
return m, err
}
// GetTags returns a list of tags on arrays
func (a *ArrayService) GetTags(params map[string]string) ([]Tag, error) {
req, err := a.client.NewRequest("GET", "arrays/tags", params, nil)
if err != nil {
return nil, err
}
m := []Tag{}
_, err = a.client.Do(req, &m, false)
if err != nil {
return nil, err
}
return m, err
}
// DeleteTags returns a list of tags on arrays
// params resource_id or resource_names is required
// both are comma-separated lists of tags to be deleted
func (a *ArrayService) DeleteTags(params map[string]string) error {
req, err := a.client.NewRequest("DELETE", "arrays/tags", params, nil)
if err != nil {
return err
}
m := []Tag{}
_, err = a.client.Do(req, &m, false)
if err != nil {
return err
}
return err
}
// CreateTags creates a list of tags on a array
// params resource_id or resource_names is required
// both are comma-separated lists of tags to be added to
func (a *ArrayService) CreateTags(params map[string]string, data interface{}) error {
req, err := a.client.NewRequest("PUT", "arrays/tags/batch", params, data)
if err != nil {
return err
}
m := []Tag{}
_, err = a.client.Do(req, &m, false)
if err != nil {
return err
}
return err
}