/
service.go
58 lines (49 loc) · 1.5 KB
/
service.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
package aws
import (
"fmt"
"github.com/CloudCoreo/cli/client"
)
// Service contains three aws service groups
type Service struct {
setup *SetupService
role *RoleService
remove *RemoveService
}
// NewServiceInput contains the info for creating a new Service
type NewServiceInput struct {
AwsProfile string
AwsProfilePath string
Policy string
RoleSessionName string
Duration int64
IgnoreMissingTrails bool
}
// NewService returns a new aws service group
func NewService(input *NewServiceInput) *Service {
return &Service{
setup: NewSetupService(input),
role: NewRoleService(input),
remove: NewRemoveService(input),
}
}
// SetupEventStream calls the SetupEventStream function in SetupService
func (s *Service) SetupEventStream(input *client.EventStreamConfig) error {
return s.setup.SetupEventStream(input)
}
// CreateNewRole calls the CreateNewRole function in RoleService
func (s *Service) CreateNewRole(input *client.RoleCreationInfo) (arn string, externalID string, err error) {
return s.role.CreateNewRole(input)
}
// DeleteRole calls the DeleteRole function in RoleService
func (s *Service) DeleteRole(roleName string) {
err := s.role.DeleteRole(roleName)
if err != nil {
fmt.Println(err.Error())
} else {
fmt.Println("Deleted role successfully!")
}
}
//RemoveEventStream perform the same function as event stream removal script
func (s *Service) RemoveEventStream(input *client.EventRemoveConfig) error {
return s.remove.RemoveEventStream(input)
}