-
Notifications
You must be signed in to change notification settings - Fork 97
Expand file tree
/
Copy pathSecurityGroupRule.cs
More file actions
87 lines (75 loc) · 2.68 KB
/
Copy pathSecurityGroupRule.cs
File metadata and controls
87 lines (75 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using OpenStack.Compute.v2_1.Serialization;
using OpenStack.Serialization;
namespace OpenStack.Compute.v2_1
{
/// <summary>
/// A security group rule.
/// </summary>
[JsonConverterWithConstructor(typeof(RootWrapperConverter), "security_group_rule")]
public class SecurityGroupRule : IHaveExtraData, IServiceResource
{
/// <summary>
/// The rule identifier.
/// </summary>
[JsonProperty("id")]
public Identifier Id { get; set; }
/// <summary>
/// The IP protocol.
/// </summary>
[JsonProperty("ip_protocol")]
public IPProtocol Protocol { get; set; }
/// <summary>
/// The port at start of range.
/// </summary>
[JsonProperty("from_port")]
public int FromPort { get; set; }
/// <summary>
/// The port at end of range.
/// </summary>
[JsonProperty("to_port")]
public int ToPort { get; set; }
/// <summary>
/// The CIDR for address range.
/// </summary>
[JsonIgnore]
public string CIDR
{
get { return _ipRange.CIDR; }
set { _ipRange.CIDR = value; }
}
[JsonProperty("ip_range")]
private CIDRWrapper _ipRange = new CIDRWrapper();
/// <summary>
/// The associated security group identifier.
/// </summary>
[JsonProperty("parent_group_id")]
public Identifier GroupId { get; set; }
/// <summary>
/// The associated source group identifier.
/// </summary>
[JsonProperty("group_id")]
public Identifier SourceGroupId { get; set; }
/// <summary />
[JsonExtensionData]
IDictionary<string, JToken> IHaveExtraData.Data { get; set; } = new Dictionary<string, JToken>();
object IServiceResource.Owner { get; set; }
/// <inheritdoc cref="ComputeApi.DeleteSecurityGroupRuleAsync" />
/// <exception cref="InvalidOperationException">When this instance was not constructed by the <see cref="ComputeService"/>, as it is missing the appropriate internal state to execute service calls.</exception>
public Task DeleteAsync(CancellationToken cancellationToken = default(CancellationToken))
{
var owner = this.GetOwnerOrThrow<ComputeApi>();
return owner.DeleteSecurityGroupRuleAsync(Id, cancellationToken);
}
private class CIDRWrapper
{
[JsonProperty("cidr")]
public string CIDR { get; set; }
}
}
}