blob: 71c0be424fbfa30365e5fe6c8c1f59c155498564 [file] [log] [blame]
Samuel A. Falvo II2e2b8772013-07-04 15:40:15 -07001package gophercloud
2
3// AccessProvider instances encapsulate a Keystone authentication interface.
4type AccessProvider interface {
5 // FirstEndpointUrlByCriteria searches through the service catalog for the first
6 // matching entry endpoint fulfilling the provided criteria. If nothing found,
7 // return "". Otherwise, return either the public or internal URL for the
8 // endpoint, depending on both its existence and the setting of the ApiCriteria.UrlChoice
9 // field.
10 FirstEndpointUrlByCriteria(ApiCriteria) string
Samuel A. Falvo IIbc0d54a2013-07-08 14:45:21 -070011
Samuel A. Falvo IIbc0d54a2013-07-08 14:45:21 -070012 // AuthToken provides a copy of the current authentication token for the user's credentials.
Samuel A. Falvo II659e14b2013-07-16 12:04:54 -070013 // Note that AuthToken() will not automatically refresh an expired token.
Samuel A. Falvo IIbc0d54a2013-07-08 14:45:21 -070014 AuthToken() string
Samuel A. Falvo II659e14b2013-07-16 12:04:54 -070015
16 // Revoke allows you to terminate any program's access to the OpenStack API by token ID.
17 Revoke(string) error
Samuel A. Falvo II9e64f6b2013-07-16 14:26:50 -070018
19 // Reauthenticate attempts to acquire a new authentication token, if the feature is enabled by
20 // AuthOptions.AllowReauth.
21 Reauthenticate() error
Samuel A. Falvo II2e2b8772013-07-04 15:40:15 -070022}
23
Samuel A. Falvo IIdbc4e9e2013-11-19 14:39:37 -080024// ServiceCatalogerIdentityV2 interface provides direct access to the service catalog as offered by the Identity V2 API.
25// We regret we need to fracture the namespace of what should otherwise be a simple concept; however,
26// the OpenStack community saw fit to render V3's service catalog completely incompatible with V2.
27type ServiceCatalogerForIdentityV2 interface {
28 V2ServiceCatalog() []CatalogEntry
29}
30
Samuel A. Falvo II1dd740a2013-07-08 15:48:40 -070031// CloudServersProvider instances encapsulate a Cloud Servers API, should one exist in the service catalog
Samuel A. Falvo II2e2b8772013-07-04 15:40:15 -070032// for your provider.
Samuel A. Falvo II1dd740a2013-07-08 15:48:40 -070033type CloudServersProvider interface {
Samuel A. Falvo II94761be2013-07-31 14:31:17 -070034 // Servers
Samuel A. Falvo II0a6e45a2013-07-11 17:00:41 -070035
Samuel A. Falvo II94761be2013-07-31 14:31:17 -070036 // ListServers provides a complete list of servers hosted by the user
37 // in a given region. This function differs from ListServersLinksOnly()
38 // in that it returns all available details for each server returned.
Samuel A. Falvo II2e2b8772013-07-04 15:40:15 -070039 ListServers() ([]Server, error)
Samuel A. Falvo II94761be2013-07-31 14:31:17 -070040
41 // ListServers provides a complete list of servers hosted by the user
42 // in a given region. This function differs from ListServers() in that
43 // it returns only IDs and links to each server returned.
44 //
45 // This function should be used only under certain circumstances.
46 // It's most useful for checking to see if a server with a given ID exists,
47 // or that you have permission to work with that server. It's also useful
48 // when the cost of retrieving the server link list plus the overhead of manually
49 // invoking ServerById() for each of the servers you're interested in is less than
50 // just calling ListServers() to begin with. This may be a consideration, for
51 // example, with mobile applications.
52 //
53 // In other cases, you probably should just call ListServers() and cache the
54 // results to conserve overall bandwidth and reduce your access rate on the API.
Samuel A. Falvo II5c305e12013-07-25 19:19:43 -070055 ListServersLinksOnly() ([]Server, error)
Samuel A. Falvo II94761be2013-07-31 14:31:17 -070056
57 // ServerById will retrieve a detailed server description given the unique ID
58 // of a server. The ID can be returned by either ListServers() or by ListServersLinksOnly().
Samuel A. Falvo II02f5e832013-07-10 13:52:27 -070059 ServerById(id string) (*Server, error)
Samuel A. Falvo II94761be2013-07-31 14:31:17 -070060
61 // CreateServer requests a new server to be created by the cloud server provider.
62 // The user must pass in a pointer to an initialized NewServerContainer structure.
63 // Please refer to the NewServerContainer documentation for more details.
64 //
65 // If the NewServer structure's AdminPass is empty (""), a password will be
66 // automatically generated by your OpenStack provider, and returned through the
67 // AdminPass field of the result. Take care, however; this will be the only time
68 // this happens. No other means exists in the public API to acquire a password
69 // for a pre-existing server. If you lose it, you'll need to call SetAdminPassword()
70 // to set a new one.
Samuel A. Falvo IIe91ff6d2013-07-11 15:46:10 -070071 CreateServer(ns NewServer) (*NewServer, error)
Samuel A. Falvo II94761be2013-07-31 14:31:17 -070072
73 // DeleteServerById requests that the server with the assigned ID be removed
74 // from your account. The delete happens asynchronously.
Samuel A. Falvo II286e4de2013-07-12 11:33:31 -070075 DeleteServerById(id string) error
Samuel A. Falvo II94761be2013-07-31 14:31:17 -070076
77 // SetAdminPassword requests that the server with the specified ID have its
78 // administrative password changed. For Linux, BSD, or other POSIX-like
79 // system, this password corresponds to the root user. For Windows machines,
80 // the Administrator password will be affected instead.
Samuel A. Falvo II5c305e12013-07-25 19:19:43 -070081 SetAdminPassword(id string, pw string) error
Samuel A. Falvo II94761be2013-07-31 14:31:17 -070082
83 // ResizeServer can be a short-hand for RebuildServer where only the size of the server
84 // changes. Note that after the resize operation is requested, you will need to confirm
85 // the resize has completed for changes to take effect permanently. Changes will assume
86 // to be confirmed even without an explicit confirmation after 24 hours from the initial
87 // request.
Samuel A. Falvo II8512e9a2013-07-26 22:53:29 -070088 ResizeServer(id, newName, newFlavor, newDiskConfig string) error
Samuel A. Falvo II94761be2013-07-31 14:31:17 -070089
90 // RevertResize will reject a server's resized configuration, thus
91 // rolling back to the original server.
Samuel A. Falvo II8512e9a2013-07-26 22:53:29 -070092 RevertResize(id string) error
Samuel A. Falvo II94761be2013-07-31 14:31:17 -070093
94 // ConfirmResizeServer will acknowledge a server's resized configuration.
Samuel A. Falvo II8512e9a2013-07-26 22:53:29 -070095 ConfirmResize(id string) error
Samuel A. Falvo II94761be2013-07-31 14:31:17 -070096
97 // RebootServer requests that the server with the specified ID be rebooted.
98 // Two reboot mechanisms exist.
99 //
100 // - Hard. This will physically power-cycle the unit.
101 // - Soft. This will attempt to use the server's software-based mechanisms to restart
102 // the machine. E.g., "shutdown -r now" on Linux.
Samuel A. Falvo IIadbecf92013-07-30 13:13:59 -0700103 RebootServer(id string, hard bool) error
Samuel A. Falvo II94761be2013-07-31 14:31:17 -0700104
105 // RescueServer requests that the server with the specified ID be placed into
106 // a state of maintenance. The server instance is replaced with a new instance,
107 // of the same flavor and image. This new image will have the boot volume of the
108 // original machine mounted as a secondary device, so that repair and administration
109 // may occur. Use UnrescueServer() to restore the server to its previous state.
110 // Note also that many providers will impose a time limit for how long a server may
111 // exist in rescue mode! Consult the API documentation for your provider for
112 // details.
Samuel A. Falvo II15da6ab2013-07-30 14:02:11 -0700113 RescueServer(id string) (string, error)
Samuel A. Falvo II94761be2013-07-31 14:31:17 -0700114
115 // UnrescueServer requests that a server in rescue state be placed into its nominal
116 // operating state.
Samuel A. Falvo II15da6ab2013-07-30 14:02:11 -0700117 UnrescueServer(id string) error
Samuel A. Falvo II94761be2013-07-31 14:31:17 -0700118
119 // UpdateServer alters one or more fields of the identified server's Server record.
120 // However, not all fields may be altered. Presently, only Name, AccessIPv4, and
121 // AccessIPv6 fields may be altered. If unspecified, or set to an empty or zero
122 // value, the corresponding field remains unaltered.
123 //
124 // This function returns the new set of server details if successful.
Samuel A. Falvo II72ac2dd2013-07-31 13:45:05 -0700125 UpdateServer(id string, newValues NewServerSettings) (*Server, error)
Samuel A. Falvo II0a6e45a2013-07-11 17:00:41 -0700126
Samuel A. Falvo II414c15c2013-08-01 15:16:46 -0700127 // RebuildServer reprovisions a server to the specifications given by the
128 // NewServer structure. The following fields are guaranteed to be recognized:
129 //
130 // Name (required) AccessIPv4
131 // imageRef (required) AccessIPv6
132 // AdminPass (required) Metadata
133 // Personality
134 //
135 // Other providers may reserve the right to act on additional fields.
136 RebuildServer(id string, ns NewServer) (*Server, error)
137
Mark Peek6b57c232013-08-24 19:03:26 -0700138 // CreateImage will create a new image from the specified server id returning the id of the new image.
139 CreateImage(id string, ci CreateImage) (string, error)
140
Samuel A. Falvo IIe21808f2013-08-14 14:48:09 -0700141 // Addresses
142
143 // ListAddresses yields the list of available addresses for the server.
144 // This information is also returned by ServerById() in the Server.Addresses
145 // field. However, if you have a lot of servers and all you need are addresses,
146 // this function might be more efficient.
147 ListAddresses(id string) (AddressSet, error)
148
Jon Perritt499dce12013-10-29 15:41:14 -0500149 // ListAddressesByNetwork yields the list of available addresses for a given server id and networkLabel.
150 // Example: ListAddressesByNetwork("234-4353-4jfrj-43j2s", "private")
151 ListAddressesByNetwork(id, networkLabel string) (NetworkAddress, error)
152
Tim Millerc04e9752014-01-15 16:15:47 -0800153 // ListFloatingIps yields the list of all floating IP addresses allocated to the current project.
154 ListFloatingIps() ([]FloatingIp, error)
155
156 // CreateFloatingIp allocates a new IP from the named pool to the current project.
157 CreateFloatingIp(pool string) (FloatingIp, error)
158
159 // DeleteFloatingIp returns the specified IP from the current project to the pool.
160 DeleteFloatingIp(ip FloatingIp) error
161
162 // AssociateFloatingIp associates the given floating IP to the given server id.
163 AssociateFloatingIp(serverId string, ip FloatingIp) error
164
Samuel A. Falvo II94761be2013-07-31 14:31:17 -0700165 // Images
Samuel A. Falvo II0a6e45a2013-07-11 17:00:41 -0700166
Samuel A. Falvo II94761be2013-07-31 14:31:17 -0700167 // ListImages yields the list of available operating system images. This function
168 // returns full details for each image, if available.
169 ListImages() ([]Image, error)
Samuel A. Falvo IIbc3f10f2013-07-11 17:13:24 -0700170
Mark Peek0dbb3682013-08-24 19:04:48 -0700171 // ImageById yields details about a specific image.
172 ImageById(id string) (*Image, error)
173
Mark Peek12a81e62013-08-27 08:15:57 -0700174 // DeleteImageById will delete the specific image.
175 DeleteImageById(id string) error
176
Samuel A. Falvo II94761be2013-07-31 14:31:17 -0700177 // Flavors
Samuel A. Falvo IIbc3f10f2013-07-11 17:13:24 -0700178
Samuel A. Falvo II94761be2013-07-31 14:31:17 -0700179 // ListFlavors yields the list of available system flavors. This function
180 // returns full details for each flavor, if available.
181 ListFlavors() ([]Flavor, error)
Mark Peek5a9151f2013-08-17 18:59:59 -0700182
183 // KeyPairs
184
185 // ListKeyPairs yields the list of available keypairs.
186 ListKeyPairs() ([]KeyPair, error)
187
188 // CreateKeyPairs will create or generate a new keypair.
189 CreateKeyPair(nkp NewKeyPair) (KeyPair, error)
190
191 // DeleteKeyPair wil delete a keypair.
192 DeleteKeyPair(name string) error
193
194 // ShowKeyPair will yield the named keypair.
195 ShowKeyPair(name string) (KeyPair, error)
Samuel A. Falvo IIf52bdf82014-02-01 16:26:21 -0800196
197 // ListSecurityGroups provides a listing of security groups for the tenant.
198 // This method works only if the provider supports the os-security-groups extension.
199 ListSecurityGroups() ([]SecurityGroup, error)
200
201 // CreateSecurityGroup lets a tenant create a new security group.
202 // Only the SecurityGroup fields which are specified will be marshalled to the API.
203 // This method works only if the provider supports the os-security-groups extension.
204 CreateSecurityGroup(desired SecurityGroup) (*SecurityGroup, error)
205
206 // ListSecurityGroupsByServerId provides a list of security groups which apply to the indicated server.
207 // This method works only if the provider supports the os-security-groups extension.
208 ListSecurityGroupsByServerId(id string) ([]SecurityGroup, error)
209
210 // SecurityGroupById returns a security group corresponding to the provided ID number.
211 // This method works only if the provider supports the os-security-groups extension.
212 SecurityGroupById(id int) (*SecurityGroup, error)
213
214 // DeleteSecurityGroupById disposes of a security group corresponding to the provided ID number.
215 // This method works only if the provider supports the os-security-groups extension.
216 DeleteSecurityGroupById(id int) error
Samuel A. Falvo IId825e1c2014-02-25 12:48:03 -0800217
218 // ListDefaultSGRules lists default security group rules.
219 // This method only works if the provider supports the os-security-groups-default-rules extension.
220 ListDefaultSGRules() ([]SGRule, error)
221
222 // CreateDefaultSGRule creates a default security group rule.
223 // This method only works if the provider supports the os-security-groups-default-rules extension.
Samuel A. Falvo IIda422ea2014-02-25 13:38:12 -0800224 CreateDefaultSGRule(SGRule) (*SGRule, error)
Samuel A. Falvo IId825e1c2014-02-25 12:48:03 -0800225
226 // GetSGRule obtains information for a specified security group rule.
227 // This method only works if the provider supports the os-security-groups-default-rules extension.
228 GetSGRule(string) (*SGRule, error)
Samuel A. Falvo II2e2b8772013-07-04 15:40:15 -0700229}