|
| 1 | +namespace net.openstack.Providers.Rackspace.Objects.Dns |
| 2 | +{ |
| 3 | + using System; |
| 4 | + using System.Collections.Generic; |
| 5 | + using System.Collections.ObjectModel; |
| 6 | + using System.Linq; |
| 7 | + using Newtonsoft.Json; |
| 8 | + |
| 9 | + /// <summary> |
| 10 | + /// Represents the configuration of a collection of domains being added to the DNS service. |
| 11 | + /// </summary> |
| 12 | + /// <remarks> |
| 13 | + /// <note type="inherit"> |
| 14 | + /// This class can be extended if a server extension requires additional information (beyond |
| 15 | + /// the <c>domains</c> property which is already supported) be sent in the body of a |
| 16 | + /// <strong>Create Domain</strong> API call. |
| 17 | + /// </note> |
| 18 | + /// </remarks> |
| 19 | + /// <seealso cref="IDnsService.CreateDomainsAsync"/> |
| 20 | + /// <threadsafety static="true" instance="false"/> |
| 21 | + /// <preliminary/> |
| 22 | + [JsonObject(MemberSerialization.OptIn)] |
| 23 | + public class DnsConfiguration |
| 24 | + { |
| 25 | + /// <summary> |
| 26 | + /// This is the backing field for the <see cref="DomainConfigurations"/> property. |
| 27 | + /// </summary> |
| 28 | + [JsonProperty("domains")] |
| 29 | + private readonly DnsDomainConfiguration[] _domainConfiguration; |
| 30 | + |
| 31 | + /// <summary> |
| 32 | + /// Initializes a new instance of the <see cref="DnsConfiguration"/> class for the |
| 33 | + /// specified domains. |
| 34 | + /// </summary> |
| 35 | + /// <param name="domainConfigurations">A collection of <see cref="DnsDomainConfiguration"/> objects describing the domains.</param> |
| 36 | + /// <exception cref="ArgumentNullException">If <paramref name="domainConfigurations"/> is <c>null</c>.</exception> |
| 37 | + /// <exception cref="ArgumentException">If <paramref name="domainConfigurations"/> contains a <c>null</c> value.</exception> |
| 38 | + public DnsConfiguration(params DnsDomainConfiguration[] domainConfigurations) |
| 39 | + : this(domainConfigurations.AsEnumerable()) |
| 40 | + { |
| 41 | + } |
| 42 | + |
| 43 | + /// <summary> |
| 44 | + /// Initializes a new instance of the <see cref="DnsConfiguration"/> class for the |
| 45 | + /// specified domains. |
| 46 | + /// </summary> |
| 47 | + /// <param name="domainConfigurations">A collection of <see cref="DnsDomainConfiguration"/> objects describing the domains.</param> |
| 48 | + /// <exception cref="ArgumentNullException">If <paramref name="domainConfigurations"/> is <c>null</c>.</exception> |
| 49 | + /// <exception cref="ArgumentException">If <paramref name="domainConfigurations"/> contains a <c>null</c> value.</exception> |
| 50 | + public DnsConfiguration(IEnumerable<DnsDomainConfiguration> domainConfigurations) |
| 51 | + { |
| 52 | + if (domainConfigurations == null) |
| 53 | + throw new ArgumentNullException("domainConfigurations"); |
| 54 | + |
| 55 | + _domainConfiguration = domainConfigurations.ToArray(); |
| 56 | + |
| 57 | + if (_domainConfiguration.Contains(null)) |
| 58 | + throw new ArgumentException("domainConfigurations cannot contain any null values.", "domainConfigurations"); |
| 59 | + } |
| 60 | + |
| 61 | + /// <summary> |
| 62 | + /// Gets a collection of the <see cref="DnsDomainConfiguration"/> objects describing |
| 63 | + /// domains in this configuration. |
| 64 | + /// </summary> |
| 65 | + public ReadOnlyCollection<DnsDomainConfiguration> DomainConfigurations |
| 66 | + { |
| 67 | + get |
| 68 | + { |
| 69 | + return new ReadOnlyCollection<DnsDomainConfiguration>(_domainConfiguration); |
| 70 | + } |
| 71 | + } |
| 72 | + } |
| 73 | +} |
0 commit comments