Skip to content

Set-AzureApiManagementHostnames fix + new SDK version #1174

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

Closed
wants to merge 9 commits into from
Closed
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 @@ -106,9 +106,7 @@ private static void ConfigureSmapiToPowershellMappings()
.CreateMap<ProductContract, PsApiManagementProduct>()
.ForMember(dest => dest.ProductId, opt => opt.MapFrom(src => src.Id))
.ForMember(dest => dest.Title, opt => opt.MapFrom(src => src.Name))
.ForMember(dest => dest.LegalTerms, opt => opt.MapFrom(src => src.Terms))
.ForMember(dest => dest.NotificationPeriod, opt => opt.MapFrom(src => FormatPeriod(src.NotificationPeriod)))
.ForMember(dest => dest.SubscriptionPeriod, opt => opt.MapFrom(src => FormatPeriod(src.SubscriptionPeriod)));
.ForMember(dest => dest.LegalTerms, opt => opt.MapFrom(src => src.Terms));

Mapper
.CreateMap<SubscriptionContract, PsApiManagementSubscription>()
Expand Down Expand Up @@ -143,18 +141,6 @@ private static void ConfigureSmapiToPowershellMappings()
: new Hashtable(src.TokenBodyParameters.ToDictionary(key => key.Name, value => value.Value)));
}

private static string FormatPeriod(PeriodContract notificationPeriod)
{
if (notificationPeriod == null)
{
return null;
}

const string format = "{0}{1}";

return string.Format(format, notificationPeriod.Interval.ToString()[0], notificationPeriod.Value);
}

public ApiManagementClient(AzureContext context)
{
if (context == null)
Expand Down Expand Up @@ -594,8 +580,6 @@ public PsApiManagementProduct ProductCreate(
bool? subscriptionRequired,
bool? approvalRequired,
int? subscriptionsLimit,
string subscriptionPeriod,
string notificationPeriod,
PsApiManagementProductState? state)
{
var productContract = new ProductContract(title)
Expand All @@ -622,16 +606,6 @@ public PsApiManagementProduct ProductCreate(
}
}

if (!string.IsNullOrWhiteSpace(subscriptionPeriod))
{
productContract.SubscriptionPeriod = ParsePeriod(subscriptionPeriod);
}

if (!string.IsNullOrWhiteSpace(notificationPeriod))
{
productContract.NotificationPeriod = ParsePeriod(notificationPeriod);
}

Client.Products.Create(context.ResourceGroupName, context.ServiceName, productId, new ProductCreateParameters(productContract));
var response = Client.Products.Get(context.ResourceGroupName, context.ServiceName, productId);

Expand All @@ -647,8 +621,6 @@ public void ProductSet(
bool? subscriptionRequired,
bool? approvalRequired,
int? subscriptionsLimit,
string subscriptionPeriod,
string notificationPeriod,
PsApiManagementProductState? state)
{
var productUpdateParameters = new ProductUpdateParameters
Expand Down Expand Up @@ -676,43 +648,9 @@ public void ProductSet(
}
}

if (!string.IsNullOrWhiteSpace(subscriptionPeriod))
{
productUpdateParameters.SubscriptionPeriod = ParsePeriod(subscriptionPeriod);
}

if (!string.IsNullOrWhiteSpace(notificationPeriod))
{
productUpdateParameters.NotificationPeriod = ParsePeriod(notificationPeriod);
}

Client.Products.Update(context.ResourceGroupName, context.ServiceName, productId, productUpdateParameters, "*");
}

private static PeriodContract ParsePeriod(string period)
{
var match = PeriodRegex.Match(period);
if (!match.Success)
{
throw new ArgumentException(string.Format("Invalid period format: {0}", period), "period");
}

var periodStr = match.Groups[PeriodGroupName].Value;
var valueStr = match.Groups[ValueGroupName].Value;

var contract = new PeriodContract
{
Value = Int32.Parse(valueStr),
Interval = "d".Equals(periodStr, StringComparison.OrdinalIgnoreCase)
? PeriodIntervalContract.Day
: "m".Equals(periodStr, StringComparison.OrdinalIgnoreCase)
? PeriodIntervalContract.Month
: PeriodIntervalContract.Year
};

return contract;
}

public void ProductAddToGroup(PsApiManagementContext context, string groupId, string productId)
{
Client.ProductGroups.Add(context.ResourceGroupName, context.ServiceName, productId, groupId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@
<HintPath>..\..\..\packages\Microsoft.Azure.KeyVault.Core.1.0.0\lib\net40\Microsoft.Azure.KeyVault.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.ApiManagement, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Reference Include="Microsoft.Azure.Management.ApiManagement, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.ApiManagement.1.0.2-preview\lib\net40\Microsoft.Azure.Management.ApiManagement.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.ApiManagement.2.0.0-preview\lib\net40\Microsoft.Azure.Management.ApiManagement.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ namespace Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands
{
using System;
using System.Management.Automation;
using System.Text.RegularExpressions;
using Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models;

[Cmdlet(VerbsCommon.New, "AzureRmApiManagementProduct")]
Expand Down Expand Up @@ -73,20 +72,6 @@ public class NewAzureApiManagementProduct : AzureApiManagementCmdletBase
HelpMessage = "Maximum number of simultaneous subscriptions. This parameter is optional. Default value is 1.")]
public Int32? SubscriptionsLimit { get; set; }

[Parameter(
ValueFromPipelineByPropertyName = false,
Mandatory = false,
HelpMessage = "The period user subscriptions stays active once approved. This parameter is optional. Default value is $null. The format is: {period}{value}. Examples: D2 (two days), M6 (six months), Y1(one year).")]
[ValidatePattern(ApiManagementClient.PeriodPattern, Options = RegexOptions.Compiled)]
public String SubscriptionPeriod { get; set; }

[Parameter(
ValueFromPipelineByPropertyName = false,
Mandatory = false,
HelpMessage = "Specifies upcoming subscription expiration notification period. This parameter is optional. Default value is $null. The format is: {period}{value}. Examples: D2 (two days), M6 (six months), Y1(one year).")]
[ValidatePattern(ApiManagementClient.PeriodPattern, Options = RegexOptions.Compiled)]
public String NotificationPeriod { get; set; }

[Parameter(
ValueFromPipelineByPropertyName = true,
Mandatory = false,
Expand All @@ -106,8 +91,6 @@ public override void ExecuteApiManagementCmdlet()
SubscriptionRequired ?? true,
ApprovalRequired ?? false,
SubscriptionsLimit,
SubscriptionPeriod,
NotificationPeriod,
State);

WriteObject(product);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,6 @@ public class SetAzureApiManagementProduct : AzureApiManagementCmdletBase
HelpMessage = "Maximum number of simultaneous subscriptions. This parameter is optional. Default value is 1.")]
public Int32? SubscriptionsLimit { get; set; }

[Parameter(
ValueFromPipelineByPropertyName = true,
Mandatory = false,
HelpMessage = "The period user subscriptions stays active once approved. This parameter is optional. Default value is $null. The format is: {period}{value}. Examples: D2 (two days), M6 (six months), Y1(one year).")]
public String SubscriptionPeriod { get; set; }

[Parameter(
ValueFromPipelineByPropertyName = true,
Mandatory = false,
HelpMessage = "Specifies upcoming subscription expiration notification period. This parameter is optional. Default value is $null. The format is: {period}{value}. Examples: D2 (two days), M6 (six months), Y1(one year).")]
public String NotificationPeriod { get; set; }

[Parameter(
ValueFromPipelineByPropertyName = true,
Mandatory = false,
Expand All @@ -107,8 +95,6 @@ public override void ExecuteApiManagementCmdlet()
SubscriptionRequired,
ApprovalRequired,
SubscriptionsLimit,
SubscriptionPeriod,
NotificationPeriod,
State);

if (PassThru)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5772,20 +5772,6 @@ New-AzureRmApiManagementOperation –Context $apimContext –ApiId $apiId –Ope
</maml:description>
<command:parameterValue required="true" variableLength="true">Nullable`1[Int32]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>SubscriptionPeriod</maml:name>
<maml:description>
<maml:para>The period user subscriptions stays active once approved. This parameter is optional. Default value is $null. The format is: {period}{value}. Examples: D2 (two days), M6 (six months), Y1(one year).</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>NotificationPeriod</maml:name>
<maml:description>
<maml:para>Specifies upcoming subscription expiration notification period. This parameter is optional. Default value is $null. The format is: {period}{value}. Examples: D2 (two days), M6 (six months), Y1(one year).</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>State</maml:name>
<maml:description>
Expand Down Expand Up @@ -5907,32 +5893,6 @@ New-AzureRmApiManagementOperation –Context $apimContext –ApiId $apiId –Ope
<dev:defaultValue>
</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>SubscriptionPeriod</maml:name>
<maml:description>
<maml:para>The period user subscriptions stays active once approved. This parameter is optional. Default value is $null. The format is: {period}{value}. Examples: D2 (two days), M6 (six months), Y1(one year).</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>
</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>NotificationPeriod</maml:name>
<maml:description>
<maml:para>Specifies upcoming subscription expiration notification period. This parameter is optional. Default value is $null. The format is: {period}{value}. Examples: D2 (two days), M6 (six months), Y1(one year).</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>
</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>State</maml:name>
<maml:description>
Expand Down Expand Up @@ -6028,9 +5988,9 @@ New-AzureRmApiManagementOperation –Context $apimContext –ApiId $apiId –Ope
<maml:introduction>
<maml:paragraph>PS C:\&gt;</maml:paragraph>
</maml:introduction>
<dev:code>New-AzureRmApiManagementProduct –Context $apimContext –ProductId 9876543210 –Title Unlimited –Description 'Subscribers have completely unlimited access to the API. Administrator approval is required.' –LegalTerms 'Free for all' –ApprovalRequired $true –State Published –NotificationPeriod 'D10' –SubscriptionPeriod 'Y1'</dev:code>
<dev:code>New-AzureRmApiManagementProduct –Context $apimContext –ProductId 9876543210 –Title Unlimited –Description 'Subscribers have completely unlimited access to the API. Administrator approval is required.' –LegalTerms 'Free for all' –ApprovalRequired $true –State Published</dev:code>
<dev:remarks>
<maml:para>Crete new product. Subscription and approval required. Notification period – 10 days. Subscription period – 1 year.</maml:para>
<maml:para>Crete new product. Subscription and approval required.</maml:para>
<maml:para />
<maml:para />
<maml:para>
Expand Down Expand Up @@ -11353,20 +11313,6 @@ New-AzureRmApiManagementOperation –Context $apimContext –ApiId $apiId –Ope
</maml:description>
<command:parameterValue required="true" variableLength="true">Nullable`1[Int32]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>SubscriptionPeriod</maml:name>
<maml:description>
<maml:para>The period user subscriptions stays active once approved. This parameter is optional. Default value is $null. The format is: {period}{value}. Examples: D2 (two days), M6 (six months), Y1(one year).</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>NotificationPeriod</maml:name>
<maml:description>
<maml:para>Specifies upcoming subscription expiration notification period. This parameter is optional. Default value is $null. The format is: {period}{value}. Examples: D2 (two days), M6 (six months), Y1(one year).</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>State</maml:name>
<maml:description>
Expand Down Expand Up @@ -11495,32 +11441,6 @@ New-AzureRmApiManagementOperation –Context $apimContext –ApiId $apiId –Ope
<dev:defaultValue>
</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>SubscriptionPeriod</maml:name>
<maml:description>
<maml:para>The period user subscriptions stays active once approved. This parameter is optional. Default value is $null. The format is: {period}{value}. Examples: D2 (two days), M6 (six months), Y1(one year).</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>
</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>NotificationPeriod</maml:name>
<maml:description>
<maml:para>Specifies upcoming subscription expiration notification period. This parameter is optional. Default value is $null. The format is: {period}{value}. Examples: D2 (two days), M6 (six months), Y1(one year).</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>
</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>State</maml:name>
<maml:description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
// limitations under the License.
namespace Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models
{
using System;

public class PsApiManagementProduct
{
public string ProductId { get; set; }
Expand All @@ -33,12 +31,6 @@ public class PsApiManagementProduct

public int? SubscriptionsLimit { get; set; }

// maps from period contract
public string SubscriptionPeriod { get; set; }

// maps from period contract
public string NotificationPeriod { get; set; }

public PsApiManagementProductState State { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<package id="Microsoft.Azure.Common.Authentication" version="1.3.5-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.ApiManagement" version="1.0.2-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.ApiManagement" version="2.0.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Resources" version="2.18.7-preview" targetFramework="net45" />
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" />
Expand Down
Loading