-
Notifications
You must be signed in to change notification settings - Fork 14
/
iam_project.go
38 lines (35 loc) · 969 Bytes
/
iam_project.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
package gobizfly
import (
"context"
"encoding/json"
"net/http"
)
// IAMProject - contains the information of a IAM project
type IAMProject struct {
IsActive bool `json:"is_active"`
CreatedAt string `json:"created_at"`
OriginName string `json:"origin_name"`
AliasName string `json:"alias_name"`
Description string `json:"description"`
UpdatedAt string `json:"updated_at"`
UUID string `json:"uuid"`
ShortUUID string `json:"short_uuid"`
}
func (i *iamService) ListProjects(ctx context.Context) ([]*IAMProject, error) {
req, err := i.client.NewRequest(ctx, http.MethodGet, iamServiceName, i.projectResourcePath(), nil)
if err != nil {
return nil, err
}
resp, err := i.client.Do(ctx, req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
var respData struct {
Data []*IAMProject `json:"data"`
}
if err := json.NewDecoder(resp.Body).Decode(&respData); err != nil {
return nil, err
}
return respData.Data, nil
}