Skip to content

Commit b3a849d

Browse files
committed
Merge pull request #40 from Azure/dev
.
2 parents 197c382 + 86f45a5 commit b3a849d

File tree

119 files changed

+35597
-80
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+35597
-80
lines changed

setup/azurecmdfiles.wxi

Lines changed: 48 additions & 12 deletions
Large diffs are not rendered by default.

src/AzurePowershell.sln

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.UsageAggregates",
222222
EndProject
223223
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.UsageAggregates.Test", "ResourceManager\Commerce\Commands.UsageAggregates.Test\Commands.UsageAggregates.Test.csproj", "{F220C306-29A3-4511-8518-A58A55C60D07}"
224224
EndProject
225+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Commands.ApiManagement.ServiceManagement", "ResourceManager\ApiManagement\Commands.ApiManagement.ServiceManagement\Commands.ApiManagement.ServiceManagement.csproj", "{ED8BA708-AF42-4C08-9F4E-DAA1037797D5}"
226+
EndProject
227+
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}"
228+
EndProject
225229
Global
226230
GlobalSection(SolutionConfigurationPlatforms) = preSolution
227231
Debug|Any CPU = Debug|Any CPU
@@ -548,6 +552,14 @@ Global
548552
{F220C306-29A3-4511-8518-A58A55C60D07}.Debug|Any CPU.Build.0 = Debug|Any CPU
549553
{F220C306-29A3-4511-8518-A58A55C60D07}.Release|Any CPU.ActiveCfg = Release|Any CPU
550554
{F220C306-29A3-4511-8518-A58A55C60D07}.Release|Any CPU.Build.0 = Release|Any CPU
555+
{ED8BA708-AF42-4C08-9F4E-DAA1037797D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
556+
{ED8BA708-AF42-4C08-9F4E-DAA1037797D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
557+
{ED8BA708-AF42-4C08-9F4E-DAA1037797D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
558+
{ED8BA708-AF42-4C08-9F4E-DAA1037797D5}.Release|Any CPU.Build.0 = Release|Any CPU
559+
{6448E795-3D02-4BDD-B0C7-AD0A2AFE3C8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
560+
{6448E795-3D02-4BDD-B0C7-AD0A2AFE3C8B}.Debug|Any CPU.Build.0 = Debug|Any CPU
561+
{6448E795-3D02-4BDD-B0C7-AD0A2AFE3C8B}.Release|Any CPU.ActiveCfg = Release|Any CPU
562+
{6448E795-3D02-4BDD-B0C7-AD0A2AFE3C8B}.Release|Any CPU.Build.0 = Release|Any CPU
551563
EndGlobalSection
552564
GlobalSection(SolutionProperties) = preSolution
553565
HideSolutionNode = FALSE
@@ -592,5 +604,6 @@ Global
592604
{7D1D3B56-4EB4-4819-86FD-43330DED8EE7} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
593605
{11387E0A-4DB6-49B8-BDBC-EE020D85D10F} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
594606
{F220C306-29A3-4511-8518-A58A55C60D07} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
607+
{6448E795-3D02-4BDD-B0C7-AD0A2AFE3C8B} = {95C16AED-FD57-42A0-86C3-2CF4300A4817}
595608
EndGlobalSection
596609
EndGlobal

src/ResourceManager/ApiManagement/Commands.ApiManagement.ServiceManagement/ApiManagementClient.cs

Lines changed: 1354 additions & 0 deletions
Large diffs are not rendered by default.

src/ResourceManager/ApiManagement/Commands.ApiManagement.ServiceManagement/Commands.ApiManagement.ServiceManagement.csproj

Lines changed: 254 additions & 0 deletions
Large diffs are not rendered by default.

src/ResourceManager/ApiManagement/Commands.ApiManagement.ServiceManagement/Commands/AddAzureApiManagementApiToProduct.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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); } } }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
//
2+
// Copyright (c) Microsoft. All rights reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
namespace Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands
16+
{
17+
using System;
18+
using System.Management.Automation;
19+
using Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models;
20+
21+
[Cmdlet(VerbsCommon.Add, "AzureApiManagementProductToGroup")]
22+
[OutputType(typeof(bool))]
23+
public class AddAzureApiManagementProductToGroup : AzureApiManagementCmdletBase
24+
{
25+
[Parameter(
26+
ValueFromPipelineByPropertyName = true,
27+
Mandatory = true,
28+
HelpMessage = "Instance of PsApiManagementContext. This parameter is required.")]
29+
[ValidateNotNullOrEmpty]
30+
public PsApiManagementContext Context { get; set; }
31+
32+
[Parameter(
33+
ValueFromPipelineByPropertyName = true,
34+
Mandatory = true,
35+
HelpMessage = "Identifier of existing group. This parameter is required.")]
36+
[ValidateNotNullOrEmpty]
37+
public String GroupId { get; set; }
38+
39+
[Parameter(
40+
ValueFromPipelineByPropertyName = true,
41+
Mandatory = true,
42+
HelpMessage = "Identifier of existing product. This parameter is required.")]
43+
[ValidateNotNullOrEmpty]
44+
public String ProductId { get; set; }
45+
46+
[Parameter(
47+
ValueFromPipelineByPropertyName = true,
48+
Mandatory = false,
49+
HelpMessage = "If specified will write true in case operation succeeds. This parameter is optional. Default value is false.")]
50+
public SwitchParameter PassThru { get; set; }
51+
52+
public override void ExecuteApiManagementCmdlet()
53+
{
54+
Client.ProductAddToGroup(Context, GroupId, ProductId);
55+
56+
if (PassThru)
57+
{
58+
WriteObject(true);
59+
}
60+
}
61+
}
62+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
//
2+
// Copyright (c) Microsoft. All rights reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
namespace Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands
16+
{
17+
using System;
18+
using System.Management.Automation;
19+
using Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models;
20+
21+
[Cmdlet(VerbsCommon.Add, "AzureApiManagementUserToGroup")]
22+
[OutputType(typeof(bool))]
23+
public class AddAzureApiManagementUserToGroup : AzureApiManagementCmdletBase
24+
{
25+
[Parameter(
26+
ValueFromPipelineByPropertyName = true,
27+
Mandatory = true,
28+
HelpMessage = "Instance of PsApiManagementContext. This parameter is required.")]
29+
[ValidateNotNullOrEmpty]
30+
public PsApiManagementContext Context { get; set; }
31+
32+
[Parameter(
33+
ValueFromPipelineByPropertyName = true,
34+
Mandatory = true,
35+
HelpMessage = "Identifier of existing group. This parameter is required.")]
36+
[ValidateNotNullOrEmpty]
37+
public String GroupId { get; set; }
38+
39+
[Parameter(
40+
ValueFromPipelineByPropertyName = true,
41+
Mandatory = true,
42+
HelpMessage = "Identifier of existing user. This parameter is required.")]
43+
[ValidateNotNullOrEmpty]
44+
public String UserId { get; set; }
45+
46+
[Parameter(
47+
ValueFromPipelineByPropertyName = true,
48+
Mandatory = false,
49+
HelpMessage = "If specified will write true in case operation succeeds. This parameter is optional. Default value is false.")]
50+
public SwitchParameter PassThru { get; set; }
51+
52+
public override void ExecuteApiManagementCmdlet()
53+
{
54+
Client.UserAddToGroup(Context, GroupId, UserId);
55+
56+
if (PassThru)
57+
{
58+
WriteObject(true);
59+
}
60+
}
61+
}
62+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
//
2+
// Copyright (c) Microsoft. All rights reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
//
15+
16+
namespace Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands
17+
{
18+
using System;
19+
using System.Management.Automation;
20+
using Microsoft.Azure.Commands.ApiManagement.ServiceManagement;
21+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
22+
23+
abstract public class AzureApiManagementCmdletBase : AzurePSCmdlet
24+
{
25+
protected static TimeSpan LongRunningOperationDefaultTimeout = TimeSpan.FromMinutes(1);
26+
27+
private ApiManagementClient _client;
28+
29+
public ApiManagementClient Client
30+
{
31+
get
32+
{
33+
if (_client == null)
34+
{
35+
_client = new ApiManagementClient(Profile);
36+
}
37+
return _client;
38+
}
39+
set
40+
{
41+
_client = value;
42+
}
43+
}
44+
45+
public abstract void ExecuteApiManagementCmdlet();
46+
47+
public override void ExecuteCmdlet()
48+
{
49+
try
50+
{
51+
ExecuteApiManagementCmdlet();
52+
}
53+
catch (ArgumentException ex)
54+
{
55+
WriteError(new ErrorRecord(ex, string.Empty, ErrorCategory.InvalidArgument, null));
56+
}
57+
catch (Exception ex)
58+
{
59+
HandleException(ex);
60+
}
61+
}
62+
63+
protected virtual void HandleException(Exception ex)
64+
{
65+
WriteExceptionError(ex);
66+
}
67+
}
68+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
//
2+
// Copyright (c) Microsoft. All rights reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
namespace Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands
15+
{
16+
using System.Management.Automation;
17+
using Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Properties;
18+
19+
abstract public class AzureApiManagementRemoveCmdletBase : AzureApiManagementCmdletBase
20+
{
21+
[Parameter(
22+
ValueFromPipelineByPropertyName = true,
23+
Mandatory = false,
24+
HelpMessage = "If specified will write true in case operation succeeds. This parameter is optional. Default value is false.")]
25+
public SwitchParameter PassThru { get; set; }
26+
27+
[Parameter(
28+
ValueFromPipelineByPropertyName = true,
29+
Mandatory = false,
30+
HelpMessage = "Forces delete operation (prevents confirmation dialog). This parameter is optional. Default value is false.")]
31+
public SwitchParameter Force { get; set; }
32+
33+
public abstract string ActionWarning { get; }
34+
35+
public abstract string ActionDescription { get; }
36+
37+
public override void ExecuteApiManagementCmdlet()
38+
{
39+
if (!Force.IsPresent &&
40+
!ShouldProcess(
41+
ActionDescription,
42+
ActionWarning,
43+
Resources.ShouldProcessCaption))
44+
{
45+
return;
46+
}
47+
48+
ExecuteRemoveLogic();
49+
50+
if (PassThru.IsPresent)
51+
{
52+
WriteObject(true);
53+
}
54+
}
55+
56+
protected abstract void ExecuteRemoveLogic();
57+
}
58+
}

0 commit comments

Comments
 (0)