forked from OpsLevel/opslevel-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
teams.go
65 lines (57 loc) · 1.02 KB
/
teams.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
package opslevel
import (
"context"
"fmt"
)
func (c *Client) GetTeam(ctx context.Context, alias string) (*Team, error) {
params := map[string]interface{}{
"teamAlias": alias,
}
var res teamResponse
if err := c.Do(ctx, teamQuery, params, &res); err != nil {
return nil, fmt.Errorf("could not find team: %w", err)
}
if res.Account.Team == nil {
return nil, fmt.Errorf("no team was found by alias: %s", alias)
}
return res.Account.Team, nil
}
type Contact struct {
DisplayName string
Address string
}
type Team struct {
Id string
Name string
Responsibilities string
Manager User
Contacts []Contact
}
type User struct {
Name string
Email string
}
type teamResponse struct {
Account struct {
Team *Team
}
}
const teamQuery = `
query($teamAlias: String) {
account {
team(alias: $teamAlias){
id
name
responsibilities
manager {
name
email
}
contacts {
displayName
address
}
}
}
}
`