Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API to add an IpSecurityRestriction while Defining a WebApp #548

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,28 @@ WebAppBase.Definition.IWithCreate<FluentT> WebAppBase.Definition.IWithWebContain
return this.WithWebContainer(webContainer);
}

/// <summary>
/// WithIpSecurityRestriction
/// </summary>
/// <param name="ipAddress">IP address the security restriction is
/// valid for.
/// It can be in form of pure ipv4 address (required SubnetMask
/// property) or
/// CIDR notation such as ipv4/mask (leading bit match). For CIDR,
/// SubnetMask property must not be specified.</param>
/// <param name="subnetMask">Subnet mask for the range of IP addresses
/// the restriction is valid for.</param>
/// <param name="action">Allow or Deny access for this IP
/// range.</param>
/// <param name="priority">Priority of IP restriction rule.</param>
/// <param name="name">IP restriction rule name.</param>
/// <param name="description">IP restriction rule description.</param>
/// <return>The next stage of the definition.</return>
WebAppBase.Definition.IWithCreate<FluentT> WebAppBase.Definition.IWithIpSecurityRestriction<FluentT>.WithIpSecurityRestriction(string ipAddress, string subnetMask = default(string), string action = default(string), int? priority = default(int?), string name = default(string), string description = default(string))
{
return this.WithIpSecurityRestriction(ipAddress, subnetMask, action, priority, name, description);
}

/// <return>The connection strings defined on the web app.</return>
async Task<System.Collections.Generic.IReadOnlyDictionary<string,Microsoft.Azure.Management.AppService.Fluent.IConnectionString>> Microsoft.Azure.Management.AppService.Fluent.IWebAppBase.GetConnectionStringsAsync(CancellationToken cancellationToken)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,8 @@ public interface IWithCreate<FluentT> :
Microsoft.Azure.Management.AppService.Fluent.WebAppBase.Definition.IWithHostNameSslBinding<FluentT>,
Microsoft.Azure.Management.AppService.Fluent.WebAppBase.Definition.IWithAuthentication<FluentT>,
Microsoft.Azure.Management.AppService.Fluent.WebAppBase.Definition.IWithDiagnosticLogging<FluentT>,
Microsoft.Azure.Management.AppService.Fluent.WebAppBase.Definition.IWithManagedServiceIdentity<FluentT>
Microsoft.Azure.Management.AppService.Fluent.WebAppBase.Definition.IWithManagedServiceIdentity<FluentT>,
Microsoft.Azure.Management.AppService.Fluent.WebAppBase.Definition.IWithIpSecurityRestriction<FluentT>
{

}
Expand Down Expand Up @@ -509,4 +510,9 @@ public interface IWithSourceControl<FluentT>
/// <return>The next stage of the definition.</return>
Microsoft.Azure.Management.AppService.Fluent.WebAppBase.Definition.IWithCreate<FluentT> WithLocalGitSourceControl();
}

public interface IWithIpSecurityRestriction<FluentT>
{
Microsoft.Azure.Management.AppService.Fluent.WebAppBase.Definition.IWithCreate<FluentT> WithIpSecurityRestriction(string ipAddress, string subnetMask = default(string), string action = default(string), int? priority = default(int?), string name = default(string), string description = default(string));
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
// <auto-generated>
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for
// license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
// </auto-generated>

namespace Microsoft.Azure.Management.AppService.Fluent.Models
{
using Microsoft.Rest;
Expand All @@ -29,13 +21,30 @@ public IpSecurityRestriction()
/// Initializes a new instance of the IpSecurityRestriction class.
/// </summary>
/// <param name="ipAddress">IP address the security restriction is
/// valid for.</param>
/// valid for.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dpetillo
you can undo these changes, The model got updated with these properties added to it :

public IpSecurityRestriction(string ipAddress = default(string), string subnetMask = default(string), string vnetSubnetResourceId = default(string), int? vnetTrafficTag = default(int?), int? subnetTrafficTag = default(int?), string action = default(string), IpFilterTag? tag = default(IpFilterTag?), int? priority = default(int?), string name = default(string), string description = default(string))

/// It can be in form of pure ipv4 address (required SubnetMask
/// property) or
/// CIDR notation such as ipv4/mask (leading bit match). For CIDR,
/// SubnetMask property must not be specified.</param>
/// <param name="subnetMask">Subnet mask for the range of IP addresses
/// the restriction is valid for.</param>
public IpSecurityRestriction(string ipAddress, string subnetMask = default(string))
/// <param name="action">Allow or Deny access for this IP
/// range.</param>
/// <param name="tag">Defines what this IP filter will be used for.
/// This is to support IP filtering on proxies. Possible values
/// include: 'Default', 'XffProxy'</param>
/// <param name="priority">Priority of IP restriction rule.</param>
/// <param name="name">IP restriction rule name.</param>
/// <param name="description">IP restriction rule description.</param>
public IpSecurityRestriction(string ipAddress, string subnetMask = default(string), string action = default(string), int? priority = default(int?), string name = default(string), string description = default(string))
{
IpAddress = ipAddress;
SubnetMask = subnetMask;
Action = action;
//Tag = tag;
Priority = priority;
Name = name;
Description = description;
CustomInit();
}

Expand All @@ -46,6 +55,10 @@ public IpSecurityRestriction()

/// <summary>
/// Gets or sets IP address the security restriction is valid for.
/// It can be in form of pure ipv4 address (required SubnetMask
/// property) or
/// CIDR notation such as ipv4/mask (leading bit match). For CIDR,
/// SubnetMask property must not be specified.
/// </summary>
[JsonProperty(PropertyName = "ipAddress")]
public string IpAddress { get; set; }
Expand All @@ -57,6 +70,38 @@ public IpSecurityRestriction()
[JsonProperty(PropertyName = "subnetMask")]
public string SubnetMask { get; set; }

/// <summary>
/// Gets or sets allow or Deny access for this IP range.
/// </summary>
[JsonProperty(PropertyName = "action")]
public string Action { get; set; }

/// <summary>
/// Gets or sets defines what this IP filter will be used for. This is
/// to support IP filtering on proxies. Possible values include:
/// 'Default', 'XffProxy'
/// </summary>
//[JsonProperty(PropertyName = "tag")]
//public IpFilterTag? Tag { get; set; }

/// <summary>
/// Gets or sets priority of IP restriction rule.
/// </summary>
[JsonProperty(PropertyName = "priority")]
public int? Priority { get; set; }

/// <summary>
/// Gets or sets IP restriction rule name.
/// </summary>
[JsonProperty(PropertyName = "name")]
public string Name { get; set; }

/// <summary>
/// Gets or sets IP restriction rule description.
/// </summary>
[JsonProperty(PropertyName = "description")]
public string Description { get; set; }

/// <summary>
/// Validate the object.
/// </summary>
Expand All @@ -71,4 +116,4 @@ public virtual void Validate()
}
}
}
}
}
16 changes: 16 additions & 0 deletions src/ResourceManagement/AppService/WebAppBaseImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,22 @@ public FluentImplT WithFtpsState(FtpsState ftpsState)
return (FluentImplT)this;
}

public FluentImplT WithIpSecurityRestriction(string ipAddress, string subnetMask = default(string), string action = default(string), int? priority = default(int?), string name = default(string), string description = default(string))
{
if (this.SiteConfig == null)
{
this.SiteConfig = new SiteConfigResourceInner();
}
if (this.SiteConfig.IpSecurityRestrictions == null)
{
this.SiteConfig.IpSecurityRestrictions = new List<IpSecurityRestriction>();
}

this.SiteConfig.IpSecurityRestrictions.Add(new IpSecurityRestriction(ipAddress, subnetMask, action, priority, name, description));

return (FluentImplT)this;
}

public FluentImplT WithVirtualApplications(IList<VirtualApplication> virtualApplications)
{
if (this.SiteConfig == null)
Expand Down
6 changes: 6 additions & 0 deletions src/ResourceManagement/AppService/WebAppImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,12 @@ public WebAppImpl WithBuiltInImage(RuntimeStack runtimeStack)
return this;
}

public WebAppImpl WithIpSecurityRestriction(string ipAddress, string subnetMask = default(string))
{
SiteConfig.IpSecurityRestrictions.Add(new IpSecurityRestriction(ipAddress, subnetMask));
return this;
}

IWithCreate IExistingWindowsPlanWithGroup.WithNewResourceGroup(string name)
{
WithNewResourceGroup(name);
Expand Down