Skip to content

Commit a90129b

Browse files
committed
Support operator-only properties on a network resource
Enables creating an external network
1 parent 3b27e6b commit a90129b

5 files changed

Lines changed: 61 additions & 12 deletions

File tree

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using System.Collections.Generic;
22
using Newtonsoft.Json;
3+
using Newtonsoft.Json.Linq;
4+
using OpenStack.Serialization;
35

46
namespace OpenStack.Networking.v2
57
{
@@ -10,7 +12,8 @@ namespace OpenStack.Networking.v2
1012
/// </para>
1113
/// </summary>
1214
/// <threadsafety static="true" instance="false"/>
13-
public class Network : NetworkDefinition
15+
[JsonConverterWithConstructor(typeof(RootWrapperConverter), "network")]
16+
public class Network : IHaveExtraData, IServiceResource
1417
{
1518
/// <summary>
1619
/// The network identifier.
@@ -19,23 +22,29 @@ public class Network : NetworkDefinition
1922
public Identifier Id { get; set; }
2023

2124
/// <summary>
22-
/// The administrative state of the network.
25+
/// The network name.
2326
/// </summary>
24-
[JsonProperty("admin_state_up")]
25-
public bool IsUp { get; set; }
27+
[JsonProperty("name")]
28+
public string Name { get; set; }
2629

2730
/// <summary>
28-
/// The tenant identifier.
31+
/// The administrative state of the network.
2932
/// </summary>
30-
[JsonProperty("tenant_id")]
31-
public string TenantId { get; set; }
33+
[JsonProperty("admin_state_up")]
34+
public bool IsUp { get; set; }
3235

3336
/// <summary>
3437
/// Indicates whether this network is shared across all tenants.
3538
/// </summary>
3639
[JsonProperty("shared")]
3740
public bool IsShared { get; set; }
3841

42+
/// <summary>
43+
/// Indicates whether this network is externally accessible.
44+
/// </summary>
45+
[JsonProperty("router:external")]
46+
public bool IsExternal { get; set; }
47+
3948
/// <summary>
4049
/// The network status.
4150
/// </summary>
@@ -46,6 +55,11 @@ public class Network : NetworkDefinition
4655
/// The associated subnet identifiers.
4756
/// </summary>
4857
[JsonProperty("subnets")]
49-
public IList<Identifier> Subnets { get; set; }
58+
public IList<Identifier> Subnets { get; set; }
59+
60+
[JsonExtensionData]
61+
IDictionary<string, JToken> IHaveExtraData.Data { get; set; } = new Dictionary<string, JToken>();
62+
63+
object IServiceResource.Owner { get; set; }
5064
}
5165
}
Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
using System.Collections.Generic;
12
using Newtonsoft.Json;
3+
using Newtonsoft.Json.Linq;
24
using OpenStack.Serialization;
35

46
namespace OpenStack.Networking.v2
@@ -8,12 +10,17 @@ namespace OpenStack.Networking.v2
810
/// </summary>
911
/// <threadsafety static="true" instance="false"/>
1012
[JsonConverterWithConstructor(typeof(RootWrapperConverter), "network")]
11-
public class NetworkDefinition
13+
public class NetworkDefinition : IHaveExtraData
1214
{
13-
/// <summary>
14-
/// The network name.
15-
/// </summary>
15+
/// <inheritdoc cref="Network.Name" />
1616
[JsonProperty("name")]
1717
public string Name { get; set; }
18+
19+
/// <inheritdoc cref="Network.IsUp" />
20+
[JsonProperty("admin_state_up")]
21+
public bool? IsUp { get; set; }
22+
23+
[JsonExtensionData]
24+
IDictionary<string, JToken> IHaveExtraData.Data { get; set; } = new Dictionary<string, JToken>();
1825
}
1926
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System.Runtime.CompilerServices;
2+
3+
namespace OpenStack.Networking.v2.Operator
4+
{
5+
/// <summary>
6+
/// The <see cref="Operator"/> namespace defines additional functionality that is restricted to cloud operators only.
7+
/// </summary>
8+
[CompilerGenerated]
9+
internal class NamespaceDoc
10+
{
11+
}
12+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using Newtonsoft.Json;
2+
3+
namespace OpenStack.Networking.v2.Operator
4+
{
5+
/// <summary>
6+
/// Extended definition of a network resource, with cloud operator functionality exposed.
7+
/// </summary>
8+
public class NetworkDefinition : v2.NetworkDefinition
9+
{
10+
/// <inheritdoc cref="Network.IsExternal" />
11+
[JsonProperty("router:external")]
12+
public bool? IsExternal { get; set; }
13+
}
14+
}

src/corelib/OpenStack.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@
211211
<Compile Include="Networking\v2\NetworkingService.cs" />
212212
<Compile Include="Networking\v2\NetworkingServiceExtensions.cs" />
213213
<Compile Include="Networking\v2\Network.cs" />
214+
<Compile Include="Networking\v2\Operator\NamespaceDoc.cs" />
215+
<Compile Include="Networking\v2\Operator\NetworkDefinition.cs" />
214216
<Compile Include="Networking\v2\Serialization\FloatingIPCollection.cs" />
215217
<Compile Include="Networking\v2\Serialization\FloatingIPStatus.cs" />
216218
<Compile Include="Networking\v2\PortUpdateDefinition.cs" />

0 commit comments

Comments
 (0)