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 | 1dd740a | 2013-07-08 15:48:40 -0700 | [diff] [blame] | 24 | // 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] | 25 | // for your provider. |
Samuel A. Falvo II | 1dd740a | 2013-07-08 15:48:40 -0700 | [diff] [blame] | 26 | type CloudServersProvider interface { |
Samuel A. Falvo II | 94761be | 2013-07-31 14:31:17 -0700 | [diff] [blame] | 27 | // Servers |
Samuel A. Falvo II | 0a6e45a | 2013-07-11 17:00:41 -0700 | [diff] [blame] | 28 | |
Samuel A. Falvo II | 94761be | 2013-07-31 14:31:17 -0700 | [diff] [blame] | 29 | // ListServers provides a complete list of servers hosted by the user |
| 30 | // in a given region. This function differs from ListServersLinksOnly() |
| 31 | // 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] | 32 | ListServers() ([]Server, error) |
Samuel A. Falvo II | 94761be | 2013-07-31 14:31:17 -0700 | [diff] [blame] | 33 | |
| 34 | // ListServers provides a complete list of servers hosted by the user |
| 35 | // in a given region. This function differs from ListServers() in that |
| 36 | // it returns only IDs and links to each server returned. |
| 37 | // |
| 38 | // This function should be used only under certain circumstances. |
| 39 | // It's most useful for checking to see if a server with a given ID exists, |
| 40 | // or that you have permission to work with that server. It's also useful |
| 41 | // when the cost of retrieving the server link list plus the overhead of manually |
| 42 | // invoking ServerById() for each of the servers you're interested in is less than |
| 43 | // just calling ListServers() to begin with. This may be a consideration, for |
| 44 | // example, with mobile applications. |
| 45 | // |
| 46 | // In other cases, you probably should just call ListServers() and cache the |
| 47 | // 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] | 48 | ListServersLinksOnly() ([]Server, error) |
Samuel A. Falvo II | 94761be | 2013-07-31 14:31:17 -0700 | [diff] [blame] | 49 | |
| 50 | // ServerById will retrieve a detailed server description given the unique ID |
| 51 | // 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] | 52 | ServerById(id string) (*Server, error) |
Samuel A. Falvo II | 94761be | 2013-07-31 14:31:17 -0700 | [diff] [blame] | 53 | |
| 54 | // CreateServer requests a new server to be created by the cloud server provider. |
| 55 | // The user must pass in a pointer to an initialized NewServerContainer structure. |
| 56 | // Please refer to the NewServerContainer documentation for more details. |
| 57 | // |
| 58 | // If the NewServer structure's AdminPass is empty (""), a password will be |
| 59 | // automatically generated by your OpenStack provider, and returned through the |
| 60 | // AdminPass field of the result. Take care, however; this will be the only time |
| 61 | // this happens. No other means exists in the public API to acquire a password |
| 62 | // for a pre-existing server. If you lose it, you'll need to call SetAdminPassword() |
| 63 | // to set a new one. |
Samuel A. Falvo II | e91ff6d | 2013-07-11 15:46:10 -0700 | [diff] [blame] | 64 | CreateServer(ns NewServer) (*NewServer, error) |
Samuel A. Falvo II | 94761be | 2013-07-31 14:31:17 -0700 | [diff] [blame] | 65 | |
| 66 | // DeleteServerById requests that the server with the assigned ID be removed |
| 67 | // from your account. The delete happens asynchronously. |
Samuel A. Falvo II | 286e4de | 2013-07-12 11:33:31 -0700 | [diff] [blame] | 68 | DeleteServerById(id string) error |
Samuel A. Falvo II | 94761be | 2013-07-31 14:31:17 -0700 | [diff] [blame] | 69 | |
| 70 | // SetAdminPassword requests that the server with the specified ID have its |
| 71 | // administrative password changed. For Linux, BSD, or other POSIX-like |
| 72 | // system, this password corresponds to the root user. For Windows machines, |
| 73 | // the Administrator password will be affected instead. |
Samuel A. Falvo II | 5c305e1 | 2013-07-25 19:19:43 -0700 | [diff] [blame] | 74 | SetAdminPassword(id string, pw string) error |
Samuel A. Falvo II | 94761be | 2013-07-31 14:31:17 -0700 | [diff] [blame] | 75 | |
| 76 | // ResizeServer can be a short-hand for RebuildServer where only the size of the server |
| 77 | // changes. Note that after the resize operation is requested, you will need to confirm |
| 78 | // the resize has completed for changes to take effect permanently. Changes will assume |
| 79 | // to be confirmed even without an explicit confirmation after 24 hours from the initial |
| 80 | // request. |
Samuel A. Falvo II | 8512e9a | 2013-07-26 22:53:29 -0700 | [diff] [blame] | 81 | ResizeServer(id, newName, newFlavor, newDiskConfig string) error |
Samuel A. Falvo II | 94761be | 2013-07-31 14:31:17 -0700 | [diff] [blame] | 82 | |
| 83 | // RevertResize will reject a server's resized configuration, thus |
| 84 | // rolling back to the original server. |
Samuel A. Falvo II | 8512e9a | 2013-07-26 22:53:29 -0700 | [diff] [blame] | 85 | RevertResize(id string) error |
Samuel A. Falvo II | 94761be | 2013-07-31 14:31:17 -0700 | [diff] [blame] | 86 | |
| 87 | // ConfirmResizeServer will acknowledge a server's resized configuration. |
Samuel A. Falvo II | 8512e9a | 2013-07-26 22:53:29 -0700 | [diff] [blame] | 88 | ConfirmResize(id string) error |
Samuel A. Falvo II | 94761be | 2013-07-31 14:31:17 -0700 | [diff] [blame] | 89 | |
| 90 | // RebootServer requests that the server with the specified ID be rebooted. |
| 91 | // Two reboot mechanisms exist. |
| 92 | // |
| 93 | // - Hard. This will physically power-cycle the unit. |
| 94 | // - Soft. This will attempt to use the server's software-based mechanisms to restart |
| 95 | // the machine. E.g., "shutdown -r now" on Linux. |
Samuel A. Falvo II | adbecf9 | 2013-07-30 13:13:59 -0700 | [diff] [blame] | 96 | RebootServer(id string, hard bool) error |
Samuel A. Falvo II | 94761be | 2013-07-31 14:31:17 -0700 | [diff] [blame] | 97 | |
| 98 | // RescueServer requests that the server with the specified ID be placed into |
| 99 | // a state of maintenance. The server instance is replaced with a new instance, |
| 100 | // of the same flavor and image. This new image will have the boot volume of the |
| 101 | // original machine mounted as a secondary device, so that repair and administration |
| 102 | // may occur. Use UnrescueServer() to restore the server to its previous state. |
| 103 | // Note also that many providers will impose a time limit for how long a server may |
| 104 | // exist in rescue mode! Consult the API documentation for your provider for |
| 105 | // details. |
Samuel A. Falvo II | 15da6ab | 2013-07-30 14:02:11 -0700 | [diff] [blame] | 106 | RescueServer(id string) (string, error) |
Samuel A. Falvo II | 94761be | 2013-07-31 14:31:17 -0700 | [diff] [blame] | 107 | |
| 108 | // UnrescueServer requests that a server in rescue state be placed into its nominal |
| 109 | // operating state. |
Samuel A. Falvo II | 15da6ab | 2013-07-30 14:02:11 -0700 | [diff] [blame] | 110 | UnrescueServer(id string) error |
Samuel A. Falvo II | 94761be | 2013-07-31 14:31:17 -0700 | [diff] [blame] | 111 | |
| 112 | // UpdateServer alters one or more fields of the identified server's Server record. |
| 113 | // However, not all fields may be altered. Presently, only Name, AccessIPv4, and |
| 114 | // AccessIPv6 fields may be altered. If unspecified, or set to an empty or zero |
| 115 | // value, the corresponding field remains unaltered. |
| 116 | // |
| 117 | // 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] | 118 | UpdateServer(id string, newValues NewServerSettings) (*Server, error) |
Samuel A. Falvo II | 0a6e45a | 2013-07-11 17:00:41 -0700 | [diff] [blame] | 119 | |
Samuel A. Falvo II | 414c15c | 2013-08-01 15:16:46 -0700 | [diff] [blame] | 120 | // RebuildServer reprovisions a server to the specifications given by the |
| 121 | // NewServer structure. The following fields are guaranteed to be recognized: |
| 122 | // |
| 123 | // Name (required) AccessIPv4 |
| 124 | // imageRef (required) AccessIPv6 |
| 125 | // AdminPass (required) Metadata |
| 126 | // Personality |
| 127 | // |
| 128 | // Other providers may reserve the right to act on additional fields. |
| 129 | RebuildServer(id string, ns NewServer) (*Server, error) |
| 130 | |
Mark Peek | 6b57c23 | 2013-08-24 19:03:26 -0700 | [diff] [blame] | 131 | // CreateImage will create a new image from the specified server id returning the id of the new image. |
| 132 | CreateImage(id string, ci CreateImage) (string, error) |
| 133 | |
Samuel A. Falvo II | e21808f | 2013-08-14 14:48:09 -0700 | [diff] [blame] | 134 | // Addresses |
| 135 | |
| 136 | // ListAddresses yields the list of available addresses for the server. |
| 137 | // This information is also returned by ServerById() in the Server.Addresses |
| 138 | // field. However, if you have a lot of servers and all you need are addresses, |
| 139 | // this function might be more efficient. |
| 140 | ListAddresses(id string) (AddressSet, error) |
| 141 | |
Samuel A. Falvo II | 94761be | 2013-07-31 14:31:17 -0700 | [diff] [blame] | 142 | // Images |
Samuel A. Falvo II | 0a6e45a | 2013-07-11 17:00:41 -0700 | [diff] [blame] | 143 | |
Samuel A. Falvo II | 94761be | 2013-07-31 14:31:17 -0700 | [diff] [blame] | 144 | // ListImages yields the list of available operating system images. This function |
| 145 | // returns full details for each image, if available. |
| 146 | ListImages() ([]Image, error) |
Samuel A. Falvo II | bc3f10f | 2013-07-11 17:13:24 -0700 | [diff] [blame] | 147 | |
Mark Peek | 0dbb368 | 2013-08-24 19:04:48 -0700 | [diff] [blame] | 148 | // ImageById yields details about a specific image. |
| 149 | ImageById(id string) (*Image, error) |
| 150 | |
Samuel A. Falvo II | 94761be | 2013-07-31 14:31:17 -0700 | [diff] [blame] | 151 | // Flavors |
Samuel A. Falvo II | bc3f10f | 2013-07-11 17:13:24 -0700 | [diff] [blame] | 152 | |
Samuel A. Falvo II | 94761be | 2013-07-31 14:31:17 -0700 | [diff] [blame] | 153 | // ListFlavors yields the list of available system flavors. This function |
| 154 | // returns full details for each flavor, if available. |
| 155 | ListFlavors() ([]Flavor, error) |
Mark Peek | 5a9151f | 2013-08-17 18:59:59 -0700 | [diff] [blame] | 156 | |
| 157 | // KeyPairs |
| 158 | |
| 159 | // ListKeyPairs yields the list of available keypairs. |
| 160 | ListKeyPairs() ([]KeyPair, error) |
| 161 | |
| 162 | // CreateKeyPairs will create or generate a new keypair. |
| 163 | CreateKeyPair(nkp NewKeyPair) (KeyPair, error) |
| 164 | |
| 165 | // DeleteKeyPair wil delete a keypair. |
| 166 | DeleteKeyPair(name string) error |
| 167 | |
| 168 | // ShowKeyPair will yield the named keypair. |
| 169 | ShowKeyPair(name string) (KeyPair, error) |
Samuel A. Falvo II | 2e2b877 | 2013-07-04 15:40:15 -0700 | [diff] [blame] | 170 | } |