PageRenderTime 5418ms CodeModel.GetById 111ms RepoModel.GetById 1ms app.codeStats 0ms

/redistributable/openstack.net/src/corelib/Providers/Rackspace/Objects/Request/CreateServerRequest.cs

https://gitlab.com/rekby-archive/onlyoffice-CommunityServer
C# | 166 lines | 64 code | 15 blank | 87 comment | 3 complexity | 7f2ffc33667c8845ea57d70757238744 MD5 | raw file
  1. namespace net.openstack.Providers.Rackspace.Objects.Request
  2. {
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using net.openstack.Core.Domain;
  7. using Newtonsoft.Json;
  8. /// <summary>
  9. /// This models the JSON request used for the Create Server request.
  10. /// </summary>
  11. /// <seealso href="http://docs.openstack.org/api/openstack-compute/2/content/CreateServers.html">Create Server (OpenStack Compute API v2 and Extensions Reference)</seealso>
  12. /// <threadsafety static="true" instance="false"/>
  13. [JsonObject(MemberSerialization.OptIn)]
  14. internal class CreateServerRequest
  15. {
  16. /// <summary>
  17. /// Gets additional details about the Create Server request.
  18. /// </summary>
  19. [JsonProperty("server")]
  20. public CreateServerDetails Details { get; private set; }
  21. /// <summary>
  22. /// Initializes a new instance of the <see cref="CreateServerRequest"/> class
  23. /// with the specified details.
  24. /// </summary>
  25. /// <param name="name">Name of the new server.</param>
  26. /// <param name="imageName">The image to use for the new server instance. This is
  27. /// specified as an image ID (see <see cref="SimpleServerImage.Id"/>) or a full URL.</param>
  28. /// <param name="flavor">The flavor to use for the new server instance. This
  29. /// is specified as a flavor ID (see <see cref="Flavor.Id"/>) or a full URL.</param>
  30. /// <param name="diskConfig">The disk configuration. If the value is <see langword="null"/>, the default configuration for the specified image is used.</param>
  31. /// <param name="metadata">The metadata to associate with the server.</param>
  32. /// <param name="personality">A collection of <see cref="Personality"/> objects describing the paths and contents of files to inject in the target file system during the creation process. If the value is <see langword="null"/>, no files are injected.</param>
  33. /// <param name="accessIPv4">The behavior of this value is unspecified. Do not use.</param>
  34. /// <param name="accessIPv6">The behavior of this value is unspecified. Do not use.</param>
  35. /// <param name="networks">A collection of identifiers for networks to initially connect to the server. These are obtained from <see cref="CloudNetwork.Id">CloudNetwork.Id</see></param>
  36. public CreateServerRequest(string name, string imageName, string flavor, DiskConfiguration diskConfig, Dictionary<string, string> metadata, string accessIPv4, string accessIPv6, IEnumerable<string> networks, IEnumerable<Personality> personality)
  37. {
  38. Details = new CreateServerDetails(name, imageName, flavor, diskConfig, metadata, accessIPv4, accessIPv6, networks, personality);
  39. }
  40. /// <summary>
  41. /// This models the JSON body containing details for a Create Server request.
  42. /// </summary>
  43. /// <threadsafety static="true" instance="false"/>
  44. [JsonObject(MemberSerialization.OptIn)]
  45. public class CreateServerDetails
  46. {
  47. /// <summary>
  48. /// Gets the name of the new server to create.
  49. /// </summary>
  50. [JsonProperty("name")]
  51. public string Name { get; private set; }
  52. /// <summary>
  53. /// Gets the image to use for the new server instance. This is
  54. /// specified as an image ID (see <see cref="SimpleServerImage.Id"/>) or a full URL.
  55. /// </summary>
  56. [JsonProperty("imageRef")]
  57. public string ImageName { get; private set; }
  58. /// <summary>
  59. /// Gets the flavor to use for the new server instance. This
  60. /// is specified as a flavor ID (see <see cref="net.openstack.Core.Domain.Flavor.Id"/>) or a full URL.
  61. /// </summary>
  62. [JsonProperty("flavorRef")]
  63. public string Flavor { get; private set; }
  64. /// <summary>
  65. /// Gets the disk configuration. If the value is <see langword="null"/>, the default configuration for the specified image is used.
  66. /// </summary>
  67. [JsonProperty("OS-DCF:diskConfig")]
  68. public DiskConfiguration DiskConfig { get; private set; }
  69. /// <summary>
  70. /// Gets the metadata to associate with the server.
  71. /// </summary>
  72. [JsonProperty("metadata", DefaultValueHandling = DefaultValueHandling.Include)]
  73. public Dictionary<string, string> Metadata { get; private set; }
  74. /// <summary>
  75. /// The behavior of this value is unspecified. Do not use.
  76. /// </summary>
  77. [JsonProperty("accessIPv4", DefaultValueHandling = DefaultValueHandling.Include)]
  78. public string AccessIPv4 { get; private set; }
  79. /// <summary>
  80. /// The behavior of this value is unspecified. Do not use.
  81. /// </summary>
  82. [JsonProperty("accessIPv6", DefaultValueHandling = DefaultValueHandling.Include)]
  83. public string AccessIPv6 { get; private set; }
  84. /// <summary>
  85. /// Gets a collection of information about networks to initially connect to the server.
  86. /// </summary>
  87. [JsonProperty("networks", DefaultValueHandling = DefaultValueHandling.Include)]
  88. public NewServerNetwork[] Networks { get; private set; }
  89. /// <summary>
  90. /// Gets a collection of <see cref="Personality"/> objects describing the paths and
  91. /// contents of files to inject in the target file system during the creation process.
  92. /// If the value is <see langword="null"/>, no files are injected.
  93. /// </summary>
  94. [JsonProperty("personality", DefaultValueHandling = DefaultValueHandling.Include)]
  95. public Personality[] Personality { get; private set; }
  96. /// <summary>
  97. /// Initializes a new instance of the <see cref="CreateServerDetails"/> class
  98. /// with the specified details.
  99. /// </summary>
  100. /// <param name="name">Name of the new server.</param>
  101. /// <param name="imageName">The image to use for the new server instance. This is
  102. /// specified as an image ID (see <see cref="SimpleServerImage.Id"/>) or a full URL.</param>
  103. /// <param name="flavor">The flavor to use for the new server instance. This
  104. /// is specified as a flavor ID (see <see cref="net.openstack.Core.Domain.Flavor.Id"/>) or a full URL.</param>
  105. /// <param name="diskConfig">The disk configuration. If the value is <see langword="null"/>, the default configuration for the specified image is used.</param>
  106. /// <param name="metadata">The metadata to associate with the server.</param>
  107. /// <param name="personality">A collection of <see cref="Personality"/> objects describing the paths and contents of files to inject in the target file system during the creation process. If the value is <see langword="null"/>, no files are injected.</param>
  108. /// <param name="accessIPv4">The behavior of this value is unspecified. Do not use.</param>
  109. /// <param name="accessIPv6">The behavior of this value is unspecified. Do not use.</param>
  110. /// <param name="networks">A collection of identifiers for networks to initially connect to the server. These are obtained from <see cref="CloudNetwork.Id">CloudNetwork.Id</see></param>
  111. public CreateServerDetails(string name, string imageName, string flavor, DiskConfiguration diskConfig, Dictionary<string, string> metadata, string accessIPv4, string accessIPv6, IEnumerable<string> networks, IEnumerable<Personality> personality)
  112. {
  113. Name = name;
  114. ImageName = imageName;
  115. Flavor = flavor;
  116. DiskConfig = diskConfig;
  117. Metadata = metadata;
  118. AccessIPv4 = accessIPv4;
  119. AccessIPv6 = accessIPv6;
  120. Networks = networks.Select(i => new NewServerNetwork(i)).ToArray();
  121. Personality = personality != null ? personality.ToArray() : null;
  122. }
  123. /// <summary>
  124. /// This models the JSON body containing details for a connected network
  125. /// within the Create Server request.
  126. /// </summary>
  127. /// <threadsafety static="true" instance="false"/>
  128. [JsonObject(MemberSerialization.OptIn)]
  129. public class NewServerNetwork
  130. {
  131. /// <summary>
  132. /// Gets the ID of the network.
  133. /// </summary>
  134. /// <seealso cref="CloudNetwork.Id"/>
  135. [JsonProperty("uuid")]
  136. public string NetworkId { get; private set; }
  137. /// <summary>
  138. /// Initializes a new instance of the <see cref="NewServerNetwork"/> class
  139. /// with the specified ID.
  140. /// </summary>
  141. /// <param name="networkId">The network ID. This is obtained from <see cref="CloudNetwork.Id">CloudNetwork.Id</see>.</param>
  142. public NewServerNetwork(string networkId)
  143. {
  144. if (networkId == null)
  145. throw new ArgumentNullException("networkId");
  146. NetworkId = networkId;
  147. }
  148. }
  149. }
  150. }
  151. }