Rackspace.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. /*
  2. * Copyright (c) 2014, Oculus VR, Inc.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the BSD-style license found in the
  6. * LICENSE file in the root directory of this source tree. An additional grant
  7. * of patent rights can be found in the PATENTS file in the same directory.
  8. *
  9. */
  10. /// \file Rackspace.h
  11. /// \brief Helper to class to manage Rackspace servers
  12. ///
  13. #include "NativeFeatureIncludes.h"
  14. #if _RAKNET_SUPPORT_Rackspace==1 && _RAKNET_SUPPORT_TCPInterface==1
  15. #include "Export.h"
  16. #include "DS_List.h"
  17. #include "RakNetTypes.h"
  18. #include "DS_Queue.h"
  19. #include "RakString.h"
  20. #ifndef __RACKSPACE_H
  21. #define __RACKSPACE_H
  22. namespace RakNet
  23. {
  24. class TCPInterface;
  25. struct Packet;
  26. /// \brief Result codes for Rackspace commands
  27. /// /sa Rackspace::EventTypeToString()
  28. enum RackspaceEventType
  29. {
  30. RET_Success_200,
  31. RET_Success_201,
  32. RET_Success_202,
  33. RET_Success_203,
  34. RET_Success_204,
  35. RET_Cloud_Servers_Fault_500,
  36. RET_Service_Unavailable_503,
  37. RET_Unauthorized_401,
  38. RET_Bad_Request_400,
  39. RET_Over_Limit_413,
  40. RET_Bad_Media_Type_415,
  41. RET_Item_Not_Found_404,
  42. RET_Build_In_Progress_409,
  43. RET_Resize_Not_Allowed_403,
  44. RET_Connection_Closed_Without_Reponse,
  45. RET_Unknown_Failure,
  46. };
  47. /// \internal
  48. enum RackspaceOperationType
  49. {
  50. RO_CONNECT_AND_AUTHENTICATE,
  51. RO_LIST_SERVERS,
  52. RO_LIST_SERVERS_WITH_DETAILS,
  53. RO_CREATE_SERVER,
  54. RO_GET_SERVER_DETAILS,
  55. RO_UPDATE_SERVER_NAME_OR_PASSWORD,
  56. RO_DELETE_SERVER,
  57. RO_LIST_SERVER_ADDRESSES,
  58. RO_SHARE_SERVER_ADDRESS,
  59. RO_DELETE_SERVER_ADDRESS,
  60. RO_REBOOT_SERVER,
  61. RO_REBUILD_SERVER,
  62. RO_RESIZE_SERVER,
  63. RO_CONFIRM_RESIZED_SERVER,
  64. RO_REVERT_RESIZED_SERVER,
  65. RO_LIST_FLAVORS,
  66. RO_GET_FLAVOR_DETAILS,
  67. RO_LIST_IMAGES,
  68. RO_CREATE_IMAGE,
  69. RO_GET_IMAGE_DETAILS,
  70. RO_DELETE_IMAGE,
  71. RO_LIST_SHARED_IP_GROUPS,
  72. RO_LIST_SHARED_IP_GROUPS_WITH_DETAILS,
  73. RO_CREATE_SHARED_IP_GROUP,
  74. RO_GET_SHARED_IP_GROUP_DETAILS,
  75. RO_DELETE_SHARED_IP_GROUP,
  76. RO_NONE,
  77. };
  78. /// \brief Callback interface to receive the results of operations
  79. class RAK_DLL_EXPORT Rackspace2EventCallback
  80. {
  81. public:
  82. Rackspace2EventCallback() {}
  83. virtual ~Rackspace2EventCallback() {}
  84. virtual void OnAuthenticationResult(RackspaceEventType eventType, const char *htmlAdditionalInfo)=0;
  85. virtual void OnListServersResult(RackspaceEventType eventType, const char *htmlAdditionalInfo)=0;
  86. virtual void OnListServersWithDetailsResult(RackspaceEventType eventType, const char *htmlAdditionalInfo)=0;
  87. virtual void OnCreateServerResult(RackspaceEventType eventType, const char *htmlAdditionalInfo)=0;
  88. virtual void OnGetServerDetails(RackspaceEventType eventType, const char *htmlAdditionalInfo)=0;
  89. virtual void OnUpdateServerNameOrPassword(RackspaceEventType eventType, const char *htmlAdditionalInfo)=0;
  90. virtual void OnDeleteServer(RackspaceEventType eventType, const char *htmlAdditionalInfo)=0;
  91. virtual void OnListServerAddresses(RackspaceEventType eventType, const char *htmlAdditionalInfo)=0;
  92. virtual void OnShareServerAddress(RackspaceEventType eventType, const char *htmlAdditionalInfo)=0;
  93. virtual void OnDeleteServerAddress(RackspaceEventType eventType, const char *htmlAdditionalInfo)=0;
  94. virtual void OnRebootServer(RackspaceEventType eventType, const char *htmlAdditionalInfo)=0;
  95. virtual void OnRebuildServer(RackspaceEventType eventType, const char *htmlAdditionalInfo)=0;
  96. virtual void OnResizeServer(RackspaceEventType eventType, const char *htmlAdditionalInfo)=0;
  97. virtual void OnConfirmResizedServer(RackspaceEventType eventType, const char *htmlAdditionalInfo)=0;
  98. virtual void OnRevertResizedServer(RackspaceEventType eventType, const char *htmlAdditionalInfo)=0;
  99. virtual void OnListFlavorsResult(RackspaceEventType eventType, const char *htmlAdditionalInfo)=0;
  100. virtual void OnGetFlavorDetailsResult(RackspaceEventType eventType, const char *htmlAdditionalInfo)=0;
  101. virtual void OnListImagesResult(RackspaceEventType eventType, const char *htmlAdditionalInfo)=0;
  102. virtual void OnCreateImageResult(RackspaceEventType eventType, const char *htmlAdditionalInfo)=0;
  103. virtual void OnGetImageDetailsResult(RackspaceEventType eventType, const char *htmlAdditionalInfo)=0;
  104. virtual void OnDeleteImageResult(RackspaceEventType eventType, const char *htmlAdditionalInfo)=0;
  105. virtual void OnListSharedIPGroups(RackspaceEventType eventType, const char *htmlAdditionalInfo)=0;
  106. virtual void OnListSharedIPGroupsWithDetails(RackspaceEventType eventType, const char *htmlAdditionalInfo)=0;
  107. virtual void OnCreateSharedIPGroup(RackspaceEventType eventType, const char *htmlAdditionalInfo)=0;
  108. virtual void OnGetSharedIPGroupDetails(RackspaceEventType eventType, const char *htmlAdditionalInfo)=0;
  109. virtual void OnDeleteSharedIPGroup(RackspaceEventType eventType, const char *htmlAdditionalInfo)=0;
  110. virtual void OnConnectionAttemptFailure(RackspaceOperationType operationType, const char *url)=0;
  111. };
  112. /// \brief Callback interface to receive the results of operations, with a default result
  113. class RAK_DLL_EXPORT RackspaceEventCallback_Default : public Rackspace2EventCallback
  114. {
  115. public:
  116. virtual void ExecuteDefault(const char *callbackName, RackspaceEventType eventType, const char *htmlAdditionalInfo) {(void) callbackName; (void) eventType; (void) htmlAdditionalInfo;}
  117. virtual void OnAuthenticationResult(RackspaceEventType eventType, const char *htmlAdditionalInfo) {ExecuteDefault("OnAuthenticationResult", eventType, htmlAdditionalInfo);}
  118. virtual void OnListServersResult(RackspaceEventType eventType, const char *htmlAdditionalInfo) {ExecuteDefault("OnListServersResult", eventType, htmlAdditionalInfo);}
  119. virtual void OnListServersWithDetailsResult(RackspaceEventType eventType, const char *htmlAdditionalInfo) {ExecuteDefault("OnListServersWithDetailsResult", eventType, htmlAdditionalInfo);}
  120. virtual void OnCreateServerResult(RackspaceEventType eventType, const char *htmlAdditionalInfo) {ExecuteDefault("OnCreateServerResult", eventType, htmlAdditionalInfo);}
  121. virtual void OnGetServerDetails(RackspaceEventType eventType, const char *htmlAdditionalInfo) {ExecuteDefault("OnGetServerDetails", eventType, htmlAdditionalInfo);}
  122. virtual void OnUpdateServerNameOrPassword(RackspaceEventType eventType, const char *htmlAdditionalInfo) {ExecuteDefault("OnUpdateServerNameOrPassword", eventType, htmlAdditionalInfo);}
  123. virtual void OnDeleteServer(RackspaceEventType eventType, const char *htmlAdditionalInfo) {ExecuteDefault("OnDeleteServer", eventType, htmlAdditionalInfo);}
  124. virtual void OnListServerAddresses(RackspaceEventType eventType, const char *htmlAdditionalInfo) {ExecuteDefault("OnListServerAddresses", eventType, htmlAdditionalInfo);}
  125. virtual void OnShareServerAddress(RackspaceEventType eventType, const char *htmlAdditionalInfo) {ExecuteDefault("OnShareServerAddress", eventType, htmlAdditionalInfo);}
  126. virtual void OnDeleteServerAddress(RackspaceEventType eventType, const char *htmlAdditionalInfo) {ExecuteDefault("OnDeleteServerAddress", eventType, htmlAdditionalInfo);}
  127. virtual void OnRebootServer(RackspaceEventType eventType, const char *htmlAdditionalInfo) {ExecuteDefault("OnRebootServer", eventType, htmlAdditionalInfo);}
  128. virtual void OnRebuildServer(RackspaceEventType eventType, const char *htmlAdditionalInfo) {ExecuteDefault("OnRebuildServer", eventType, htmlAdditionalInfo);}
  129. virtual void OnResizeServer(RackspaceEventType eventType, const char *htmlAdditionalInfo) {ExecuteDefault("OnResizeServer", eventType, htmlAdditionalInfo);}
  130. virtual void OnConfirmResizedServer(RackspaceEventType eventType, const char *htmlAdditionalInfo) {ExecuteDefault("OnConfirmResizedServer", eventType, htmlAdditionalInfo);}
  131. virtual void OnRevertResizedServer(RackspaceEventType eventType, const char *htmlAdditionalInfo) {ExecuteDefault("OnRevertResizedServer", eventType, htmlAdditionalInfo);}
  132. virtual void OnListFlavorsResult(RackspaceEventType eventType, const char *htmlAdditionalInfo) {ExecuteDefault("OnListFlavorsResult", eventType, htmlAdditionalInfo);}
  133. virtual void OnGetFlavorDetailsResult(RackspaceEventType eventType, const char *htmlAdditionalInfo) {ExecuteDefault("OnGetFlavorDetailsResult", eventType, htmlAdditionalInfo);}
  134. virtual void OnListImagesResult(RackspaceEventType eventType, const char *htmlAdditionalInfo) {ExecuteDefault("OnListImagesResult", eventType, htmlAdditionalInfo);}
  135. virtual void OnCreateImageResult(RackspaceEventType eventType, const char *htmlAdditionalInfo) {ExecuteDefault("OnCreateImageResult", eventType, htmlAdditionalInfo);}
  136. virtual void OnGetImageDetailsResult(RackspaceEventType eventType, const char *htmlAdditionalInfo) {ExecuteDefault("OnGetImageDetailsResult", eventType, htmlAdditionalInfo);}
  137. virtual void OnDeleteImageResult(RackspaceEventType eventType, const char *htmlAdditionalInfo) {ExecuteDefault("OnDeleteImageResult", eventType, htmlAdditionalInfo);}
  138. virtual void OnListSharedIPGroups(RackspaceEventType eventType, const char *htmlAdditionalInfo) {ExecuteDefault("OnListSharedIPGroups", eventType, htmlAdditionalInfo);}
  139. virtual void OnListSharedIPGroupsWithDetails(RackspaceEventType eventType, const char *htmlAdditionalInfo) {ExecuteDefault("OnListSharedIPGroupsWithDetails", eventType, htmlAdditionalInfo);}
  140. virtual void OnCreateSharedIPGroup(RackspaceEventType eventType, const char *htmlAdditionalInfo) {ExecuteDefault("OnCreateSharedIPGroup", eventType, htmlAdditionalInfo);}
  141. virtual void OnGetSharedIPGroupDetails(RackspaceEventType eventType, const char *htmlAdditionalInfo) {ExecuteDefault("OnGetSharedIPGroupDetails", eventType, htmlAdditionalInfo);}
  142. virtual void OnDeleteSharedIPGroup(RackspaceEventType eventType, const char *htmlAdditionalInfo) {ExecuteDefault("OnDeleteSharedIPGroup", eventType, htmlAdditionalInfo);}
  143. virtual void OnConnectionAttemptFailure(RackspaceOperationType operationType, const char *url) {(void) operationType; (void) url;}
  144. };
  145. /// \brief Code that uses the TCPInterface class to communicate with the Rackspace API servers
  146. /// \pre Compile RakNet with OPEN_SSL_CLIENT_SUPPORT set to 1
  147. /// \pre Packets returned from TCPInterface::OnReceive() must be passed to Rackspace::OnReceive()
  148. /// \pre Packets returned from TCPInterface::HasLostConnection() must be passed to Rackspace::OnClosedConnection()
  149. class RAK_DLL_EXPORT Rackspace
  150. {
  151. public:
  152. Rackspace();
  153. ~Rackspace();
  154. /// \brief Authenticate with Rackspace servers, required before executing any commands.
  155. /// \details All requests to authenticate and operate against Cloud Servers are performed using SSL over HTTP (HTTPS) on TCP port 443.
  156. /// Times out after 24 hours - if you get RET_Authenticate_Unauthorized in the RackspaceEventCallback callback, call again
  157. /// \sa RackspaceEventCallback::OnAuthenticationResult()
  158. /// \param[in] _tcpInterface An instance of TCPInterface, build with OPEN_SSL_CLIENT_SUPPORT 1 and already started
  159. /// \param[in] _authenticationURL See http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide-20110112.pdf . US-based accounts authenticate through auth.api.rackspacecloud.com. UK-based accounts authenticate through lon.auth.api.rackspacecloud.com
  160. /// \param[in] _rackspaceCloudUsername Username you registered with Rackspace on their website
  161. /// \param[in] _apiAccessKey Obtain your API access key from the Rackspace Cloud Control Panel in the Your Account API Access section.
  162. /// \return The address of the authentication server, or UNASSIGNED_SYSTEM_ADDRESS if the connection attempt failed
  163. SystemAddress Authenticate(TCPInterface *_tcpInterface, const char *_authenticationURL, const char *_rackspaceCloudUsername, const char *_apiAccessKey);
  164. /// \brief Get a list of running servers
  165. /// \sa http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide-20110112.pdf
  166. /// \sa RackspaceEventCallback::OnListServersResult()
  167. void ListServers(void);
  168. /// \brief Get a list of running servers, with extended details on each server
  169. /// \sa GetServerDetails()
  170. /// \sa http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide-20110112.pdf
  171. /// \sa RackspaceEventCallback::OnListServersWithDetailsResult()
  172. void ListServersWithDetails(void);
  173. /// \brief Create a server
  174. /// \details Create a server with a given image (harddrive contents) and flavor (hardware configuration)
  175. /// Get the available images with ListImages()
  176. /// Get the available flavors with ListFlavors()
  177. /// It is possible to configure the server in more detail. See the XML schema at http://docs.rackspacecloud.com/servers/api/v1.0
  178. /// You can execute such a custom command by calling AddOperation() manually. See the implementation of CreateServer for how to do so.
  179. /// The server takes a while to build. Call GetServerDetails() to get the current build status. Server id to pass to GetServerDetails() is returned in the field <server ... id="1234">
  180. /// \sa http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide-20110112.pdf
  181. /// \sa RackspaceEventCallback::OnCreateServerResult()
  182. /// \param[in] name Name of the server. Only alphanumeric characters, periods, and hyphens are valid. Server Name cannot start or end with a period or hyphen.
  183. /// \param[in] imageId Which image (harddrive contents, including OS) to use
  184. /// \param[in] flavorId Which flavor (hardware config) to use, primarily how much memory is available.
  185. void CreateServer(RakNet::RakString name, RakNet::RakString imageId, RakNet::RakString flavorId);
  186. /// \brief Get details on a particular server
  187. /// \sa http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide-20110112.pdf
  188. /// \sa RackspaceEventCallback::OnGetServerDetailsResult()
  189. /// \param[in] serverId Which server to get details on. You can call ListServers() to get the list of active servers.
  190. void GetServerDetails(RakNet::RakString serverId);
  191. /// \brief Changes the name or password for a server
  192. /// \sa http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide-20110112.pdf
  193. /// \sa RackspaceEventCallback::OnUpdateServerNameOrPasswordResult()
  194. /// \param[in] serverId Which server to get details on. You can call ListServers() to get the list of active servers.
  195. /// \param[in] newName The new server name. Leave blank to leave unchanged. Only alphanumeric characters, periods, and hyphens are valid. Server Name cannot start or end with a period or hyphen.
  196. /// \param[in] newPassword The new server password. Leave blank to leave unchanged.
  197. void UpdateServerNameOrPassword(RakNet::RakString serverId, RakNet::RakString newName, RakNet::RakString newPassword);
  198. /// \brief Deletes a server
  199. /// \sa http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide-20110112.pdf
  200. /// \sa RackspaceEventCallback::OnDeleteServerResult()
  201. /// \param[in] serverId Which server to get details on. You can call ListServers() to get the list of active servers.
  202. void DeleteServer(RakNet::RakString serverId);
  203. /// \brief Lists the IP addresses available to a server
  204. /// \sa http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide-20110112.pdf
  205. /// \sa RackspaceEventCallback::OnListServerAddressesResult()
  206. /// \param[in] serverId Which server to operate on. You can call ListServers() to get the list of active servers.
  207. void ListServerAddresses(RakNet::RakString serverId);
  208. /// \brief Shares an IP address with a server
  209. /// \sa http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide-20110112.pdf
  210. /// \sa RackspaceEventCallback::OnShareServerAddressResult()
  211. /// \param[in] serverId Which server to operate on. You can call ListServers() to get the list of active servers.
  212. /// \param[in] ipAddress Which IP address. You can call ListServerAddresses() to get the list of addresses for the specified server
  213. void ShareServerAddress(RakNet::RakString serverId, RakNet::RakString ipAddress);
  214. /// \brief Stops sharing an IP address with a server
  215. /// \sa http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide-20110112.pdf
  216. /// \sa RackspaceEventCallback::OnDeleteServerAddressResult()
  217. /// \param[in] serverId Which server to operate on. You can call ListServers() to get the list of active servers.
  218. /// \param[in] ipAddress Which IP address. You can call ListServerAddresses() to get the list of addresses for the specified server
  219. void DeleteServerAddress(RakNet::RakString serverId, RakNet::RakString ipAddress);
  220. /// \brief Reboots a server
  221. /// \sa http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide-20110112.pdf
  222. /// \sa RackspaceEventCallback::OnRebootServerResult()
  223. /// \param[in] serverId Which server to operate on. You can call ListServers() to get the list of active servers.
  224. /// \param[in] rebootType Should be either "HARD" or "SOFT"
  225. void RebootServer(RakNet::RakString serverId, RakNet::RakString rebootType);
  226. /// \brief Rebuilds a server with a different image (harddrive contents)
  227. /// \sa http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide-20110112.pdf
  228. /// \sa RackspaceEventCallback::OnRebuildServerResult()
  229. /// \param[in] serverId Which server to operate on. You can call ListServers() to get the list of active servers.
  230. /// \param[in] imageId Which image (harddrive contents, including OS) to use
  231. void RebuildServer(RakNet::RakString serverId, RakNet::RakString imageId);
  232. /// \brief Changes the hardware configuration of a server. This does not take effect until you call ConfirmResizedServer()
  233. /// \sa http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide-20110112.pdf
  234. /// \sa RackspaceEventCallback::OnResizeServerResult()
  235. /// \sa RevertResizedServer()
  236. /// \param[in] serverId Which server to operate on. You can call ListServers() to get the list of active servers.
  237. /// \param[in] flavorId Which flavor (hardware config) to use, primarily how much memory is available.
  238. void ResizeServer(RakNet::RakString serverId, RakNet::RakString flavorId);
  239. /// \brief Confirm a resize for the specified server
  240. /// \sa http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide-20110112.pdf
  241. /// \sa RackspaceEventCallback::OnConfirmResizedServerResult()
  242. /// \sa ResizeServer()
  243. /// \param[in] serverId Which server to operate on. You can call ListServers() to get the list of active servers.
  244. void ConfirmResizedServer(RakNet::RakString serverId);
  245. /// \brief Reverts a resize for the specified server
  246. /// \sa http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide-20110112.pdf
  247. /// \sa RackspaceEventCallback::OnRevertResizedServerResult()
  248. /// \sa ResizeServer()
  249. /// \param[in] serverId Which server to operate on. You can call ListServers() to get the list of active servers.
  250. void RevertResizedServer(RakNet::RakString serverId);
  251. /// \brief List all flavors (hardware configs, primarily memory)
  252. /// \sa http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide-20110112.pdf
  253. /// \sa RackspaceEventCallback::OnListFlavorsResult()
  254. void ListFlavors(void);
  255. /// \brief Get extended details about a specific flavor
  256. /// \sa http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide-20110112.pdf
  257. /// \sa RackspaceEventCallback::OnGetFlavorDetailsResult()
  258. /// \sa ListFlavors()
  259. /// \param[in] flavorId Which flavor (hardware config)
  260. void GetFlavorDetails(RakNet::RakString flavorId);
  261. /// \brief List all images (software configs, including operating systems), which includes images you create yourself
  262. /// \sa http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide-20110112.pdf
  263. /// \sa RackspaceEventCallback::OnListImagesResult()
  264. /// \sa CreateImage()
  265. void ListImages(void);
  266. /// \brief Images a running server. This essentially copies the harddrive, and lets you start a server with the same harddrive contents later
  267. /// \sa http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide-20110112.pdf
  268. /// \sa RackspaceEventCallback::OnCreateImageResult()
  269. /// \sa ListImages()
  270. /// \param[in] serverId Which server to operate on. You can call ListServers() to get the list of active servers.
  271. /// \param[in] imageName What to call this image
  272. void CreateImage(RakNet::RakString serverId, RakNet::RakString imageName);
  273. /// \brief Get extended details about a particular image
  274. /// \sa http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide-20110112.pdf
  275. /// \sa RackspaceEventCallback::OnGetImageDetailsResult()
  276. /// \sa ListImages()
  277. /// \param[in] imageId Which image
  278. void GetImageDetails(RakNet::RakString imageId);
  279. /// \brief Delete a custom image created with CreateImage()
  280. /// \sa http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide-20110112.pdf
  281. /// \sa RackspaceEventCallback::OnDeleteImageResult()
  282. /// \sa ListImages()
  283. /// \param[in] imageId Which image
  284. void DeleteImage(RakNet::RakString imageId);
  285. /// \brief List IP groups
  286. /// \sa http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide-20110112.pdf
  287. /// \sa RackspaceEventCallback::OnListSharedIPGroupsResult()
  288. void ListSharedIPGroups(void);
  289. /// \brief List IP groups with extended details
  290. /// \sa http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide-20110112.pdf
  291. /// \sa RackspaceEventCallback::OnListSharedIPGroupsWithDetailsResult()
  292. void ListSharedIPGroupsWithDetails(void);
  293. // I don't know what this does
  294. void CreateSharedIPGroup(RakNet::RakString name, RakNet::RakString optionalServerId);
  295. // I don't know what this does
  296. void GetSharedIPGroupDetails(RakNet::RakString groupId);
  297. // I don't know what this does
  298. void DeleteSharedIPGroup(RakNet::RakString groupId);
  299. /// \brief Adds a callback to the list of callbacks to be called when any of the above functions finish executing
  300. /// The callbacks are called in the order they are added
  301. void AddEventCallback(Rackspace2EventCallback *callback);
  302. /// \brief Removes a callback from the list of callbacks to be called when any of the above functions finish executing
  303. /// The callbacks are called in the order they are added
  304. void RemoveEventCallback(Rackspace2EventCallback *callback);
  305. /// \brief Removes all callbacks
  306. void ClearEventCallbacks(void);
  307. /// Call this anytime TCPInterface returns a packet
  308. void OnReceive(Packet *packet);
  309. /// Call this when TCPInterface returns something other than UNASSIGNED_SYSTEM_ADDRESS from HasLostConnection()
  310. void OnClosedConnection(SystemAddress systemAddress);
  311. /// String representation of each RackspaceEventType
  312. static const char * EventTypeToString(RackspaceEventType eventType);
  313. /// \brief Mostly for internal use, but you can use it to execute an operation with more complex xml if desired
  314. /// See the Rackspace.cpp on how to use it
  315. void AddOperation(RackspaceOperationType type, RakNet::RakString httpCommand, RakNet::RakString operation, RakNet::RakString xml);
  316. protected:
  317. DataStructures::List<Rackspace2EventCallback*> eventCallbacks;
  318. struct RackspaceOperation
  319. {
  320. RackspaceOperationType type;
  321. // RakNet::RakString stringInfo;
  322. SystemAddress connectionAddress;
  323. bool isPendingAuthentication;
  324. RakNet::RakString incomingStream;
  325. RakNet::RakString httpCommand;
  326. RakNet::RakString operation;
  327. RakNet::RakString xml;
  328. };
  329. TCPInterface *tcpInterface;
  330. // RackspaceOperationType currentOperation;
  331. // DataStructures::Queue<RackspaceOperation> nextOperationQueue;
  332. DataStructures::List<RackspaceOperation> operations;
  333. bool HasOperationOfType(RackspaceOperationType t);
  334. unsigned int GetOperationOfTypeIndex(RackspaceOperationType t);
  335. RakNet::RakString serverManagementURL;
  336. RakNet::RakString serverManagementDomain;
  337. RakNet::RakString serverManagementPath;
  338. RakNet::RakString storageURL;
  339. RakNet::RakString storageDomain;
  340. RakNet::RakString storagePath;
  341. RakNet::RakString cdnManagementURL;
  342. RakNet::RakString cdnManagementDomain;
  343. RakNet::RakString cdnManagementPath;
  344. RakNet::RakString storageToken;
  345. RakNet::RakString authToken;
  346. RakNet::RakString rackspaceCloudUsername;
  347. RakNet::RakString apiAccessKey;
  348. bool ExecuteOperation(RackspaceOperation &ro);
  349. void ReadLine(const char *data, const char *stringStart, RakNet::RakString &output);
  350. bool ConnectToServerManagementDomain(RackspaceOperation &ro);
  351. };
  352. } // namespace RakNet
  353. #endif // __RACKSPACE_API_H
  354. #endif // _RAKNET_SUPPORT_Rackspace
粤ICP备19079148号