Samuel A. Falvo II | 2e2b877 | 2013-07-04 15:40:15 -0700 | [diff] [blame] | 1 | package gophercloud |
| 2 | |
| 3 | // AccessProvider instances encapsulate a Keystone authentication interface. |
| 4 | type 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 II | bc0d54a | 2013-07-08 14:45:21 -0700 | [diff] [blame] | 11 | |
Samuel A. Falvo II | bc0d54a | 2013-07-08 14:45:21 -0700 | [diff] [blame] | 12 | // AuthToken provides a copy of the current authentication token for the user's credentials. |
Samuel A. Falvo II | 659e14b | 2013-07-16 12:04:54 -0700 | [diff] [blame] | 13 | // Note that AuthToken() will not automatically refresh an expired token. |
Samuel A. Falvo II | bc0d54a | 2013-07-08 14:45:21 -0700 | [diff] [blame] | 14 | AuthToken() string |
Samuel A. Falvo II | 659e14b | 2013-07-16 12:04:54 -0700 | [diff] [blame] | 15 | |
| 16 | // Revoke allows you to terminate any program's access to the OpenStack API by token ID. |
| 17 | Revoke(string) error |
Samuel A. Falvo II | 9e64f6b | 2013-07-16 14:26:50 -0700 | [diff] [blame] | 18 | |
| 19 | // Reauthenticate attempts to acquire a new authentication token, if the feature is enabled by |
| 20 | // AuthOptions.AllowReauth. |
| 21 | Reauthenticate() error |
Samuel A. Falvo II | 2e2b877 | 2013-07-04 15:40:15 -0700 | [diff] [blame] | 22 | } |
| 23 | |
Samuel A. Falvo II | dbc4e9e | 2013-11-19 14:39:37 -0800 | [diff] [blame] | 24 | // 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. |
| 27 | type ServiceCatalogerForIdentityV2 interface { |
| 28 | V2ServiceCatalog() []CatalogEntry |
| 29 | } |
| 30 | |
Samuel A. Falvo II | 1dd740a | 2013-07-08 15:48:40 -0700 | [diff] [blame] | 31 | // CloudServersProvider instances encapsulate a Cloud Servers API, should one exist in the service catalog |
Samuel A. Falvo II | 2e2b877 | 2013-07-04 15:40:15 -0700 | [diff] [blame] | 32 | // for your provider. |
Samuel A. Falvo II | 1dd740a | 2013-07-08 15:48:40 -0700 | [diff] [blame] | 33 | type CloudServersProvider interface { |
Samuel A. Falvo II | 94761be | 2013-07-31 14:31:17 -0700 | [diff] [blame] | 34 | // Servers |
Samuel A. Falvo II | 0a6e45a | 2013-07-11 17:00:41 -0700 | [diff] [blame] | 35 | |
Samuel A. Falvo II | 94761be | 2013-07-31 14:31:17 -0700 | [diff] [blame] | 36 | // 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 II | 2e2b877 | 2013-07-04 15:40:15 -0700 | [diff] [blame] | 39 | ListServers() ([]Server, error) |
Samuel A. Falvo II | 94761be | 2013-07-31 14:31:17 -0700 | [diff] [blame] | 40 | |
| 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 II | 5c305e1 | 2013-07-25 19:19:43 -0700 | [diff] [blame] | 55 | ListServersLinksOnly() ([]Server, error) |
Samuel A. Falvo II | 94761be | 2013-07-31 14:31:17 -0700 | [diff] [blame] | 56 | |
| 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 II | 02f5e83 | 2013-07-10 13:52:27 -0700 | [diff] [blame] | 59 | ServerById(id string) (*Server, error) |
Samuel A. Falvo II | 94761be | 2013-07-31 14:31:17 -0700 | [diff] [blame] | 60 | |
| 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 II | e91ff6d | 2013-07-11 15:46:10 -0700 | [diff] [blame] | 71 | CreateServer(ns NewServer) (*NewServer, error) |
Samuel A. Falvo II | 94761be | 2013-07-31 14:31:17 -0700 | [diff] [blame] | 72 | |
| 73 | // DeleteServerById requests that the server with the assigned ID be removed |
| 74 | // from your account. The delete happens asynchronously. |
Samuel A. Falvo II | 286e4de | 2013-07-12 11:33:31 -0700 | [diff] [blame] | 75 | DeleteServerById(id string) error |
Samuel A. Falvo II | 94761be | 2013-07-31 14:31:17 -0700 | [diff] [blame] | 76 | |
| 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 II | 5c305e1 | 2013-07-25 19:19:43 -0700 | [diff] [blame] | 81 | SetAdminPassword(id string, pw string) error |
Samuel A. Falvo II | 94761be | 2013-07-31 14:31:17 -0700 | [diff] [blame] | 82 | |
| 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 II | 8512e9a | 2013-07-26 22:53:29 -0700 | [diff] [blame] | 88 | ResizeServer(id, newName, newFlavor, newDiskConfig string) error |
Samuel A. Falvo II | 94761be | 2013-07-31 14:31:17 -0700 | [diff] [blame] | 89 | |
| 90 | // RevertResize will reject a server's resized configuration, thus |
| 91 | // rolling back to the original server. |
Samuel A. Falvo II | 8512e9a | 2013-07-26 22:53:29 -0700 | [diff] [blame] | 92 | RevertResize(id string) error |
Samuel A. Falvo II | 94761be | 2013-07-31 14:31:17 -0700 | [diff] [blame] | 93 | |
| 94 | // ConfirmResizeServer will acknowledge a server's resized configuration. |
Samuel A. Falvo II | 8512e9a | 2013-07-26 22:53:29 -0700 | [diff] [blame] | 95 | ConfirmResize(id string) error |
Samuel A. Falvo II | 94761be | 2013-07-31 14:31:17 -0700 | [diff] [blame] | 96 | |
| 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 II | adbecf9 | 2013-07-30 13:13:59 -0700 | [diff] [blame] | 103 | RebootServer(id string, hard bool) error |
Samuel A. Falvo II | 94761be | 2013-07-31 14:31:17 -0700 | [diff] [blame] | 104 | |
| 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 II | 15da6ab | 2013-07-30 14:02:11 -0700 | [diff] [blame] | 113 | RescueServer(id string) (string, error) |
Samuel A. Falvo II | 94761be | 2013-07-31 14:31:17 -0700 | [diff] [blame] | 114 | |
| 115 | // UnrescueServer requests that a server in rescue state be placed into its nominal |
| 116 | // operating state. |
Samuel A. Falvo II | 15da6ab | 2013-07-30 14:02:11 -0700 | [diff] [blame] | 117 | UnrescueServer(id string) error |
Samuel A. Falvo II | 94761be | 2013-07-31 14:31:17 -0700 | [diff] [blame] | 118 | |
| 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 II | 72ac2dd | 2013-07-31 13:45:05 -0700 | [diff] [blame] | 125 | UpdateServer(id string, newValues NewServerSettings) (*Server, error) |
Samuel A. Falvo II | 0a6e45a | 2013-07-11 17:00:41 -0700 | [diff] [blame] | 126 | |
Samuel A. Falvo II | 414c15c | 2013-08-01 15:16:46 -0700 | [diff] [blame] | 127 | // 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 Peek | 6b57c23 | 2013-08-24 19:03:26 -0700 | [diff] [blame] | 138 | // 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 II | e21808f | 2013-08-14 14:48:09 -0700 | [diff] [blame] | 141 | // 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 Perritt | 499dce1 | 2013-10-29 15:41:14 -0500 | [diff] [blame] | 149 | // 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 Miller | c04e975 | 2014-01-15 16:15:47 -0800 | [diff] [blame] | 153 | // 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 II | 94761be | 2013-07-31 14:31:17 -0700 | [diff] [blame] | 165 | // Images |
Samuel A. Falvo II | 0a6e45a | 2013-07-11 17:00:41 -0700 | [diff] [blame] | 166 | |
Samuel A. Falvo II | 94761be | 2013-07-31 14:31:17 -0700 | [diff] [blame] | 167 | // 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 II | bc3f10f | 2013-07-11 17:13:24 -0700 | [diff] [blame] | 170 | |
Mark Peek | 0dbb368 | 2013-08-24 19:04:48 -0700 | [diff] [blame] | 171 | // ImageById yields details about a specific image. |
| 172 | ImageById(id string) (*Image, error) |
| 173 | |
Mark Peek | 12a81e6 | 2013-08-27 08:15:57 -0700 | [diff] [blame] | 174 | // DeleteImageById will delete the specific image. |
| 175 | DeleteImageById(id string) error |
| 176 | |
Samuel A. Falvo II | 94761be | 2013-07-31 14:31:17 -0700 | [diff] [blame] | 177 | // Flavors |
Samuel A. Falvo II | bc3f10f | 2013-07-11 17:13:24 -0700 | [diff] [blame] | 178 | |
Samuel A. Falvo II | 94761be | 2013-07-31 14:31:17 -0700 | [diff] [blame] | 179 | // ListFlavors yields the list of available system flavors. This function |
| 180 | // returns full details for each flavor, if available. |
| 181 | ListFlavors() ([]Flavor, error) |
Mark Peek | 5a9151f | 2013-08-17 18:59:59 -0700 | [diff] [blame] | 182 | |
| 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 II | f52bdf8 | 2014-02-01 16:26:21 -0800 | [diff] [blame] | 196 | |
| 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 II | d825e1c | 2014-02-25 12:48:03 -0800 | [diff] [blame] | 217 | |
| 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 II | da422ea | 2014-02-25 13:38:12 -0800 | [diff] [blame] | 224 | CreateDefaultSGRule(SGRule) (*SGRule, error) |
Samuel A. Falvo II | d825e1c | 2014-02-25 12:48:03 -0800 | [diff] [blame] | 225 | |
| 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 II | 2e2b877 | 2013-07-04 15:40:15 -0700 | [diff] [blame] | 229 | } |