Skip to content

Commit b78eaea

Browse files
committed
Merge branch 'preview' of https://github.com/Azure/azure-powershell into automapper-fix
# Conflicts: # src/ResourceManager/ApiManagement/Commands.ApiManagement.ServiceManagement/ApiManagementClient.cs
2 parents 71f897f + 76989a3 commit b78eaea

File tree

270 files changed

+178692
-266516
lines changed

Some content is hidden

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

270 files changed

+178692
-266516
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,9 @@ The following guidelines must be followed in **EVERY** pull request that is open
148148

149149
The following guidelines must be followed in pull requests that add, edit, or remove a cmdlet.
150150

151-
- Cmdlet name uses an approved PowerShell verb - use enums for `VerbsCommon`, `VerbsCommunication`, `VerbLifecycle`, `VerbsOther` whenever possible
151+
- Cmdlet name uses an approved PowerShell verb - use enums for `VerbsCommon`, `VerbsCommunication`, `VerbsData`, `VerbsDiagnostic`, `VerbsLifecycle`, `VerbsOther`, and `VerbsSecurity` whenever possible
152+
- Note that you can see a list of all approved PowerShell verbs by running `Get-Verb` in PowerShell
153+
- When a verb you would like to use is not in the list of approved verbs, or to get ideas on how to use verbs, consult the [Approved Verbs for Windows PowerShell Commands](https://msdn.microsoft.com/en-us/library/ms714428\(v=vs.85\).aspx) documentation where you will find descriptions of approved verbs as well as related verbs in the comments so that you can find one appropriate for your command
152154
- Cmdlet noun name uses the AzureRm prefix for management cmdlets, and the Azure prefix for data plane cmdlets
153155
- Cmdlet specifies the `OutputType` attribute if any output is produced; if the cmdlet produces no output, it should implement a `PassThrough` parameter
154156
- If the cmdlet makes changes or has side effects, it should implement `ShouldProcess` and have `SupportsShouldProcess = true` specified in the cmdlet attribute. See a discussion about correct `ShouldProcess` implementation [here](https://gist.github.com/markcowl/338e16fe5c8bbf195aff9f8af0db585d#what-is-the-change).

documentation/Using-Azure-TestFramework.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
1. This starts VS Dev command prompt in PowerShell
1919
2. Import module that helps in performing basic repository tasks
2020
1. Import-Module Repo-Tasks.psd1
21-
2. Type Get-Commands -Module Repo-Tasks to see list of cmdlets
21+
2. Type Get-Command -Module Repo-Tasks to see list of cmdlets
2222
3. Get-Help <CommandName> to get help on individual commands.
2323

2424
## 2. Accquring TestFramework

src/ResourceManager/ApiManagement/ChangeLog.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@
1818
- Additional information about change #1
1919
-->
2020
## Current Release
21+
* Breaking Changes in Cmdlet to Manage Api Management Users
22+
- New-AzureRmApiManagementUser Parameter `Password` is changed from String to SecureString
23+
- Set-AzureRmApiManagementBackend Parameter `Password` is changed from String to SecureString
24+
25+
* Breaking Changes in Cmdlet to Create Backend Proxy Object
26+
- New-AzureRmApiManagementBackendProxy Parameter `Password` and `UserName` have been replaced with `ProxyCredentials` of type PSCredential
27+
28+
* Updated Cmdlet Get-AzureRmApiManagementUser to fix issue https://github.com/Azure/azure-powershell/issues/4510
29+
30+
* Updated Cmdlet New-AzureRmApiManagementApi to create Api with Empty Path https://github.com/Azure/azure-powershell/issues/4069
2131

2232
## Version 4.4.1
2333

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

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ namespace Microsoft.Azure.Commands.ApiManagement.ServiceManagement
3131
using System.Collections.Generic;
3232
using System.IO;
3333
using System.Linq;
34+
using System.Management.Automation;
3435
using System.Net;
3536
using System.Text;
3637
using System.Text.RegularExpressions;
@@ -202,8 +203,15 @@ private static void ConfigureMappings()
202203
cfg
203204
.CreateMap<BackendProxyContract, PsApiManagementBackendProxy>()
204205
.ForMember(dest => dest.Url, opt => opt.MapFrom(src => src.Url))
205-
.ForMember(dest => dest.Password, opt => opt.MapFrom(src => src.Password))
206-
.ForMember(dest => dest.UserName, opt => opt.MapFrom(src => src.Username));
206+
.ForMember(dest => dest.ProxyCredentials, opt => opt.MapFrom(src =>
207+
string.IsNullOrEmpty(src.Password) ? PSCredential.Empty :
208+
new PSCredential(src.Username, src.Password.ConvertToSecureString())));
209+
210+
cfg
211+
.CreateMap<PsApiManagementBackendProxy, BackendProxyContract>()
212+
.ForMember(dest => dest.Url, opt => opt.MapFrom(src => src.Url))
213+
.ForMember(dest => dest.Username, opt => opt.MapFrom(src => src.ProxyCredentials == PSCredential.Empty ? null : src.ProxyCredentials.UserName))
214+
.ForMember(dest => dest.Password, opt => opt.MapFrom(src => src.ProxyCredentials == PSCredential.Empty ? null : src.ProxyCredentials.Password.ConvertToString()));
207215

208216
cfg
209217
.CreateMap<BackendCredentialsContract, PsApiManagementBackendCredential>()
@@ -463,7 +471,7 @@ public void ApiImportFromFile(
463471
string apiId,
464472
PsApiManagementApiFormat specificationFormat,
465473
string specificationPath,
466-
string urlSuffix,
474+
string apiPath,
467475
string wsdlServiceName,
468476
string wsdlEndpointName,
469477
PsApiManagementApiType? apiType)
@@ -474,7 +482,7 @@ public void ApiImportFromFile(
474482

475483
using (var fileStream = File.OpenRead(specificationPath))
476484
{
477-
Client.Apis.Import(context.ResourceGroupName, context.ServiceName, apiId, contentType, fileStream, urlSuffix, wsdlServiceName, wsdlEndpointName, apiTypeValue);
485+
Client.Apis.Import(context.ResourceGroupName, context.ServiceName, apiId, contentType, fileStream, apiPath, wsdlServiceName, wsdlEndpointName, apiTypeValue);
478486
}
479487
}
480488

@@ -1058,7 +1066,7 @@ private static QueryParameters CreateQueryUserParameters(string firstName, strin
10581066
{
10591067
query.Filter += "&";
10601068
}
1061-
query.Filter = string.Format("lastName eq '{0}'", email);
1069+
query.Filter = string.Format("email eq '{0}'", email);
10621070
isFirstCondition = false;
10631071
}
10641072

@@ -2094,9 +2102,9 @@ public IList<PsApiManagementBackend> BackendsList(PsApiManagementContext context
20942102
return results;
20952103
}
20962104

2097-
public PsApiManagementBackend BackendById(PsApiManagementContext context, string loggerId)
2105+
public PsApiManagementBackend BackendById(PsApiManagementContext context, string backendId)
20982106
{
2099-
var response = Client.Backends.Get(context.ResourceGroupName, context.ServiceName, loggerId);
2107+
var response = Client.Backends.Get(context.ResourceGroupName, context.ServiceName, backendId);
21002108
var backend = Mapper.Map<PsApiManagementBackend>(response.Value);
21012109

21022110
return backend;
@@ -2187,7 +2195,7 @@ public void BackendSet(
21872195

21882196
if (proxy != null)
21892197
{
2190-
backendUpdateParams.Proxy = Mapper.Map<PsApiManagementBackendProxy, BackendProxyContract>(proxy);
2198+
backendUpdateParams.Proxy = Mapper.Map<BackendProxyContract>(proxy);
21912199
}
21922200

21932201
Client.Backends.Update(

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,10 @@ public override void ExecuteApiManagementCmdlet()
8989
var user = Client.UserById(Context, UserId);
9090
WriteObject(user);
9191
}
92-
else
92+
else
9393
{
94-
throw new InvalidOperationException(string.Format("Parameter set name '{0}' is not supported.", ParameterSetName));
94+
var user = Client.UsersList(Context, FirstName, LastName, Email, State, GroupId);
95+
WriteObject(user, true);
9596
}
9697
}
9798
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ public class NewAzureApiManagementApi : AzureApiManagementCmdletBase
6161
ValueFromPipelineByPropertyName = true,
6262
Mandatory = true,
6363
HelpMessage = "Web API Path. Last part of the API's public URL. This URL will be used by API consumers for sending requests to the web service." +
64-
" Must be 1 to 400 characters long. This parameter is required.")]
65-
[ValidateNotNullOrEmpty]
64+
" Must be 0 to 400 characters long. This parameter is required.")]
65+
[ValidateNotNull]
6666
public String Path { get; set; }
6767

6868
[Parameter(

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

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,27 +35,16 @@ public class NewAzureApiManagementBackendProxy : AzureApiManagementCmdletBase
3535
[Parameter(
3636
ValueFromPipelineByPropertyName = false,
3737
Mandatory = false,
38-
HelpMessage = "UserName used to connect to Backend Proxy. This parameter is optional.")]
39-
[Obsolete("New-AzureRmApiManagementBackendProxy: The parameter \"UserName\" is being removed in a future release in favor of a new PSCredential parameter (-Credential).")]
40-
public string UserName { get; set; }
41-
42-
[Parameter(
43-
ValueFromPipelineByPropertyName = false,
44-
Mandatory = false,
45-
HelpMessage = "Password used to connect to Backend Proxy. This parameter is optional.")]
46-
[Obsolete("New-AzureRmApiManagementBackendProxy: The parameter \"Password\" is being removed in a future release in favor of a new PSCredential parameter (-Credential).")]
47-
public string Password { get; set; }
38+
HelpMessage = "Credentials used to connect to Backend Proxy. This parameter is optional.")]
39+
public PSCredential ProxyCredential { get; set; }
4840

4941
public override void ExecuteApiManagementCmdlet()
5042
{
5143
WriteObject(
5244
new PsApiManagementBackendProxy
5345
{
5446
Url = Url,
55-
#pragma warning disable 0618
56-
UserName = UserName,
57-
Password = Password
58-
#pragma warning restore 0618
47+
ProxyCredentials = ProxyCredential != null ? ProxyCredential : PSCredential.Empty
5948
});
6049
}
6150
}

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ namespace Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands
1717
using Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models;
1818
using System;
1919
using System.Management.Automation;
20+
using System.Security;
21+
using WindowsAzure.Commands.Common;
2022

2123
[Cmdlet(VerbsCommon.New, Constants.ApiManagementUser)]
2224
[OutputType(typeof(PsApiManagementUser))]
@@ -61,8 +63,7 @@ public class NewAzureApiManagementUser : AzureApiManagementCmdletBase
6163
Mandatory = true,
6264
HelpMessage = "User password. This parameter is required.")]
6365
[ValidateNotNullOrEmpty]
64-
[Obsolete("New-AzureRmApiManagementUser: The parameter \"Password\" is being changed from a string to a SecureString in an upcoming breaking change release.")]
65-
public String Password { get; set; }
66+
public SecureString Password { get; set; }
6667

6768
[Parameter(
6869
ValueFromPipelineByPropertyName = true,
@@ -79,10 +80,8 @@ public class NewAzureApiManagementUser : AzureApiManagementCmdletBase
7980
public override void ExecuteApiManagementCmdlet()
8081
{
8182
string userId = UserId ?? Guid.NewGuid().ToString("N");
82-
83-
#pragma warning disable 0618
84-
var user = Client.UserCreate(Context, userId, FirstName, LastName, Password, Email, State, Note);
85-
#pragma warning restore 0618
83+
84+
var user = Client.UserCreate(Context, userId, FirstName, LastName, Password.ConvertToString(), Email, State, Note);
8685

8786
WriteObject(user);
8887
}

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ namespace Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands
1717
using Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models;
1818
using System;
1919
using System.Management.Automation;
20+
using System.Security;
21+
using WindowsAzure.Commands.Common;
2022

2123
[Cmdlet(VerbsCommon.Set, Constants.ApiManagementUser)]
2224
[OutputType(typeof(PsApiManagementUser))]
@@ -58,8 +60,7 @@ public class SetAzureApiManagementUser : AzureApiManagementCmdletBase
5860
ValueFromPipelineByPropertyName = true,
5961
Mandatory = false,
6062
HelpMessage = "User password. This parameter is optional.")]
61-
[Obsolete("Set-AzureRmApiManagementUser: The parameter \"Password\" is being changed from a string to a SecureString in an upcoming breaking change release.")]
62-
public String Password { get; set; }
63+
public SecureString Password { get; set; }
6364

6465
[Parameter(
6566
ValueFromPipelineByPropertyName = true,
@@ -83,9 +84,7 @@ public class SetAzureApiManagementUser : AzureApiManagementCmdletBase
8384

8485
public override void ExecuteApiManagementCmdlet()
8586
{
86-
#pragma warning disable 0618
87-
Client.UserSet(Context, UserId, FirstName, LastName, Password, Email, State, Note);
88-
#pragma warning restore 0618
87+
Client.UserSet(Context, UserId, FirstName, LastName, Password != null ? Password.ConvertToString() : null, Email, State, Note);
8988

9089
if (PassThru)
9190
{

src/ResourceManager/ApiManagement/Commands.ApiManagement.ServiceManagement/Models/PsApiManagementBackendProxy.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414

1515
namespace Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models
1616
{
17+
using System.Management.Automation;
18+
1719
public class PsApiManagementBackendProxy
1820
{
1921
public string Url { get; set; }
2022

21-
public string UserName { get; set; }
22-
23-
public string Password { get; set; }
23+
public PSCredential ProxyCredentials { get; set; }
2424
}
2525
}

src/ResourceManager/ApiManagement/Commands.ApiManagement/help/Add-AzureRmApiManagementApiToProduct.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Adds an API to a product.
1414

1515
```
1616
Add-AzureRmApiManagementApiToProduct -Context <PsApiManagementContext> -ProductId <String> -ApiId <String>
17-
[-PassThru] [<CommonParameters>]
17+
[-PassThru] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
1818
```
1919

2020
## DESCRIPTION
@@ -24,6 +24,7 @@ The **Add-AzureRmApiManagementApiToProduct** cmdlet adds an Azure API Management
2424

2525
### Example 1: Add an API to a product
2626
```
27+
PS C:\>$ApiMgmtContext = New-AzureRmApiManagementContext -ResourceGroupName "Api-Default-WestUS" -ServiceName "contoso"
2728
PS C:\>Add-AzureRmApiManagementApiToProduct -Context $ApiMgmtContext -ProductId "0123456789" -ApiId "0001"
2829
```
2930

@@ -61,6 +62,21 @@ Accept pipeline input: True (ByPropertyName)
6162
Accept wildcard characters: False
6263
```
6364
65+
### -DefaultProfile
66+
The credentials, account, tenant, and subscription used for communication with azure.
67+
68+
```yaml
69+
Type: IAzureContextContainer
70+
Parameter Sets: (All)
71+
Aliases: AzureRmContext, AzureCredential
72+
73+
Required: False
74+
Position: Named
75+
Default value: None
76+
Accept pipeline input: False
77+
Accept wildcard characters: False
78+
```
79+
6480
### -PassThru
6581
passthru
6682

src/ResourceManager/ApiManagement/Commands.ApiManagement/help/Add-AzureRmApiManagementProductToGroup.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Adds a product to a group.
1414

1515
```
1616
Add-AzureRmApiManagementProductToGroup -Context <PsApiManagementContext> -GroupId <String> -ProductId <String>
17-
[-PassThru] [<CommonParameters>]
17+
[-PassThru] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
1818
```
1919

2020
## DESCRIPTION
@@ -25,6 +25,7 @@ In other words, this cmdlet assigns a group to a product.
2525

2626
### Example 1: Add a product to a group
2727
```
28+
PS C:\>$apimContext = New-AzureRmApiManagementContext -ResourceGroupName "Api-Default-WestUS" -ServiceName "contoso"
2829
PS C:\>Add-AzureRmApiManagementProductToGroup -Context $apimContext -GroupId "0001" -ProductId "0123456789"
2930
```
3031

@@ -48,6 +49,21 @@ Accept pipeline input: True (ByPropertyName)
4849
Accept wildcard characters: False
4950
```
5051
52+
### -DefaultProfile
53+
The credentials, account, tenant, and subscription used for communication with azure.
54+
55+
```yaml
56+
Type: IAzureContextContainer
57+
Parameter Sets: (All)
58+
Aliases: AzureRmContext, AzureCredential
59+
60+
Required: False
61+
Position: Named
62+
Default value: None
63+
Accept pipeline input: False
64+
Accept wildcard characters: False
65+
```
66+
5167
### -GroupId
5268
Specifies the group ID.
5369
This parameter is required.

src/ResourceManager/ApiManagement/Commands.ApiManagement/help/Add-AzureRmApiManagementRegion.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ Adds new deployment regions to a PsApiManagement instance.
1414

1515
```
1616
Add-AzureRmApiManagementRegion -ApiManagement <PsApiManagement> -Location <String> [-Sku <PsApiManagementSku>]
17-
[-Capacity <Int32>] [-VirtualNetwork <PsApiManagementVirtualNetwork>] [<CommonParameters>]
17+
[-Capacity <Int32>] [-VirtualNetwork <PsApiManagementVirtualNetwork>]
18+
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
1819
```
1920

2021
## DESCRIPTION
@@ -70,26 +71,26 @@ Accept pipeline input: False
7071
Accept wildcard characters: False
7172
```
7273
73-
### -Location
74-
Specifies the location of the new deployment region.
74+
### -DefaultProfile
75+
The credentials, account, tenant, and subscription used for communication with azure.
76+
77+
```yaml
78+
Type: IAzureContextContainer
79+
Parameter Sets: (All)
80+
Aliases: AzureRmContext, AzureCredential
7581

76-
Valid values are:
82+
Required: False
83+
Position: Named
84+
Default value: None
85+
Accept pipeline input: False
86+
Accept wildcard characters: False
87+
```
7788
78-
- North Central US
79-
- South Central US
80-
- Central US
81-
- West Europe
82-
- North Europe
83-
- West US
84-
- East US
85-
- East US 2
86-
- Japan East
87-
- Japan West
88-
- Brazil South
89-
- Southeast Asia
90-
- East Asia
91-
- Australia East
92-
- Australia Southeast
89+
### -Location
90+
Specifies the location of the new deployment region amongst the supported region for Api Management service.
91+
92+
To obtain valid locations, use the cmdlet
93+
Get-AzureRmResourceProvider -ProviderNamespace "Microsoft.ApiManagement" | where {$_.ResourceTypes[0].ResourceTypeName -eq "service"} | Select-Object Locations
9394
9495
```yaml
9596
Type: String
@@ -145,7 +146,6 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
145146
## INPUTS
146147
147148
### PsApiManagement
148-
149149
Parameter 'ApiManagement' accepts value of type 'PsApiManagement' from the pipeline
150150
151151
## OUTPUTS

0 commit comments

Comments
 (0)