Skip to content

Commit 23ae023

Browse files
committed
New-AzManagedServicesDefinition changes
1 parent b8e4f23 commit 23ae023

File tree

3 files changed

+61
-33
lines changed

3 files changed

+61
-33
lines changed

src/ManagedServices/ManagedServices.Test/ScenarioTests/ManagedServicesTests.ps1

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ function New-AzManagedServicesDefinitionWithId
5353
{
5454
[CmdletBinding()]
5555
param(
56-
[string] [Parameter()] $Name,
56+
[string] [Parameter()] $DisplayName,
5757
[string] [Parameter()] $ManagedByTenantId,
5858
[string] [Parameter()] $PrincipalId,
5959
[string] [Parameter()] $RoleDefinitionId,
6060
[string] [Parameter()] $Description,
61-
[Guid] [Parameter()] $RegistrationDefinitionId
61+
[string] [Parameter()] $Name
6262
)
6363

6464
$profile = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile
@@ -71,9 +71,9 @@ function New-AzManagedServicesDefinitionWithId
7171
$cmdlet.Description = $Description
7272
}
7373

74-
if (-not ([string]::IsNullOrEmpty($Name)))
74+
if (-not ([string]::IsNullOrEmpty($DisplayName)))
7575
{
76-
$cmdlet.Name = $Name
76+
$cmdlet.DisplayName = $DisplayName
7777
}
7878

7979
if (-not ([string]::IsNullOrEmpty($ManagedByTenantId)))
@@ -91,9 +91,9 @@ function New-AzManagedServicesDefinitionWithId
9191
$cmdlet.RoleDefinitionId = $RoleDefinitionId
9292
}
9393

94-
if ($RegistrationDefinitionId -ne $null -and $RegistrationDefinitionId -ne [System.Guid]::Empty)
94+
if ($Name -ne $null -and $Name -ne [System.Guid]::Empty)
9595
{
96-
$cmdlet.RegistrationDefinitionId = $RegistrationDefinitionId
96+
$cmdlet.Name = $Name
9797
}
9898

9999
$cmdlet.ExecuteCmdlet()
@@ -110,7 +110,7 @@ function Test-ManagedServices_CRUD
110110
$definitionId = "1ccdb215-959a-48b9-bd7c-0584d461ea6c"
111111

112112
#put def
113-
$definition = New-AzManagedServicesDefinitionWithId -ManagedByTenantId $managedByTenantId -RoleDefinitionId $roleDefinitionId -PrincipalId $principalId -Name $name -RegistrationDefinitionId $definitionId
113+
$definition = New-AzManagedServicesDefinitionWithId -ManagedByTenantId $managedByTenantId -RoleDefinitionId $roleDefinitionId -PrincipalId $principalId -DisplayName $name -Name $definitionId
114114

115115
Assert-AreEqual $name $definition.Properties.Name
116116
Assert-AreEqual $managedByTenantId $definition.Properties.ManagedByTenantId

src/ManagedServices/ManagedServices/Commands/NewAzureRmManagedServicesDefinition.cs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,14 @@ public class NewAzureRmManagedServicesDefinition : ManagedServicesCmdletBase
3232
protected const string DefaultParameterSet = "Default";
3333
protected const string ByPlanParameterSet = "ByPlan";
3434

35-
[Parameter(ParameterSetName = DefaultParameterSet, Mandatory = true, HelpMessage = "The name of the Registration Definition.")]
36-
[Parameter(ParameterSetName = ByPlanParameterSet, Mandatory = true, HelpMessage = "The name of the Registration Definition.")]
35+
[Parameter(ParameterSetName = DefaultParameterSet, Mandatory = false, HelpMessage = "The unique name of the Registration Definition.")]
36+
[Parameter(ParameterSetName = ByPlanParameterSet, Mandatory = false, HelpMessage = "The unique name of the Registration Definition.")]
3737
public string Name { get; set; }
3838

39+
[Parameter(ParameterSetName = DefaultParameterSet, Mandatory = true, HelpMessage = "The display name of the Registration Definition.")]
40+
[Parameter(ParameterSetName = ByPlanParameterSet, Mandatory = true, HelpMessage = "The display name of the Registration Definition.")]
41+
public string DisplayName { get; set; }
42+
3943
[Parameter(ParameterSetName = DefaultParameterSet, Mandatory = true, HelpMessage = "The ManagedBy Tenant Identifier.")]
4044
[Parameter(ParameterSetName = ByPlanParameterSet, Mandatory = true, HelpMessage = "The ManagedBy Tenant Identifier.")]
4145
public string ManagedByTenantId { get; set; }
@@ -71,7 +75,7 @@ public class NewAzureRmManagedServicesDefinition : ManagedServicesCmdletBase
7175
[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")]
7276
public SwitchParameter AsJob { get; set; }
7377

74-
public Guid RegistrationDefinitionId { get; set; } = default(Guid);
78+
public Guid RegistrationDefinitionId { get; set; }
7579

7680
public override void ExecuteCmdlet()
7781
{
@@ -92,7 +96,16 @@ public override void ExecuteCmdlet()
9296
throw new ApplicationException("RoleDefinitionId must be a valid GUID.");
9397
}
9498

95-
if (this.RegistrationDefinitionId == default(Guid))
99+
if (this.Name != null)
100+
{
101+
if (!this.Name.IsGuid())
102+
{
103+
throw new ApplicationException("Name must be a valid GUID.");
104+
}
105+
106+
this.RegistrationDefinitionId = new Guid(this.Name);
107+
}
108+
else
96109
{
97110
this.RegistrationDefinitionId = Guid.NewGuid();
98111
}
@@ -122,7 +135,7 @@ public override void ExecuteCmdlet()
122135
Properties = new RegistrationDefinitionProperties
123136
{
124137
Description = this.Description,
125-
RegistrationDefinitionName = this.Name,
138+
RegistrationDefinitionName = this.DisplayName,
126139
ManagedByTenantId = this.ManagedByTenantId,
127140
Authorizations = new List<Authorization>
128141
{

src/ManagedServices/ManagedServices/help/New-AzManagedServicesDefinition.md

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ Creates or updates a registration definition.
1414

1515
### Default (Default)
1616
```
17-
New-AzManagedServicesDefinition -Name <String> -ManagedByTenantId <String>
18-
-PrincipalId <String> -RoleDefinitionId <String> [-Description <String>] [-AsJob]
17+
New-AzManagedServicesDefinition -DisplayName <String> -ManagedByTenantId <String>
18+
-PrincipalId <String> -RoleDefinitionId <String> [-Name <String>] [-Description <String>] [-AsJob]
1919
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
2020
```
2121

2222
### ByPlan
2323
```
24-
New-AzManagedServicesDefinition -Name <String> -ManagedByTenantId <String>
25-
-PrincipalId <String> -RoleDefinitionId <String> [-Description <String>] -PlanName <String>
24+
New-AzManagedServicesDefinition -DisplayName <String> -ManagedByTenantId <String>
25+
-PrincipalId <String> -RoleDefinitionId <String> [-Name <String>] [-Description <String>] -PlanName <String>
2626
-PlanPublisher <String> -PlanProduct <String> -PlanVersion <String> [-AsJob]
2727
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
2828
```
@@ -34,7 +34,7 @@ Creates or updates a registration definition.
3434

3535
### Example 1
3636
```powershell
37-
PS C:\> PS C:\> New-AzManagedServicesDefinition -Name name -ManagedByTenantId bab3375b-6197-4a15-a44b-16c41faa91d7 -PrincipalId d6f6c88a-5b7a-455e-ba40-ce146d4d3671 -RoleDefinitionId acdd72a7-3385-48ef-bd42-f606fba81ae7 -Description mydef
37+
PS C:\> PS C:\> New-AzManagedServicesDefinition -DisplayName MyRegistrationDefinition -ManagedByTenantId bab3375b-6197-4a15-a44b-16c41faa91d7 -PrincipalId d6f6c88a-5b7a-455e-ba40-ce146d4d3671 -RoleDefinitionId acdd72a7-3385-48ef-bd42-f606fba81ae7 -Description mydef
3838
3939
Name ManagedByTenantId PrincipalId RoleDefinitionId
4040
---- ----------------- ----------- ----------------
@@ -45,7 +45,7 @@ Creates or updates a registration definition given the required parameters.
4545

4646
### Example 2
4747
```powershell
48-
PS C> New-AzManagedServicesDefinition -Name asd -ManagedByTenantId "bab3375b-6197-4a15-a44b-16c41faa91d7" -PrincipalId "d6f6c88a-5b7a-455e-ba40-ce146d4d3671" -RoleDefinitionId "acdd72a7-3385-48ef-bd42-f606fba81ae7" -PlanName plan -PlanPublisher publisher -PlanProduct product -PlanVersion 0.1
48+
PS C> New-AzManagedServicesDefinition -DisplayName asd -ManagedByTenantId "bab3375b-6197-4a15-a44b-16c41faa91d7" -PrincipalId "d6f6c88a-5b7a-455e-ba40-ce146d4d3671" -RoleDefinitionId "acdd72a7-3385-48ef-bd42-f606fba81ae7" -PlanName plan -PlanPublisher publisher -PlanProduct product -PlanVersion 0.1
4949
5050
Name ManagedByTenantId PrincipalId RoleDefinitionId
5151
---- ----------------- ----------- ----------------
@@ -101,6 +101,21 @@ Accept pipeline input: False
101101
Accept wildcard characters: False
102102
```
103103
104+
### -DisplayName
105+
The display name of the Registration Definition.
106+
107+
```yaml
108+
Type: System.String
109+
Parameter Sets: (All)
110+
Aliases:
111+
112+
Required: True
113+
Position: Named
114+
Default value: None
115+
Accept pipeline input: False
116+
Accept wildcard characters: False
117+
```
118+
104119
### -ManagedByTenantId
105120
The ManagedBy Tenant Identifier.
106121
@@ -116,23 +131,23 @@ Accept pipeline input: False
116131
Accept wildcard characters: False
117132
```
118133
119-
### -PlanName
120-
The name of the plan.
134+
### -Name
135+
The unique name of the Registration Definition (for example b0c052e5-c437-4771-a476-8b1201158a57).
121136
122137
```yaml
123138
Type: System.String
124-
Parameter Sets: ByPlan
139+
Parameter Sets: (All)
125140
Aliases:
126141

127-
Required: True
142+
Required: False
128143
Position: Named
129144
Default value: None
130145
Accept pipeline input: False
131146
Accept wildcard characters: False
132147
```
133148
134-
### -PlanProduct
135-
The name of the Product.
149+
### -PlanName
150+
The name of the plan.
136151
137152
```yaml
138153
Type: System.String
@@ -146,8 +161,8 @@ Accept pipeline input: False
146161
Accept wildcard characters: False
147162
```
148163
149-
### -PlanPublisher
150-
The name of the Publisher.
164+
### -PlanProduct
165+
The name of the Product.
151166
152167
```yaml
153168
Type: System.String
@@ -161,8 +176,8 @@ Accept pipeline input: False
161176
Accept wildcard characters: False
162177
```
163178
164-
### -PlanVersion
165-
The version number of the plan.
179+
### -PlanPublisher
180+
The name of the Publisher.
166181
167182
```yaml
168183
Type: System.String
@@ -176,12 +191,12 @@ Accept pipeline input: False
176191
Accept wildcard characters: False
177192
```
178193
179-
### -PrincipalId
180-
The ManagedBy Principal Identifier.
194+
### -PlanVersion
195+
The version number of the plan.
181196
182197
```yaml
183198
Type: System.String
184-
Parameter Sets: (All)
199+
Parameter Sets: ByPlan
185200
Aliases:
186201

187202
Required: True
@@ -191,8 +206,8 @@ Accept pipeline input: False
191206
Accept wildcard characters: False
192207
```
193208
194-
### -RegistrationDefinitionName
195-
The name of the Registration Definition.
209+
### -PrincipalId
210+
The ManagedBy Principal Identifier.
196211
197212
```yaml
198213
Type: System.String

0 commit comments

Comments
 (0)