/
service.go
82 lines (65 loc) · 3.53 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package aws
import (
"context"
"github.com/spotinst/spotinst-sdk-go/spotinst"
"github.com/spotinst/spotinst-sdk-go/spotinst/client"
"github.com/spotinst/spotinst-sdk-go/spotinst/session"
)
// Service provides the API operation methods for making requests to endpoints
// of the Spotinst API. See this package's package overview docs for details on
// the service.
type Service interface {
serviceKubernetes
serviceECS
serviceCommon
}
type serviceKubernetes interface {
ListClusters(context.Context, *ListClustersInput) (*ListClustersOutput, error)
CreateCluster(context.Context, *CreateClusterInput) (*CreateClusterOutput, error)
ReadCluster(context.Context, *ReadClusterInput) (*ReadClusterOutput, error)
UpdateCluster(context.Context, *UpdateClusterInput) (*UpdateClusterOutput, error)
DeleteCluster(context.Context, *DeleteClusterInput) (*DeleteClusterOutput, error)
ListLaunchSpecs(context.Context, *ListLaunchSpecsInput) (*ListLaunchSpecsOutput, error)
CreateLaunchSpec(context.Context, *CreateLaunchSpecInput) (*CreateLaunchSpecOutput, error)
ReadLaunchSpec(context.Context, *ReadLaunchSpecInput) (*ReadLaunchSpecOutput, error)
UpdateLaunchSpec(context.Context, *UpdateLaunchSpecInput) (*UpdateLaunchSpecOutput, error)
DeleteLaunchSpec(context.Context, *DeleteLaunchSpecInput) (*DeleteLaunchSpecOutput, error)
ListClusterInstances(context.Context, *ListClusterInstancesInput) (*ListClusterInstancesOutput, error)
DetachClusterInstances(context.Context, *DetachClusterInstancesInput) (*DetachClusterInstancesOutput, error)
GetLogEvents(context.Context, *GetLogEventsInput) (*GetLogEventsOutput, error)
ListRolls(context.Context, *ListRollsInput) (*ListRollsOutput, error)
CreateRoll(context.Context, *CreateRollInput) (*CreateRollOutput, error)
ReadRoll(context.Context, *ReadRollInput) (*ReadRollOutput, error)
UpdateRoll(context.Context, *UpdateRollInput) (*UpdateRollOutput, error)
// Deprecated: Roll is obsolete, exists for backward compatibility only,
// and should not be used. Please use CreateRoll instead.
Roll(context.Context, *RollClusterInput) (*RollClusterOutput, error)
}
type serviceECS interface {
ListECSClusters(context.Context, *ListECSClustersInput) (*ListECSClustersOutput, error)
CreateECSCluster(context.Context, *CreateECSClusterInput) (*CreateECSClusterOutput, error)
ReadECSCluster(context.Context, *ReadECSClusterInput) (*ReadECSClusterOutput, error)
UpdateECSCluster(context.Context, *UpdateECSClusterInput) (*UpdateECSClusterOutput, error)
DeleteECSCluster(context.Context, *DeleteECSClusterInput) (*DeleteECSClusterOutput, error)
ListECSLaunchSpecs(context.Context, *ListECSLaunchSpecsInput) (*ListECSLaunchSpecsOutput, error)
CreateECSLaunchSpec(context.Context, *CreateECSLaunchSpecInput) (*CreateECSLaunchSpecOutput, error)
ReadECSLaunchSpec(context.Context, *ReadECSLaunchSpecInput) (*ReadECSLaunchSpecOutput, error)
UpdateECSLaunchSpec(context.Context, *UpdateECSLaunchSpecInput) (*UpdateECSLaunchSpecOutput, error)
DeleteECSLaunchSpec(context.Context, *DeleteECSLaunchSpecInput) (*DeleteECSLaunchSpecOutput, error)
RollECS(context.Context, *ECSRollClusterInput) (*ECSRollClusterOutput, error)
}
type serviceCommon interface {
ListResourceSuggestions(context.Context, *ListResourceSuggestionsInput) (*ListResourceSuggestionsOutput, error)
}
type ServiceOp struct {
Client *client.Client
}
var _ Service = &ServiceOp{}
func New(sess *session.Session, cfgs ...*spotinst.Config) *ServiceOp {
cfg := &spotinst.Config{}
cfg.Merge(sess.Config)
cfg.Merge(cfgs...)
return &ServiceOp{
Client: client.New(sess.Config),
}
}