blob: 4c7dbee422a532be012a7a8cdf1290a32d12068f [file] [log] [blame]
Samuel A. Falvo II2e2b8772013-07-04 15:40:15 -07001package gophercloud
2
Fatih Arslan41e3a702014-07-09 13:05:33 -07003import "net/url"
4
Samuel A. Falvo II2e2b8772013-07-04 15:40:15 -07005// AccessProvider instances encapsulate a Keystone authentication interface.
6type AccessProvider interface {
7 // FirstEndpointUrlByCriteria searches through the service catalog for the first
8 // matching entry endpoint fulfilling the provided criteria. If nothing found,
9 // return "". Otherwise, return either the public or internal URL for the
10 // endpoint, depending on both its existence and the setting of the ApiCriteria.UrlChoice
11 // field.
12 FirstEndpointUrlByCriteria(ApiCriteria) string
Samuel A. Falvo IIbc0d54a2013-07-08 14:45:21 -070013
Samuel A. Falvo IIbc0d54a2013-07-08 14:45:21 -070014 // AuthToken provides a copy of the current authentication token for the user's credentials.
Samuel A. Falvo II659e14b2013-07-16 12:04:54 -070015 // Note that AuthToken() will not automatically refresh an expired token.
Samuel A. Falvo IIbc0d54a2013-07-08 14:45:21 -070016 AuthToken() string
Samuel A. Falvo II659e14b2013-07-16 12:04:54 -070017
18 // Revoke allows you to terminate any program's access to the OpenStack API by token ID.
19 Revoke(string) error
Samuel A. Falvo II9e64f6b2013-07-16 14:26:50 -070020
21 // Reauthenticate attempts to acquire a new authentication token, if the feature is enabled by
22 // AuthOptions.AllowReauth.
23 Reauthenticate() error
Samuel A. Falvo II2e2b8772013-07-04 15:40:15 -070024}
25
Samuel A. Falvo IIdbc4e9e2013-11-19 14:39:37 -080026// ServiceCatalogerIdentityV2 interface provides direct access to the service catalog as offered by the Identity V2 API.
27// We regret we need to fracture the namespace of what should otherwise be a simple concept; however,
28// the OpenStack community saw fit to render V3's service catalog completely incompatible with V2.
29type ServiceCatalogerForIdentityV2 interface {
30 V2ServiceCatalog() []CatalogEntry
31}
32
Samuel A. Falvo II1dd740a2013-07-08 15:48:40 -070033// CloudServersProvider instances encapsulate a Cloud Servers API, should one exist in the service catalog
Samuel A. Falvo II2e2b8772013-07-04 15:40:15 -070034// for your provider.
Samuel A. Falvo II1dd740a2013-07-08 15:48:40 -070035type CloudServersProvider interface {
Samuel A. Falvo II94761be2013-07-31 14:31:17 -070036 // Servers
Samuel A. Falvo II0a6e45a2013-07-11 17:00:41 -070037
Samuel A. Falvo II94761be2013-07-31 14:31:17 -070038 // ListServers provides a complete list of servers hosted by the user
39 // in a given region. This function differs from ListServersLinksOnly()
40 // in that it returns all available details for each server returned.
Samuel A. Falvo II2e2b8772013-07-04 15:40:15 -070041 ListServers() ([]Server, error)
Samuel A. Falvo II94761be2013-07-31 14:31:17 -070042
Fatih Arslan41e3a702014-07-09 13:05:33 -070043 // ListServersByFilters provides a list of servers hosted by the user in a
44 // given region. This function let you requests servers by certain URI
45 // paramaters defined by the API endpoint. This is sometimes more suitable
46 // if you have many servers and you only want to pick servers on certain
47 // criterias. An example usage could be :
48 //
49 // filter := url.Values{}
50 // filter.Set("name", "MyServer")
51 // filter.Set("status", "ACTIVE")
52 //
53 // filteredServers, err := c.ListServersByFilters(filter)
54 //
55 // Here, filteredServers only contains servers whose name started with
56 // "MyServer" and are in "ACTIVE" status.
57 ListServersByFilter(filter url.Values) ([]Server, error)
58
Samuel A. Falvo II94761be2013-07-31 14:31:17 -070059 // ListServers provides a complete list of servers hosted by the user
60 // in a given region. This function differs from ListServers() in that
61 // it returns only IDs and links to each server returned.
62 //
63 // This function should be used only under certain circumstances.
64 // It's most useful for checking to see if a server with a given ID exists,
65 // or that you have permission to work with that server. It's also useful
66 // when the cost of retrieving the server link list plus the overhead of manually
67 // invoking ServerById() for each of the servers you're interested in is less than
68 // just calling ListServers() to begin with. This may be a consideration, for
69 // example, with mobile applications.
70 //
71 // In other cases, you probably should just call ListServers() and cache the
72 // results to conserve overall bandwidth and reduce your access rate on the API.
Samuel A. Falvo II5c305e12013-07-25 19:19:43 -070073 ListServersLinksOnly() ([]Server, error)
Samuel A. Falvo II94761be2013-07-31 14:31:17 -070074
75 // ServerById will retrieve a detailed server description given the unique ID
76 // of a server. The ID can be returned by either ListServers() or by ListServersLinksOnly().
Samuel A. Falvo II02f5e832013-07-10 13:52:27 -070077 ServerById(id string) (*Server, error)
Samuel A. Falvo II94761be2013-07-31 14:31:17 -070078
79 // CreateServer requests a new server to be created by the cloud server provider.
80 // The user must pass in a pointer to an initialized NewServerContainer structure.
81 // Please refer to the NewServerContainer documentation for more details.
82 //
83 // If the NewServer structure's AdminPass is empty (""), a password will be
84 // automatically generated by your OpenStack provider, and returned through the
85 // AdminPass field of the result. Take care, however; this will be the only time
86 // this happens. No other means exists in the public API to acquire a password
87 // for a pre-existing server. If you lose it, you'll need to call SetAdminPassword()
88 // to set a new one.
Samuel A. Falvo IIe91ff6d2013-07-11 15:46:10 -070089 CreateServer(ns NewServer) (*NewServer, error)
Samuel A. Falvo II94761be2013-07-31 14:31:17 -070090
91 // DeleteServerById requests that the server with the assigned ID be removed
92 // from your account. The delete happens asynchronously.
Samuel A. Falvo II286e4de2013-07-12 11:33:31 -070093 DeleteServerById(id string) error
Samuel A. Falvo II94761be2013-07-31 14:31:17 -070094
95 // SetAdminPassword requests that the server with the specified ID have its
96 // administrative password changed. For Linux, BSD, or other POSIX-like
97 // system, this password corresponds to the root user. For Windows machines,
98 // the Administrator password will be affected instead.
Samuel A. Falvo II5c305e12013-07-25 19:19:43 -070099 SetAdminPassword(id string, pw string) error
Samuel A. Falvo II94761be2013-07-31 14:31:17 -0700100
101 // ResizeServer can be a short-hand for RebuildServer where only the size of the server
102 // changes. Note that after the resize operation is requested, you will need to confirm
103 // the resize has completed for changes to take effect permanently. Changes will assume
104 // to be confirmed even without an explicit confirmation after 24 hours from the initial
105 // request.
Samuel A. Falvo II8512e9a2013-07-26 22:53:29 -0700106 ResizeServer(id, newName, newFlavor, newDiskConfig string) error
Samuel A. Falvo II94761be2013-07-31 14:31:17 -0700107
108 // RevertResize will reject a server's resized configuration, thus
109 // rolling back to the original server.
Samuel A. Falvo II8512e9a2013-07-26 22:53:29 -0700110 RevertResize(id string) error
Samuel A. Falvo II94761be2013-07-31 14:31:17 -0700111
112 // ConfirmResizeServer will acknowledge a server's resized configuration.
Samuel A. Falvo II8512e9a2013-07-26 22:53:29 -0700113 ConfirmResize(id string) error
Samuel A. Falvo II94761be2013-07-31 14:31:17 -0700114
115 // RebootServer requests that the server with the specified ID be rebooted.
116 // Two reboot mechanisms exist.
117 //
118 // - Hard. This will physically power-cycle the unit.
119 // - Soft. This will attempt to use the server's software-based mechanisms to restart
120 // the machine. E.g., "shutdown -r now" on Linux.
Samuel A. Falvo IIadbecf92013-07-30 13:13:59 -0700121 RebootServer(id string, hard bool) error
Samuel A. Falvo II94761be2013-07-31 14:31:17 -0700122
123 // RescueServer requests that the server with the specified ID be placed into
124 // a state of maintenance. The server instance is replaced with a new instance,
125 // of the same flavor and image. This new image will have the boot volume of the
126 // original machine mounted as a secondary device, so that repair and administration
127 // may occur. Use UnrescueServer() to restore the server to its previous state.
128 // Note also that many providers will impose a time limit for how long a server may
129 // exist in rescue mode! Consult the API documentation for your provider for
130 // details.
Samuel A. Falvo II15da6ab2013-07-30 14:02:11 -0700131 RescueServer(id string) (string, error)
Samuel A. Falvo II94761be2013-07-31 14:31:17 -0700132
133 // UnrescueServer requests that a server in rescue state be placed into its nominal
134 // operating state.
Samuel A. Falvo II15da6ab2013-07-30 14:02:11 -0700135 UnrescueServer(id string) error
Samuel A. Falvo II94761be2013-07-31 14:31:17 -0700136
137 // UpdateServer alters one or more fields of the identified server's Server record.
138 // However, not all fields may be altered. Presently, only Name, AccessIPv4, and
139 // AccessIPv6 fields may be altered. If unspecified, or set to an empty or zero
140 // value, the corresponding field remains unaltered.
141 //
142 // This function returns the new set of server details if successful.
Samuel A. Falvo II72ac2dd2013-07-31 13:45:05 -0700143 UpdateServer(id string, newValues NewServerSettings) (*Server, error)
Samuel A. Falvo II0a6e45a2013-07-11 17:00:41 -0700144
Samuel A. Falvo II414c15c2013-08-01 15:16:46 -0700145 // RebuildServer reprovisions a server to the specifications given by the
146 // NewServer structure. The following fields are guaranteed to be recognized:
147 //
148 // Name (required) AccessIPv4
149 // imageRef (required) AccessIPv6
150 // AdminPass (required) Metadata
151 // Personality
152 //
153 // Other providers may reserve the right to act on additional fields.
154 RebuildServer(id string, ns NewServer) (*Server, error)
155
Mark Peek6b57c232013-08-24 19:03:26 -0700156 // CreateImage will create a new image from the specified server id returning the id of the new image.
157 CreateImage(id string, ci CreateImage) (string, error)
158
Samuel A. Falvo IIe21808f2013-08-14 14:48:09 -0700159 // Addresses
160
161 // ListAddresses yields the list of available addresses for the server.
162 // This information is also returned by ServerById() in the Server.Addresses
163 // field. However, if you have a lot of servers and all you need are addresses,
164 // this function might be more efficient.
165 ListAddresses(id string) (AddressSet, error)
166
Jon Perritt499dce12013-10-29 15:41:14 -0500167 // ListAddressesByNetwork yields the list of available addresses for a given server id and networkLabel.
168 // Example: ListAddressesByNetwork("234-4353-4jfrj-43j2s", "private")
169 ListAddressesByNetwork(id, networkLabel string) (NetworkAddress, error)
170
Tim Millerc04e9752014-01-15 16:15:47 -0800171 // ListFloatingIps yields the list of all floating IP addresses allocated to the current project.
172 ListFloatingIps() ([]FloatingIp, error)
173
174 // CreateFloatingIp allocates a new IP from the named pool to the current project.
175 CreateFloatingIp(pool string) (FloatingIp, error)
176
177 // DeleteFloatingIp returns the specified IP from the current project to the pool.
178 DeleteFloatingIp(ip FloatingIp) error
179
180 // AssociateFloatingIp associates the given floating IP to the given server id.
181 AssociateFloatingIp(serverId string, ip FloatingIp) error
182
Samuel A. Falvo II94761be2013-07-31 14:31:17 -0700183 // Images
Samuel A. Falvo II0a6e45a2013-07-11 17:00:41 -0700184
Samuel A. Falvo II94761be2013-07-31 14:31:17 -0700185 // ListImages yields the list of available operating system images. This function
186 // returns full details for each image, if available.
187 ListImages() ([]Image, error)
Samuel A. Falvo IIbc3f10f2013-07-11 17:13:24 -0700188
Mark Peek0dbb3682013-08-24 19:04:48 -0700189 // ImageById yields details about a specific image.
190 ImageById(id string) (*Image, error)
191
Mark Peek12a81e62013-08-27 08:15:57 -0700192 // DeleteImageById will delete the specific image.
193 DeleteImageById(id string) error
194
Samuel A. Falvo II94761be2013-07-31 14:31:17 -0700195 // Flavors
Samuel A. Falvo IIbc3f10f2013-07-11 17:13:24 -0700196
Samuel A. Falvo II94761be2013-07-31 14:31:17 -0700197 // ListFlavors yields the list of available system flavors. This function
198 // returns full details for each flavor, if available.
199 ListFlavors() ([]Flavor, error)
Mark Peek5a9151f2013-08-17 18:59:59 -0700200
201 // KeyPairs
202
203 // ListKeyPairs yields the list of available keypairs.
204 ListKeyPairs() ([]KeyPair, error)
205
206 // CreateKeyPairs will create or generate a new keypair.
207 CreateKeyPair(nkp NewKeyPair) (KeyPair, error)
208
209 // DeleteKeyPair wil delete a keypair.
210 DeleteKeyPair(name string) error
211
212 // ShowKeyPair will yield the named keypair.
213 ShowKeyPair(name string) (KeyPair, error)
Samuel A. Falvo IIf52bdf82014-02-01 16:26:21 -0800214
215 // ListSecurityGroups provides a listing of security groups for the tenant.
216 // This method works only if the provider supports the os-security-groups extension.
217 ListSecurityGroups() ([]SecurityGroup, error)
218
219 // CreateSecurityGroup lets a tenant create a new security group.
220 // Only the SecurityGroup fields which are specified will be marshalled to the API.
221 // This method works only if the provider supports the os-security-groups extension.
222 CreateSecurityGroup(desired SecurityGroup) (*SecurityGroup, error)
223
224 // ListSecurityGroupsByServerId provides a list of security groups which apply to the indicated server.
225 // This method works only if the provider supports the os-security-groups extension.
226 ListSecurityGroupsByServerId(id string) ([]SecurityGroup, error)
227
228 // SecurityGroupById returns a security group corresponding to the provided ID number.
229 // This method works only if the provider supports the os-security-groups extension.
230 SecurityGroupById(id int) (*SecurityGroup, error)
231
232 // DeleteSecurityGroupById disposes of a security group corresponding to the provided ID number.
233 // This method works only if the provider supports the os-security-groups extension.
234 DeleteSecurityGroupById(id int) error
Samuel A. Falvo IId825e1c2014-02-25 12:48:03 -0800235
236 // ListDefaultSGRules lists default security group rules.
237 // This method only works if the provider supports the os-security-groups-default-rules extension.
238 ListDefaultSGRules() ([]SGRule, error)
239
240 // CreateDefaultSGRule creates a default security group rule.
241 // This method only works if the provider supports the os-security-groups-default-rules extension.
Samuel A. Falvo IIda422ea2014-02-25 13:38:12 -0800242 CreateDefaultSGRule(SGRule) (*SGRule, error)
Samuel A. Falvo IId825e1c2014-02-25 12:48:03 -0800243
244 // GetSGRule obtains information for a specified security group rule.
245 // This method only works if the provider supports the os-security-groups-default-rules extension.
246 GetSGRule(string) (*SGRule, error)
Samuel A. Falvo II2e2b8772013-07-04 15:40:15 -0700247}