Skip to content
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

Hide generated parameter sets for New-* #24507

Merged
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
2 changes: 1 addition & 1 deletion src/Resources/Policy.Autorest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ directive:

# Remove or hide cmdlets that are customized or not supported at all
- where:
verb: Get|Remove|Update
verb: New|Get|Remove|Update
hide: true
- where:
verb: New|Remove|Update
Expand Down
31 changes: 10 additions & 21 deletions src/Resources/Policy.Autorest/custom/New-AzPolicyAssignment.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -69,37 +69,33 @@ param(
# This message will be part of response in case of policy violation.
${Description},

[Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName)]
[Parameter(ParameterSetName='Default', ValueFromPipelineByPropertyName)]
[Parameter(ParameterSetName='ParameterObject', Mandatory, ValueFromPipelineByPropertyName)]
[Parameter(ParameterSetName='ParameterString', Mandatory, ValueFromPipelineByPropertyName)]
[Parameter(ParameterSetName='ParameterObject', ValueFromPipeline)]
[Parameter(ParameterSetName='ParameterString', ValueFromPipeline)]
[Parameter(ParameterSetName='PolicyDefinition', Mandatory, ValueFromPipelineByPropertyName)]
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Category('Body')]
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.Info(PossibleTypes=([Microsoft.Azure.PowerShell.Cmdlets.Policy.Models.IPolicyDefinition]))]
[PSCustomObject]
# The ID of the policy definition or policy set definition being assigned.
# The ID of the policy definition being assigned.
${PolicyDefinition},

[Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName)]
[Parameter(ParameterSetName='Default', ValueFromPipelineByPropertyName)]
[Parameter(ParameterSetName='SetParameterObject', Mandatory, ValueFromPipelineByPropertyName)]
[Parameter(ParameterSetName='SetParameterString', Mandatory, ValueFromPipelineByPropertyName)]
[Parameter(ParameterSetName='ParameterObject', ValueFromPipeline)]
[Parameter(ParameterSetName='ParameterString', ValueFromPipeline)]
[Parameter(ParameterSetName='PolicySetDefinition', Mandatory, ValueFromPipeline)]
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Category('Body')]
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Runtime.Info(PossibleTypes=([Microsoft.Azure.PowerShell.Cmdlets.Policy.Models.IPolicySetDefinition]))]
[PSCustomObject]
# The ID of the policy definition or policy set definition being assigned.
# The ID of the policy set definition being assigned.
${PolicySetDefinition},

[Parameter(ParameterSetName='ParameterObject', Mandatory)]
[Parameter(ParameterSetName='SetParameterObject', Mandatory)]
[ValidateNotNullOrEmpty()]
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Category('Body')]
[hashtable]
# The parameter values for the assigned policy rule.
# The keys are the parameter names.
${PolicyParameterObject},

[Parameter(ParameterSetName='ParameterString', Mandatory, ValueFromPipelineByPropertyName)]
[Parameter(ParameterSetName='SetParameterString', Mandatory, ValueFromPipelineByPropertyName)]
[Parameter(ParameterSetName='ParameterString', Mandatory)]
[ValidateNotNullOrEmpty()]
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Category('Body')]
[System.String]
Expand Down Expand Up @@ -327,15 +323,8 @@ process {
$calledParameters.ScopeInternal = $Scope
$null = $calledParameters.Remove('Scope')

# client-side parameter validation
# route the input policy id to the correct place
if ($PolicyDefinition) {
if ($PolicySetDefinition) {
# Single piped input object gets bound to both parameters. This is only OK if they are the same resource
if ($PolicyDefinition.Id -ne $PolicySetDefinition.Id) {
throw 'Only one of -PolicyDefinition or -PolicySetDefinition can be specified, not both.'
}
}

$calledParameters.PolicyDefinitionId = $PolicyDefinition.Id
$null = $calledParameters.Remove('PolicyDefinition')
}
Expand Down
12 changes: 4 additions & 8 deletions src/Resources/Policy.Autorest/docs/Az.Policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,16 @@ Gets policy set definitions.


### [New-AzPolicyAssignment](New-AzPolicyAssignment.md)
This operation Create a policy assignment with the given scope and name.
Policy assignments apply to all resources contained within their scope.
For example, when you assign a policy at resource group scope, that policy applies to all resources in the group.
Creates or updates a policy assignment.

### [New-AzPolicyDefinition](New-AzPolicyDefinition.md)
This operation Create a policy definition in the given subscription with the given name.
Creates or updates a policy definition.

### [New-AzPolicyExemption](New-AzPolicyExemption.md)
This operation Create a policy exemption with the given scope and name.
Policy exemptions apply to all resources contained within their scope.
For example, when you create a policy exemption at resource group scope for a policy assignment at the same or above level, the exemption exempts to all applicable resources in the resource group.
Creates or updates a policy exemption.

### [New-AzPolicySetDefinition](New-AzPolicySetDefinition.md)
This operation Create a policy set definition in the given subscription with the given name.
Creates or updates a policy set definition.

### [Remove-AzPolicyAssignment](Remove-AzPolicyAssignment.md)
This operation deletes a policy assignment, given its name and the scope it was created in.
Expand Down
105 changes: 35 additions & 70 deletions src/Resources/Policy.Autorest/docs/New-AzPolicyAssignment.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ schema: 2.0.0
# New-AzPolicyAssignment

## SYNOPSIS
This operation Create a policy assignment with the given scope and name.
Policy assignments apply to all resources contained within their scope.
For example, when you assign a policy at resource group scope, that policy applies to all resources in the group.
Creates or updates a policy assignment.

## SYNTAX

Expand All @@ -19,62 +17,45 @@ For example, when you assign a policy at resource group scope, that policy appli
New-AzPolicyAssignment -Name <String> [-Scope <String>] [-BackwardCompatible] [-Description <String>]
[-DisplayName <String>] [-EnforcementMode <String>] [-IdentityId <String>] [-IdentityType <String>]
[-Location <String>] [-Metadata <String>] [-NonComplianceMessage <PSObject[]>] [-NotScope <String[]>]
[-PolicyDefinition <PSObject>] [-PolicySetDefinition <PSObject>] [-DefaultProfile <PSObject>] [-Confirm]
[-WhatIf] [<CommonParameters>]
```

### CreateExpanded
```
New-AzPolicyAssignment [-Description <String>] [-DisplayName <String>] [-EnforcementMode <String>]
[-IdentityType <String>] [-IdentityUserAssignedIdentity <Hashtable>] [-Location <String>]
[-NotScope <String[]>] [-DefaultProfile <PSObject>] [-Confirm] [-WhatIf] [<CommonParameters>]
```

### CreateExpanded1
```
New-AzPolicyAssignment [-Description <String>] [-DisplayName <String>] [-EnforcementMode <String>]
[-IdentityType <String>] [-IdentityUserAssignedIdentity <Hashtable>] [-Location <String>]
[-NotScope <String[]>] [-DefaultProfile <PSObject>] [-Confirm] [-WhatIf] [<CommonParameters>]
[-DefaultProfile <PSObject>] [-Confirm] [-WhatIf] [<CommonParameters>]
```

### ParameterObject
```
New-AzPolicyAssignment -Name <String> -PolicyDefinition <PSObject> -PolicyParameterObject <Hashtable>
[-Scope <String>] [-BackwardCompatible] [-Description <String>] [-DisplayName <String>]
[-EnforcementMode <String>] [-IdentityId <String>] [-IdentityType <String>] [-Location <String>]
[-Metadata <String>] [-NonComplianceMessage <PSObject[]>] [-NotScope <String[]>]
New-AzPolicyAssignment -Name <String> -PolicyParameterObject <Hashtable> [-Scope <String>]
[-BackwardCompatible] [-Description <String>] [-DisplayName <String>] [-EnforcementMode <String>]
[-IdentityId <String>] [-IdentityType <String>] [-Location <String>] [-Metadata <String>]
[-NonComplianceMessage <PSObject[]>] [-NotScope <String[]>] [-PolicyDefinition <PSObject>]
[-PolicySetDefinition <PSObject>] [-DefaultProfile <PSObject>] [-Confirm] [-WhatIf] [<CommonParameters>]
```

### ParameterString
```
New-AzPolicyAssignment -Name <String> -PolicyDefinition <PSObject> -PolicyParameter <String> [-Scope <String>]
[-BackwardCompatible] [-Description <String>] [-DisplayName <String>] [-EnforcementMode <String>]
[-IdentityId <String>] [-IdentityType <String>] [-Location <String>] [-Metadata <String>]
[-NonComplianceMessage <PSObject[]>] [-NotScope <String[]>] [-PolicySetDefinition <PSObject>]
New-AzPolicyAssignment -Name <String> -PolicyParameter <String> [-Scope <String>] [-BackwardCompatible]
[-Description <String>] [-DisplayName <String>] [-EnforcementMode <String>] [-IdentityId <String>]
[-IdentityType <String>] [-Location <String>] [-Metadata <String>] [-NonComplianceMessage <PSObject[]>]
[-NotScope <String[]>] [-PolicyDefinition <PSObject>] [-PolicySetDefinition <PSObject>]
[-DefaultProfile <PSObject>] [-Confirm] [-WhatIf] [<CommonParameters>]
```

### SetParameterObject
### PolicyDefinition
```
New-AzPolicyAssignment -Name <String> -PolicyParameterObject <Hashtable> -PolicySetDefinition <PSObject>
[-Scope <String>] [-BackwardCompatible] [-Description <String>] [-DisplayName <String>]
[-EnforcementMode <String>] [-IdentityId <String>] [-IdentityType <String>] [-Location <String>]
[-Metadata <String>] [-NonComplianceMessage <PSObject[]>] [-NotScope <String[]>]
[-PolicyDefinition <PSObject>] [-DefaultProfile <PSObject>] [-Confirm] [-WhatIf] [<CommonParameters>]
New-AzPolicyAssignment -Name <String> -PolicyDefinition <PSObject> [-Scope <String>] [-BackwardCompatible]
[-Description <String>] [-DisplayName <String>] [-EnforcementMode <String>] [-IdentityId <String>]
[-IdentityType <String>] [-Location <String>] [-Metadata <String>] [-NonComplianceMessage <PSObject[]>]
[-NotScope <String[]>] [-DefaultProfile <PSObject>] [-Confirm] [-WhatIf] [<CommonParameters>]
```

### SetParameterString
### PolicySetDefinition
```
New-AzPolicyAssignment -Name <String> -PolicyParameter <String> -PolicySetDefinition <PSObject>
[-Scope <String>] [-BackwardCompatible] [-Description <String>] [-DisplayName <String>]
[-EnforcementMode <String>] [-IdentityId <String>] [-IdentityType <String>] [-Location <String>]
[-Metadata <String>] [-NonComplianceMessage <PSObject[]>] [-NotScope <String[]>]
[-PolicyDefinition <PSObject>] [-DefaultProfile <PSObject>] [-Confirm] [-WhatIf] [<CommonParameters>]
New-AzPolicyAssignment -Name <String> -PolicySetDefinition <PSObject> [-Scope <String>] [-BackwardCompatible]
[-Description <String>] [-DisplayName <String>] [-EnforcementMode <String>] [-IdentityId <String>]
[-IdentityType <String>] [-Location <String>] [-Metadata <String>] [-NonComplianceMessage <PSObject[]>]
[-NotScope <String[]>] [-DefaultProfile <PSObject>] [-Confirm] [-WhatIf] [<CommonParameters>]
```

## DESCRIPTION
This operation Create a policy assignment with the given scope and name.
The **New-AzPolicyAssignment** cmdlet creates or updates a policy assignment with the given scope and name.
Policy assignments apply to all resources contained within their scope.
For example, when you assign a policy at resource group scope, that policy applies to all resources in the group.

Expand Down Expand Up @@ -239,7 +220,7 @@ Causes cmdlet to return artifacts using legacy format placing policy-specific pr

```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: Default, ParameterObject, ParameterString, SetParameterObject, SetParameterString
Parameter Sets: (All)
Aliases:

Required: False
Expand Down Expand Up @@ -317,7 +298,7 @@ The user identity dictionary key references will be ARM resource ids in the form

```yaml
Type: System.String
Parameter Sets: Default, ParameterObject, ParameterString, SetParameterObject, SetParameterString
Parameter Sets: (All)
Aliases:

Required: False
Expand All @@ -343,22 +324,6 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -IdentityUserAssignedIdentity
The user identity associated with the policy.
The user identity dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.

```yaml
Type: System.Collections.Hashtable
Parameter Sets: CreateExpanded, CreateExpanded1
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Location
The location of the policy assignment.
Only required when utilizing managed identity.
Expand All @@ -381,7 +346,7 @@ Metadata is an open ended object and is typically a collection of key value pair

```yaml
Type: System.String
Parameter Sets: Default, ParameterObject, ParameterString, SetParameterObject, SetParameterString
Parameter Sets: (All)
Aliases:

Required: False
Expand All @@ -396,7 +361,7 @@ The name of the policy assignment.

```yaml
Type: System.String
Parameter Sets: Default, ParameterObject, ParameterString, SetParameterObject, SetParameterString
Parameter Sets: (All)
Aliases: PolicyAssignmentName

Required: True
Expand All @@ -411,7 +376,7 @@ The messages that describe why a resource is non-compliant with the policy.

```yaml
Type: System.Management.Automation.PSObject[]
Parameter Sets: Default, ParameterObject, ParameterString, SetParameterObject, SetParameterString
Parameter Sets: (All)
Aliases:

Required: False
Expand All @@ -437,12 +402,12 @@ Accept wildcard characters: False
```

### -PolicyDefinition
The ID of the policy definition or policy set definition being assigned.
The ID of the policy definition being assigned.
To construct, see NOTES section for POLICYDEFINITION properties and create a hash table.

```yaml
Type: System.Management.Automation.PSObject
Parameter Sets: Default, ParameterObject, ParameterString, SetParameterObject, SetParameterString
Parameter Sets: ParameterObject, ParameterString, PolicyDefinition
Aliases:

Required: True
Expand All @@ -458,13 +423,13 @@ The keys are the parameter names.

```yaml
Type: System.String
Parameter Sets: ParameterString, SetParameterString
Parameter Sets: ParameterString
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept pipeline input: False
Accept wildcard characters: False
```

Expand All @@ -474,7 +439,7 @@ The keys are the parameter names.

```yaml
Type: System.Collections.Hashtable
Parameter Sets: ParameterObject, SetParameterObject
Parameter Sets: ParameterObject
Aliases:

Required: True
Expand All @@ -485,18 +450,18 @@ Accept wildcard characters: False
```

### -PolicySetDefinition
The ID of the policy definition or policy set definition being assigned.
The ID of the policy set definition being assigned.
To construct, see NOTES section for POLICYSETDEFINITION properties and create a hash table.

```yaml
Type: System.Management.Automation.PSObject
Parameter Sets: Default, ParameterObject, ParameterString, SetParameterObject, SetParameterString
Parameter Sets: ParameterObject, ParameterString, PolicySetDefinition
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue, ByPropertyName)
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```

Expand All @@ -506,7 +471,7 @@ Valid scopes are: management group (format: '/providers/Microsoft.Management/man

```yaml
Type: System.String
Parameter Sets: Default, ParameterObject, ParameterString, SetParameterObject, SetParameterString
Parameter Sets: (All)
Aliases:

Required: False
Expand Down
Loading
Loading