Skip to content

. #40

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

Merged
merged 13 commits into from
Jul 9, 2015
Merged

. #40

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
60 changes: 48 additions & 12 deletions setup/azurecmdfiles.wxi

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions src/AzurePowershell.sln
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.UsageAggregates",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.UsageAggregates.Test", "ResourceManager\Commerce\Commands.UsageAggregates.Test\Commands.UsageAggregates.Test.csproj", "{F220C306-29A3-4511-8518-A58A55C60D07}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.ApiManagement.ServiceManagement", "ResourceManager\ApiManagement\Commands.ApiManagement.ServiceManagement\Commands.ApiManagement.ServiceManagement.csproj", "{ED8BA708-AF42-4C08-9F4E-DAA1037797D5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.ApiManagement.ServiceManagement.Test", "ResourceManager\ApiManagement\Commands.SMAPI.Test\Commands.ApiManagement.ServiceManagement.Test.csproj", "{6448E795-3D02-4BDD-B0C7-AD0A2AFE3C8B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -548,6 +552,14 @@ Global
{F220C306-29A3-4511-8518-A58A55C60D07}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F220C306-29A3-4511-8518-A58A55C60D07}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F220C306-29A3-4511-8518-A58A55C60D07}.Release|Any CPU.Build.0 = Release|Any CPU
{ED8BA708-AF42-4C08-9F4E-DAA1037797D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ED8BA708-AF42-4C08-9F4E-DAA1037797D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ED8BA708-AF42-4C08-9F4E-DAA1037797D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ED8BA708-AF42-4C08-9F4E-DAA1037797D5}.Release|Any CPU.Build.0 = Release|Any CPU
{6448E795-3D02-4BDD-B0C7-AD0A2AFE3C8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6448E795-3D02-4BDD-B0C7-AD0A2AFE3C8B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6448E795-3D02-4BDD-B0C7-AD0A2AFE3C8B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6448E795-3D02-4BDD-B0C7-AD0A2AFE3C8B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -592,5 +604,6 @@ Global
{7D1D3B56-4EB4-4819-86FD-43330DED8EE7} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
{11387E0A-4DB6-49B8-BDBC-EE020D85D10F} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
{F220C306-29A3-4511-8518-A58A55C60D07} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
{6448E795-3D02-4BDD-B0C7-AD0A2AFE3C8B} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
EndGlobalSection
EndGlobal

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// // Copyright (c) Microsoft. All rights reserved.// // Licensed under the Apache License, Version 2.0 (the "License");// you may not use this file except in compliance with the License.// You may obtain a copy of the License at// http://www.apache.org/licenses/LICENSE-2.0// // Unless required by applicable law or agreed to in writing, software// distributed under the License is distributed on an "AS IS" BASIS,// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.// See the License for the specific language governing permissions and// limitations under the License.namespace Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands{ using System; using System.Management.Automation; using Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models; [Cmdlet(VerbsCommon.Add, "AzureApiManagementApiToProduct")] [OutputType(typeof(bool))] public class AddAzureApiManagementApiToProduct : AzureApiManagementCmdletBase { [Parameter( ValueFromPipelineByPropertyName = true, Mandatory = true, HelpMessage = "Instance of PsApiManagementContext. This parameter is required.")] [ValidateNotNullOrEmpty] public PsApiManagementContext Context { get; set; } [Parameter( ValueFromPipelineByPropertyName = true, Mandatory = true, HelpMessage = "Identifier of existing Product to add API to. This parameter is required.")] [ValidateNotNullOrEmpty] public String ProductId { get; set; } [Parameter( ValueFromPipelineByPropertyName = true, Mandatory = true, HelpMessage = "Identifier of existing APIs to be added to the product. This parameter is required.")] [ValidateNotNullOrEmpty] public String ApiId { get; set; } [Parameter( ValueFromPipelineByPropertyName = true, Mandatory = false, HelpMessage = "If specified will write true in case operation succeeds. This parameter is optional. Default value is false.")] public SwitchParameter PassThru { get; set; } public override void ExecuteApiManagementCmdlet() { Client.ApiAddToProduct(Context, ProductId, ApiId); if (PassThru) { WriteObject(true); } } }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//
// Copyright (c) Microsoft. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands
{
using System;
using System.Management.Automation;
using Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models;

[Cmdlet(VerbsCommon.Add, "AzureApiManagementProductToGroup")]
[OutputType(typeof(bool))]
public class AddAzureApiManagementProductToGroup : AzureApiManagementCmdletBase
{
[Parameter(
ValueFromPipelineByPropertyName = true,
Mandatory = true,
HelpMessage = "Instance of PsApiManagementContext. This parameter is required.")]
[ValidateNotNullOrEmpty]
public PsApiManagementContext Context { get; set; }

[Parameter(
ValueFromPipelineByPropertyName = true,
Mandatory = true,
HelpMessage = "Identifier of existing group. This parameter is required.")]
[ValidateNotNullOrEmpty]
public String GroupId { get; set; }

[Parameter(
ValueFromPipelineByPropertyName = true,
Mandatory = true,
HelpMessage = "Identifier of existing product. This parameter is required.")]
[ValidateNotNullOrEmpty]
public String ProductId { get; set; }

[Parameter(
ValueFromPipelineByPropertyName = true,
Mandatory = false,
HelpMessage = "If specified will write true in case operation succeeds. This parameter is optional. Default value is false.")]
public SwitchParameter PassThru { get; set; }

public override void ExecuteApiManagementCmdlet()
{
Client.ProductAddToGroup(Context, GroupId, ProductId);

if (PassThru)
{
WriteObject(true);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//
// Copyright (c) Microsoft. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands
{
using System;
using System.Management.Automation;
using Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models;

[Cmdlet(VerbsCommon.Add, "AzureApiManagementUserToGroup")]
[OutputType(typeof(bool))]
public class AddAzureApiManagementUserToGroup : AzureApiManagementCmdletBase
{
[Parameter(
ValueFromPipelineByPropertyName = true,
Mandatory = true,
HelpMessage = "Instance of PsApiManagementContext. This parameter is required.")]
[ValidateNotNullOrEmpty]
public PsApiManagementContext Context { get; set; }

[Parameter(
ValueFromPipelineByPropertyName = true,
Mandatory = true,
HelpMessage = "Identifier of existing group. This parameter is required.")]
[ValidateNotNullOrEmpty]
public String GroupId { get; set; }

[Parameter(
ValueFromPipelineByPropertyName = true,
Mandatory = true,
HelpMessage = "Identifier of existing user. This parameter is required.")]
[ValidateNotNullOrEmpty]
public String UserId { get; set; }

[Parameter(
ValueFromPipelineByPropertyName = true,
Mandatory = false,
HelpMessage = "If specified will write true in case operation succeeds. This parameter is optional. Default value is false.")]
public SwitchParameter PassThru { get; set; }

public override void ExecuteApiManagementCmdlet()
{
Client.UserAddToGroup(Context, GroupId, UserId);

if (PassThru)
{
WriteObject(true);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
//
// Copyright (c) Microsoft. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

namespace Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands
{
using System;
using System.Management.Automation;
using Microsoft.Azure.Commands.ApiManagement.ServiceManagement;
using Microsoft.WindowsAzure.Commands.Utilities.Common;

abstract public class AzureApiManagementCmdletBase : AzurePSCmdlet
{
protected static TimeSpan LongRunningOperationDefaultTimeout = TimeSpan.FromMinutes(1);

private ApiManagementClient _client;

public ApiManagementClient Client
{
get
{
if (_client == null)
{
_client = new ApiManagementClient(Profile);
}
return _client;
}
set
{
_client = value;
}
}

public abstract void ExecuteApiManagementCmdlet();

public override void ExecuteCmdlet()
{
try
{
ExecuteApiManagementCmdlet();
}
catch (ArgumentException ex)
{
WriteError(new ErrorRecord(ex, string.Empty, ErrorCategory.InvalidArgument, null));
}
catch (Exception ex)
{
HandleException(ex);
}
}

protected virtual void HandleException(Exception ex)
{
WriteExceptionError(ex);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//
// Copyright (c) Microsoft. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
namespace Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands
{
using System.Management.Automation;
using Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Properties;

abstract public class AzureApiManagementRemoveCmdletBase : AzureApiManagementCmdletBase
{
[Parameter(
ValueFromPipelineByPropertyName = true,
Mandatory = false,
HelpMessage = "If specified will write true in case operation succeeds. This parameter is optional. Default value is false.")]
public SwitchParameter PassThru { get; set; }

[Parameter(
ValueFromPipelineByPropertyName = true,
Mandatory = false,
HelpMessage = "Forces delete operation (prevents confirmation dialog). This parameter is optional. Default value is false.")]
public SwitchParameter Force { get; set; }

public abstract string ActionWarning { get; }

public abstract string ActionDescription { get; }

public override void ExecuteApiManagementCmdlet()
{
if (!Force.IsPresent &&
!ShouldProcess(
ActionDescription,
ActionWarning,
Resources.ShouldProcessCaption))
{
return;
}

ExecuteRemoveLogic();

if (PassThru.IsPresent)
{
WriteObject(true);
}
}

protected abstract void ExecuteRemoveLogic();
}
}
Loading