/
client.go
56 lines (48 loc) · 1.56 KB
/
client.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
// Package v1 contains auto-generated files. DO NOT MODIFY
package v1
import (
"github.com/RJPearson94/twilio-sdk-go/client"
"github.com/RJPearson94/twilio-sdk-go/service/monitor/v1/alert"
"github.com/RJPearson94/twilio-sdk-go/service/monitor/v1/alerts"
"github.com/RJPearson94/twilio-sdk-go/service/monitor/v1/event"
"github.com/RJPearson94/twilio-sdk-go/service/monitor/v1/events"
"github.com/RJPearson94/twilio-sdk-go/session"
)
// Monitor client is used to manage resources for Twilio Monitor
type Monitor struct {
client *client.Client
Alert func(string) *alert.Client
Alerts *alerts.Client
Event func(string) *event.Client
Events *events.Client
}
// NewWithClient creates a new instance of the client with a HTTP client
func NewWithClient(client *client.Client) *Monitor {
return &Monitor{
client: client,
Alert: func(alertSid string) *alert.Client {
return alert.New(client, alert.ClientProperties{
Sid: alertSid,
})
},
Alerts: alerts.New(client),
Event: func(eventSid string) *event.Client {
return event.New(client, event.ClientProperties{
Sid: eventSid,
})
},
Events: events.New(client),
}
}
// GetClient is used for testing purposes only
func (s Monitor) GetClient() *client.Client {
return s.client
}
// New creates a new instance of the client using session data and config
func New(sess *session.Session, clientConfig *client.Config) *Monitor {
config := client.NewAPIClientConfig(clientConfig)
config.Beta = false
config.SubDomain = "monitor"
config.APIVersion = "v1"
return NewWithClient(client.New(sess, config))
}