-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathclients.go
More file actions
146 lines (129 loc) · 8.98 KB
/
clients.go
File metadata and controls
146 lines (129 loc) · 8.98 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
package clients
import (
"context"
"github.com/akamai/AkamaiOPEN-edgegrid-golang/v8/pkg/dns"
awssigner "github.com/aws/aws-sdk-go-v2/aws/signer/v4"
"github.com/aws/aws-sdk-go-v2/service/s3"
"github.com/go-resty/resty/v2"
"github.com/linode/linodego"
"sigs.k8s.io/controller-runtime/pkg/client"
)
// LinodeClient is an interface that defines the methods that a Linode client must have to interact with Linode.
// It defines all the functions that are required to create, delete, and get resources
// from Linode such as object storage buckets, node balancers, linodes, and VPCs.
type LinodeClient interface {
LinodeNodeBalancerClient
LinodeInstanceClient
LinodeVPCClient
LinodeObjectStorageClient
LinodeDNSClient
LinodePlacementGroupClient
LinodeFirewallClient
LinodeTokenClient
OnAfterResponse(m func(response *resty.Response) error)
}
type AkamClient interface {
AkamEdgeDNSClient
}
type AkamEdgeDNSClient interface {
GetRecord(context.Context, string, string, string) (*dns.RecordBody, error)
CreateRecord(context.Context, *dns.RecordBody, string, ...bool) error
UpdateRecord(context.Context, *dns.RecordBody, string, ...bool) error
DeleteRecord(context.Context, *dns.RecordBody, string, ...bool) error
}
// LinodeInstanceClient defines the methods that interact with Linode's Instance service.
type LinodeInstanceClient interface {
GetInstanceIPAddresses(ctx context.Context, linodeID int) (*linodego.InstanceIPAddressResponse, error)
ListInstances(ctx context.Context, opts *linodego.ListOptions) ([]linodego.Instance, error)
CreateInstance(ctx context.Context, opts linodego.InstanceCreateOptions) (*linodego.Instance, error)
BootInstance(ctx context.Context, linodeID int, configID int) error
ListInstanceConfigs(ctx context.Context, linodeID int, opts *linodego.ListOptions) ([]linodego.InstanceConfig, error)
UpdateInstanceConfig(ctx context.Context, linodeID int, configID int, opts linodego.InstanceConfigUpdateOptions) (*linodego.InstanceConfig, error)
GetInstanceDisk(ctx context.Context, linodeID int, diskID int) (*linodego.InstanceDisk, error)
UpdateInstance(ctx context.Context, linodeId int, opts linodego.InstanceUpdateOptions) (*linodego.Instance, error)
ResizeInstanceDisk(ctx context.Context, linodeID int, diskID int, size int) error
CreateInstanceDisk(ctx context.Context, linodeID int, opts linodego.InstanceDiskCreateOptions) (*linodego.InstanceDisk, error)
GetInstance(ctx context.Context, linodeID int) (*linodego.Instance, error)
DeleteInstance(ctx context.Context, linodeID int) error
GetRegion(ctx context.Context, regionID string) (*linodego.Region, error)
GetImage(ctx context.Context, imageID string) (*linodego.Image, error)
GetType(ctx context.Context, typeID string) (*linodego.LinodeType, error)
}
// LinodeVPCClient defines the methods that interact with Linode's VPC service.
type LinodeVPCClient interface {
GetVPC(ctx context.Context, vpcID int) (*linodego.VPC, error)
ListVPCs(ctx context.Context, opts *linodego.ListOptions) ([]linodego.VPC, error)
CreateVPC(ctx context.Context, opts linodego.VPCCreateOptions) (*linodego.VPC, error)
DeleteVPC(ctx context.Context, vpcID int) error
CreateVPCSubnet(ctx context.Context, opts linodego.VPCSubnetCreateOptions, vpcID int) (*linodego.VPCSubnet, error)
DeleteVPCSubnet(ctx context.Context, vpcID, subnetID int) error
}
// LinodeNodeBalancerClient defines the methods that interact with Linode's Node Balancer service.
type LinodeNodeBalancerClient interface {
CreateNodeBalancer(ctx context.Context, opts linodego.NodeBalancerCreateOptions) (*linodego.NodeBalancer, error)
GetNodeBalancer(ctx context.Context, nodebalancerID int) (*linodego.NodeBalancer, error)
ListNodeBalancerNodes(ctx context.Context, nodebalancerID int, configID int, opts *linodego.ListOptions) ([]linodego.NodeBalancerNode, error)
GetNodeBalancerConfig(ctx context.Context, nodebalancerID int, configID int) (*linodego.NodeBalancerConfig, error)
CreateNodeBalancerConfig(ctx context.Context, nodebalancerID int, opts linodego.NodeBalancerConfigCreateOptions) (*linodego.NodeBalancerConfig, error)
DeleteNodeBalancerNode(ctx context.Context, nodebalancerID int, configID int, nodeID int) error
DeleteNodeBalancer(ctx context.Context, nodebalancerID int) error
CreateNodeBalancerNode(ctx context.Context, nodebalancerID int, configID int, opts linodego.NodeBalancerNodeCreateOptions) (*linodego.NodeBalancerNode, error)
}
// LinodeObjectStorageClient defines the methods that interact with Linode's Object Storage service.
type LinodeObjectStorageClient interface {
GetObjectStorageBucket(ctx context.Context, regionID, label string) (*linodego.ObjectStorageBucket, error)
CreateObjectStorageBucket(ctx context.Context, opts linodego.ObjectStorageBucketCreateOptions) (*linodego.ObjectStorageBucket, error)
GetObjectStorageBucketAccess(ctx context.Context, clusterOrRegionID, label string) (*linodego.ObjectStorageBucketAccess, error)
UpdateObjectStorageBucketAccess(ctx context.Context, clusterOrRegionID, label string, opts linodego.ObjectStorageBucketUpdateAccessOptions) error
GetObjectStorageKey(ctx context.Context, keyID int) (*linodego.ObjectStorageKey, error)
CreateObjectStorageKey(ctx context.Context, opts linodego.ObjectStorageKeyCreateOptions) (*linodego.ObjectStorageKey, error)
DeleteObjectStorageKey(ctx context.Context, keyID int) error
DeleteObjectStorageBucket(ctx context.Context, regionID, label string) error
}
// LinodeDNSClient defines the methods that interact with Linode's Domains service.
type LinodeDNSClient interface {
CreateDomainRecord(ctx context.Context, domainID int, recordReq linodego.DomainRecordCreateOptions) (*linodego.DomainRecord, error)
UpdateDomainRecord(ctx context.Context, domainID int, domainRecordID int, recordReq linodego.DomainRecordUpdateOptions) (*linodego.DomainRecord, error)
ListDomainRecords(ctx context.Context, domainID int, opts *linodego.ListOptions) ([]linodego.DomainRecord, error)
ListDomains(ctx context.Context, opts *linodego.ListOptions) ([]linodego.Domain, error)
DeleteDomainRecord(ctx context.Context, domainID int, domainRecordID int) error
}
// LinodePlacementGroupClient defines the methods that interact with Linode's PlacementGroup service.
type LinodePlacementGroupClient interface {
GetPlacementGroup(ctx context.Context, id int) (*linodego.PlacementGroup, error)
ListPlacementGroups(ctx context.Context, options *linodego.ListOptions) ([]linodego.PlacementGroup, error)
CreatePlacementGroup(ctx context.Context, opts linodego.PlacementGroupCreateOptions) (*linodego.PlacementGroup, error)
DeletePlacementGroup(ctx context.Context, id int) error
UpdatePlacementGroup(ctx context.Context, id int, options linodego.PlacementGroupUpdateOptions) (*linodego.PlacementGroup, error)
AssignPlacementGroupLinodes(ctx context.Context, id int, options linodego.PlacementGroupAssignOptions) (*linodego.PlacementGroup, error)
UnassignPlacementGroupLinodes(ctx context.Context, id int, options linodego.PlacementGroupUnAssignOptions) (*linodego.PlacementGroup, error)
}
// LinodeFirewallClient defines the methods that interact with Linode's Firewall service.
type LinodeFirewallClient interface {
CreateFirewall(ctx context.Context, opts linodego.FirewallCreateOptions) (*linodego.Firewall, error)
GetFirewall(ctx context.Context, firewallID int) (*linodego.Firewall, error)
GetFirewallDevice(ctx context.Context, firewallID, deviceID int) (*linodego.FirewallDevice, error)
GetFirewallRules(ctx context.Context, firewallID int) (*linodego.FirewallRuleSet, error)
UpdateFirewall(ctx context.Context, firewallID int, opts linodego.FirewallUpdateOptions) (*linodego.Firewall, error)
UpdateFirewallRules(ctx context.Context, firewallID int, rules linodego.FirewallRuleSet) (*linodego.FirewallRuleSet, error)
DeleteFirewall(ctx context.Context, firewallID int) error
DeleteFirewallDevice(ctx context.Context, firewallID, deviceID int) error
}
type K8sClient interface {
client.Client
}
type S3Client interface {
DeleteObject(ctx context.Context, params *s3.DeleteObjectInput, optFns ...func(*s3.Options)) (*s3.DeleteObjectOutput, error)
PutObject(ctx context.Context, params *s3.PutObjectInput, optFns ...func(*s3.Options)) (*s3.PutObjectOutput, error)
HeadObject(ctx context.Context, params *s3.HeadObjectInput, optFns ...func(*s3.Options)) (*s3.HeadObjectOutput, error)
GetBucketVersioning(ctx context.Context, params *s3.GetBucketVersioningInput, optFns ...func(*s3.Options)) (*s3.GetBucketVersioningOutput, error)
DeleteObjects(ctx context.Context, params *s3.DeleteObjectsInput, optFns ...func(*s3.Options)) (*s3.DeleteObjectsOutput, error)
ListObjectsV2(ctx context.Context, params *s3.ListObjectsV2Input, optFns ...func(*s3.Options)) (*s3.ListObjectsV2Output, error)
ListObjectVersions(ctx context.Context, params *s3.ListObjectVersionsInput, f ...func(*s3.Options)) (*s3.ListObjectVersionsOutput, error)
}
type S3PresignClient interface {
PresignGetObject(ctx context.Context, params *s3.GetObjectInput, optFns ...func(*s3.PresignOptions)) (*awssigner.PresignedHTTPRequest, error)
}
type LinodeTokenClient interface {
SetToken(token string) *linodego.Client
}