forked from juju/juju
/
interfaces.go
260 lines (233 loc) · 11.3 KB
/
interfaces.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
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
// Copyright 2017 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package common
import (
"github.com/juju/go-oracle-cloud/api"
"github.com/juju/go-oracle-cloud/common"
"github.com/juju/go-oracle-cloud/response"
"github.com/juju/juju/core/instance"
"github.com/juju/juju/environs"
)
type OracleInstancer interface {
environs.Environ
Details(id instance.Id) (response.Instance, error)
}
// Instancer used to retrieve details from a given instance
// in the oracle cloud infrastructure
type Instancer interface {
// InstanceDetails retrieves information from the provider
// about one instance
InstanceDetails(string) (response.Instance, error)
}
// Composer has the simple task of composing an oracle compatible
// resource name
type Composer interface {
// ComposeName composes the name for a provider resource. The name
// for an oracle API resource typically has the following form:
//
// /Compute-<Identity Domain>/<username>/<resource name>
//
// The Identity Domain in this case equates to what some other providers
// like OpenStack refer to as tenants or projects.
// This information is supplied by the user in the cloud configuration
// information.
// This function is generally needed
ComposeName(string) string
}
// InstanceAPI uses to retrieve all instances, delete and create
// in the oracle cloud infrastructure
type InstanceAPI interface {
CreateInstance(api.InstanceParams) (response.LaunchPlan, error)
AllInstances([]api.Filter) (response.AllInstances, error)
DeleteInstance(string) error
}
// Authenticater authenticates the oracle client in the
// oracle IAAS api
type Authenticater interface {
Authenticate() error
}
// Shaper used to retrieve all shapes from the oracle cloud
// environ
type Shaper interface {
AllShapes([]api.Filter) (response.AllShapes, error)
}
// Imager used to retrieve all images iso meta data format from the
// oracle cloud environment
type Imager interface {
AllImageLists([]api.Filter) (response.AllImageLists, error)
CreateImageList(def int, description string, name string) (resp response.ImageList, err error)
CreateImageListEntry(name string, attributes map[string]interface{}, version int, machineImages []string) (resp response.ImageListEntryAdd, err error)
DeleteImageList(name string) (err error)
}
// IpReservationAPI provider methods for retrieving, updating, creating
// and deleting ip reservations inside the oracle cloud infrastructure
type IpReservationAPI interface {
AllIpReservations([]api.Filter) (response.AllIpReservations, error)
UpdateIpReservation(string, string,
common.IPPool, bool, []string) (response.IpReservation, error)
CreateIpReservation(string, common.IPPool,
bool, []string) (response.IpReservation, error)
DeleteIpReservation(string) error
}
// IpAssociationAPI provides methods for creating deleting and listing all
// ip associations inside the oracle cloud environment
type IpAssociationAPI interface {
CreateIpAssociation(common.IPPool, common.VcableID) (response.IpAssociation, error)
DeleteIpAssociation(string) error
AllIpAssociations([]api.Filter) (response.AllIpAssociations, error)
}
// IpNetworkExchanger provides a simple interface for retrieving all
// ip network exchanges inside the oracle cloud environment
type IpNetworkExchanger interface {
AllIpNetworkExchanges([]api.Filter) (response.AllIpNetworkExchanges, error)
}
// IpNetowrker provides a simple interface for retrieving all
// ip networks inside the oracle cloud environment
type IpNetworker interface {
AllIpNetworks([]api.Filter) (response.AllIpNetworks, error)
}
// VnicSetAPI provides methods for deleting, retrieving details and creating
// virtual nics for providing access for instances to different subnets inside
// the oracle cloud environment
type VnicSetAPI interface {
DeleteVnicSet(string) error
VnicSetDetails(string) (response.VnicSet, error)
CreateVnicSet(api.VnicSetParams) (response.VnicSet, error)
}
// RulesAPI defines methods for retrieving, creating and deleting
// Sec rules under the oracle cloud endpoint
// For more information on sec rules, please see:
// https://docs.oracle.com/cloud/latest/stcomputecs/STCSA/api-SecRules.html
type RulesAPI interface {
// AllSecRules returns all sec rules matching a filter. A nil valued
// filter will return all entries in the API.
AllSecRules([]api.Filter) (response.AllSecRules, error)
// DeleteSecRule deletes the security rule with the given name
DeleteSecRule(string) error
// CreateSecRule creates the security rule inside oracle cloud
// given the sec rule parameters
CreateSecRule(api.SecRuleParams) (response.SecRule, error)
}
// AclAPI defines methods for retrieving, creating and deleting
// access control lists under the oracle cloud endpoint
type AclAPI interface {
// AclDetails retrieves the access control list details for one list
AclDetails(string) (response.Acl, error)
// CreateAcl creates the access control list
CreateAcl(string, string, bool, []string) (response.Acl, error)
// DeleteAcl deletes one access control list
DeleteAcl(string) error
// AllAcls fetches a list of all ACLs matching the given filter.
AllAcls([]api.Filter) (response.AllAcls, error)
}
// SecIpAPI defines methods for retrieving creating sec IP lists
// in the oracle cloud
// For more information about sec ip lists, please see:
// https://docs.oracle.com/cloud/latest/stcomputecs/STCSA/api-SecIPLists.html
type SecIpAPI interface {
// AllSecIpLists returns all sec IP lists that match a filter. A nil valued
// filter will return all entries in the API.
AllSecIpLists([]api.Filter) (response.AllSecIpLists, error)
// CreateSecIpList creates the sec IP list under the oracle cloud endpoint
CreateSecIpList(string, string, []string) (response.SecIpList, error)
// AllDefaultSecIpLists retrieves all default sec IP lists from the
// oracle cloud account. Default lists are defined by the cloud and cannot
// be changed in any way.
AllDefaultSecIpLists([]api.Filter) (response.AllSecIpLists, error)
}
// IpAddressPrefixSetAPI defines methods for creating and listing
// IP address prefix sets under the oracle cloud endpoint
// For information about IP address prefix sets, please see:
// https://docs.oracle.com/cloud/latest/stcomputecs/STCSA/api-IPAddressPrefixSets.html
type IpAddressPrefixSetAPI interface {
// CreateIpAddressPrefixSet creates a new IP address prefix set inside the oracle
// cloud, for the current user
CreateIpAddressPrefixSet(
api.IpAddressPrefixSetParams) (response.IpAddressPrefixSet, error)
// AllIpAddressPrefixSets returns all IP address prefix sets that match the given filter.
// A nil valued filter will return all entries in the API.
AllIpAddressPrefixSets([]api.Filter) (response.AllIpAddressPrefixSets, error)
}
// SecListAPI defines methods for retrieving, creating and deleting
// sec lists under the oracle cloud endpoint
// For more information about sec lists, please see:
// https://docs.oracle.com/cloud/latest/stcomputecs/STCSA/api-SecLists.html
type SecListAPI interface {
// SecListDetails retrieves sec list details for the given list
SecListDetails(string) (response.SecList, error)
// DeleteSecList deletes one sec list
DeleteSecList(string) error
// CreateSecList creates a sec list
CreateSecList(string, string,
common.SecRuleAction, common.SecRuleAction) (response.SecList, error)
}
// SecRulesAPI defines methods for retrieving, deleting and creating
// security rules under the oracle cloud endpoint
// For more details on sec rules, please see:
// https://docs.oracle.com/cloud/latest/stcomputecs/STCSA/api-SecRules.html
type SecRulesAPI interface {
// AllSecurityRules returns all security rules matching a filter. A nil valued
// filter will return all entries in the API.
AllSecurityRules([]api.Filter) (response.AllSecurityRules, error)
// DeleteSecurityRule deletes the security rule with the given name
DeleteSecurityRule(string) error
// CreateSecurityRule creates a security rule based on the security rule
// parameters under the oracle cloud endpoint
CreateSecurityRule(api.SecurityRuleParams) (response.SecurityRule, error)
}
// ApplicationsAPI also named protocols in the oracle cloud defines methods
// for retriving and creating applications rules/protocol rules
// under the oracle cloud endpoint
// For more information about sec applications, please see:
// https://docs.oracle.com/cloud/latest/stcomputecs/STCSA/api-SecApplications.html
type ApplicationsAPI interface {
// AllSecApplications returns all sec applications matching a filter. A nil valued
// filter will return all entries in the API.
AllSecApplications([]api.Filter) (response.AllSecApplications, error)
// DefaultSecApplications returns all default security applications matching a filter.
// A nil valued filter will return all entries in the API.
DefaultSecApplications([]api.Filter) (response.AllSecApplications, error)
// CreateSecApplications creates a security applications
CreateSecApplication(api.SecApplicationParams) (response.SecApplication, error)
}
// AssociationAPI defines a rule for listing, retrieving all security
// associations under the oracle cloud API
// For more details about sec associations, please see:
// https://docs.oracle.com/cloud/latest/stcomputecs/STCSA/api-SecAssociations.html
type AssociationAPI interface {
// AllSecAssociations returns all security associations matching a filter. A nil valued
// filter will return all entries in the API.
AllSecAssociations([]api.Filter) (response.AllSecAssociations, error)
}
// StorageVolumeAPI defines methods for retrieving, creating, deleting and
// updating storage volumes under the oracle cloud endpoint
// For more details about storage volumes, please see:
// https://docs.oracle.com/cloud/latest/stcomputecs/STCSA/api-StorageVolumes.html
type StorageVolumeAPI interface {
// CreateStorageVolume creates a storage volume
CreateStorageVolume(p api.StorageVolumeParams) (resp response.StorageVolume, err error)
// DeleteStorageVolume deletes the storage volume
DeleteStorageVolume(name string) (err error)
// StorageVolumeDetails retrieves storage volume details
StorageVolumeDetails(name string) (resp response.StorageVolume, err error)
// AllStoragevolumes retrieves all storage volumes matching a filter. A nil valued
// filter will return all entries in the API.
AllStorageVolumes(filter []api.Filter) (resp response.AllStorageVolumes, err error)
// UpdateStorageVolume updates the state of the storage volume
UpdateStorageVolume(p api.StorageVolumeParams, currentName string) (resp response.StorageVolume, err error)
}
// StorageAttachmentAPI defines methods for attaching, detaching storages to
// instances under the oracle cloud endpoint
// For more information on storage attachments, please see:
// https://docs.oracle.com/cloud/latest/stcomputecs/STCSA/api-StorageAttachments.html
type StorageAttachmentAPI interface {
// CreateStorageAttachment creates a storage attachment
CreateStorageAttachment(p api.StorageAttachmentParams) (response.StorageAttachment, error)
// DeleteStorageAttachment deletes the storage attachment
DeleteStorageAttachment(name string) error
// StorageAttachmentDetails retrieves details of the storage attachment
StorageAttachmentDetails(name string) (response.StorageAttachment, error)
// AllStorageAttachments retrieves all storage attachments matching a filter. A nil valued
// filter will return all entries in the API.
AllStorageAttachments(filter []api.Filter) (response.AllStorageAttachments, error)
}