|
| 1 | +<!-- region Generated --> |
| 2 | +# Az.Policy |
| 3 | +This directory contains the PowerShell module for the Policy service. |
| 4 | + |
| 5 | +--- |
| 6 | +## Info |
| 7 | +- Modifiable: yes |
| 8 | +- Generated: all |
| 9 | +- Committed: yes |
| 10 | +- Packaged: yes |
| 11 | + |
| 12 | +--- |
| 13 | +## Detail |
| 14 | +This module was primarily generated via [AutoRest](https://github.com/Azure/autorest) using the [PowerShell](https://github.com/Azure/autorest.powershell) extension. |
| 15 | + |
| 16 | +## Module Requirements |
| 17 | +- [Az.Accounts module](https://www.powershellgallery.com/packages/Az.Accounts/), version 2.7.5 or greater |
| 18 | + |
| 19 | +## Authentication |
| 20 | +AutoRest does not generate authentication code for the module. Authentication is handled via Az.Accounts by altering the HTTP payload before it is sent. |
| 21 | + |
| 22 | +## Development |
| 23 | +For information on how to develop for `Az.Policy`, see [how-to.md](how-to.md). |
| 24 | +<!-- endregion --> |
| 25 | + |
| 26 | +### AutoRest Configuration |
| 27 | +> see https://aka.ms/autorest |
| 28 | +
|
| 29 | +``` yaml |
| 30 | +# Please specify the commit id that includes your features to make sure generated codes stable. |
| 31 | +commit: 33da947dfea91e16a4e62c663a13de4f0fa72251 |
| 32 | +require: |
| 33 | +# readme.azure.noprofile.md is the common configuration file |
| 34 | + - $(this-folder)/../../readme.azure.noprofile.md |
| 35 | +input-file: |
| 36 | +# You need to specify your swagger files here. |
| 37 | + - $(repo)/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/policyDefinitions.json |
| 38 | + - $(repo)/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/policySetDefinitions.json |
| 39 | + - $(repo)/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/policyDefinitionVersions.json |
| 40 | + - $(repo)/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/policySetDefinitionVersions.json |
| 41 | + - $(repo)/specification/resources/resource-manager/Microsoft.Authorization/stable/2023-04-01/policyAssignments.json |
| 42 | + - $(repo)/specification/resources/resource-manager/Microsoft.Authorization/preview/2022-07-01-preview/policyExemptions.json |
| 43 | +# If the swagger has not been put in the repo, you may uncomment the following line and refer to it locally |
| 44 | +# - ..\..\..\..\azure-rest-api-specs\specification\resources\resource-manager\Microsoft.Authorization\stable\2023-04-01\policyDefinitionVersions.json |
| 45 | +# - ..\..\..\..\azure-rest-api-specs\specification\resources\resource-manager\Microsoft.Authorization\stable\2023-04-01\policySetDefinitionVersions.json |
| 46 | + |
| 47 | +# For new RP, the version is 0.1.1 |
| 48 | +module-version: 0.1.1 |
| 49 | +# Normally, title is the service name |
| 50 | +root-module-name: $(prefix).Resources |
| 51 | +title: Policy |
| 52 | +subject-prefix: Policy |
| 53 | + |
| 54 | +# If there are post APIs for some kinds of actions in the RP, you may need to |
| 55 | +# uncomment following line to support viaIdentity for these post APIs |
| 56 | +# identity-correction-for-post: true |
| 57 | + |
| 58 | +# For new modules, please avoid setting 3.x using the use-extension method and instead, use 4.x as the default option |
| 59 | +#use-extension: |
| 60 | +# "@autorest/powershell": "3.x" |
| 61 | +azure: true |
| 62 | +resourcegroup-append: false |
| 63 | +identity-correction-for-post: false |
| 64 | +export-properties-for-dict: false |
| 65 | +nested-object-to-string: false |
| 66 | + |
| 67 | +directive: |
| 68 | + # Following is two common directive which are normally required in all the RPs |
| 69 | + # 1. Remove the unexpanded parameter set |
| 70 | + # 2. For New-* cmdlets, ViaIdentity is not required, so CreateViaIdentityExpanded is removed as well |
| 71 | + - where: |
| 72 | + variant: ^Create$|^CreateViaIdentity.*$|^CreateViaIdentityExpanded$|^Update$|^UpdateViaIdentity$ |
| 73 | + remove: true |
| 74 | + # Remove the set-* cmdlet |
| 75 | + - where: |
| 76 | + verb: Set |
| 77 | + remove: true |
| 78 | + - where: |
| 79 | + verb: New|Update |
| 80 | + variant: ^(Create|Update)(?!.*?Expanded) |
| 81 | + remove: true |
| 82 | + # Remove ManagementGroupInputObject parameter for all cmdlets, since it's not supported |
| 83 | + - where: |
| 84 | + variant: ^(Get|Delete|Update)ViaIdentityManagementGroup(Expanded)?$ |
| 85 | + remove: true |
| 86 | + |
| 87 | + # Hide separate cmdlets generated for tenant-level GETs. These are used by Get-AzPolicy* |
| 88 | + # customization to match behavior of current SDK cmdlets. |
| 89 | + - where: |
| 90 | + subject: .*Built |
| 91 | + hide: true |
| 92 | + |
| 93 | + # Create aliases of Set-*, since they are not supported/generated by autorest.powershell |
| 94 | + # They are provide in the new policy module for compatibility with current SDK module. |
| 95 | + # Since neither definitions nor set definitions generate Update-* cmdlets, both |
| 96 | + # Set-* and Update-* cmdlets are implemented by wrapping the generated New-* cmdlets. |
| 97 | + - where: |
| 98 | + verb: Update |
| 99 | + subject: PolicyAssignment |
| 100 | + set: |
| 101 | + alias: |
| 102 | + Set-AzPolicyAssignment |
| 103 | + - where: |
| 104 | + verb: Update |
| 105 | + subject: PolicyExemption |
| 106 | + set: |
| 107 | + alias: |
| 108 | + Set-AzPolicyExemption |
| 109 | + |
| 110 | + # Hide generated ManagementGroupId parameter for all cmdlets |
| 111 | + # since previous SDK cmdlets always used ManagementGroupName |
| 112 | + - where: |
| 113 | + parameter-name: ManagementGroupId |
| 114 | + set: |
| 115 | + default: |
| 116 | + name: DefaultManagementGroupId |
| 117 | + description: Need a placeholder to keep autorest happy |
| 118 | + script: '{ "" }' |
| 119 | + hide: true |
| 120 | + |
| 121 | + # Hide extra parameters likely to be confusing in new cmdlets |
| 122 | + - where: |
| 123 | + verb: New |
| 124 | + subject: PolicyExemption |
| 125 | + parameter-name: PolicyAssignmentId |
| 126 | + set: |
| 127 | + default: |
| 128 | + name: DefaultAssignmentId |
| 129 | + description: Need a placeholder to keep autorest happy |
| 130 | + script: '{ "" }' |
| 131 | + hide: true |
| 132 | + |
| 133 | + # Need to change ExpiresOn to a nullable DateTime (not supported by autorest) |
| 134 | + - where: |
| 135 | + verb: New |
| 136 | + subject: PolicyExemption |
| 137 | + parameter-name: ExpiresOn |
| 138 | + set: |
| 139 | + parameter-name: ExpiresOnInternal |
| 140 | + default: |
| 141 | + name: DefaultExpiresOn |
| 142 | + description: Need a placeholder to keep autorest happy |
| 143 | + script: '"PlaceholderExpiresOn"' |
| 144 | + hide: true |
| 145 | + clear-alias: true |
| 146 | + |
| 147 | + # Transform empty object definitions (e.g. policyRule, metadata) so they are generated as |
| 148 | + # hashtable, otherwise their values are discarded |
| 149 | + - from: swagger-document |
| 150 | + where: $.definitions.PolicyAssignmentProperties.properties.metadata |
| 151 | + transform: $['additionalProperties'] = true |
| 152 | + - from: swagger-document |
| 153 | + where: $.definitions.PolicyDefinitionProperties.properties.policyRule |
| 154 | + transform: $['additionalProperties'] = true |
| 155 | + - from: swagger-document |
| 156 | + where: $.definitions.PolicyDefinitionProperties.properties.metadata |
| 157 | + transform: $['additionalProperties'] = true |
| 158 | + - from: swagger-document |
| 159 | + where: $.definitions.PolicySetDefinitionProperties.properties.metadata |
| 160 | + transform: $['additionalProperties'] = true; |
| 161 | + - from: swagger-document |
| 162 | + where: $.definitions.PolicyExemptionProperties.properties.metadata |
| 163 | + transform: $['additionalProperties'] = true; |
| 164 | + - from: swagger-document |
| 165 | + where: $.definitions.PolicySetDefinitionProperties.properties.policyDefinition.policyDefinitionId |
| 166 | + transform: $['additionalProperties'] = true; |
| 167 | + - from: swagger-document |
| 168 | + where: $.definitions.PolicySetDefinitionProperties.properties.policyDefinition.parameters |
| 169 | + transform: $['additionalProperties'] = true; |
| 170 | + - from: swagger-document |
| 171 | + where: $.definitions.PolicySetDefinitionProperties.properties.policyDefinition.policyDefinitionReferenceId |
| 172 | + transform: $['additionalProperties'] = true; |
| 173 | + - from: swagger-document |
| 174 | + where: $.definitions.PolicySetDefinitionProperties.properties.policyDefinition.groupNames |
| 175 | + transform: $['additionalProperties'] = true; |
| 176 | + |
| 177 | + # previous approach that partially supported "any type" serialization |
| 178 | + - from: swagger-document |
| 179 | + where: $.definitions.ParameterDefinitionsValue.properties.allowedValues.items |
| 180 | + transform: $['additionalProperties'] = true; |
| 181 | + - from: swagger-document |
| 182 | + where: $.definitions.ParameterDefinitionsValue.properties.defaultValue |
| 183 | + transform: $['additionalProperties'] = true; |
| 184 | + - from: swagger-document |
| 185 | + where: $.definitions.ParameterValues |
| 186 | + transform: $['additionalProperties'] = true; |
| 187 | + - from: swagger-document |
| 188 | + where: $.definitions.ParameterDefinitions |
| 189 | + transform: $['additionalProperties'] = true; |
| 190 | + |
| 191 | + # Rename generated hashtable parameters to avoid type mismatch, since generated code |
| 192 | + # uses hashtable and previous SDK cmdlets use [JSON] string. Note, removing any |
| 193 | + # of these will cause builds to fail, since a parameter is not allowed to be |
| 194 | + # multiple types. |
| 195 | + - where: |
| 196 | + parameter-name: Metadata |
| 197 | + set: |
| 198 | + parameter-name: MetadataTable |
| 199 | + hide: true |
| 200 | + - where: |
| 201 | + parameter-name: Parameter |
| 202 | + set: |
| 203 | + parameter-name: ParameterTable |
| 204 | + hide: true |
| 205 | + - where: |
| 206 | + parameter-name: PolicyDefinition |
| 207 | + set: |
| 208 | + parameter-name: PolicyDefinitionTable |
| 209 | + hide: true |
| 210 | + - where: |
| 211 | + parameter-name: PolicySetDefinition |
| 212 | + set: |
| 213 | + parameter-name: PolicySetDefinitionTable |
| 214 | + hide: true |
| 215 | + - where: |
| 216 | + parameter-name: PolicyDefinitionGroup |
| 217 | + set: |
| 218 | + parameter-name: PolicyDefinitionGroupTable |
| 219 | + hide: true |
| 220 | + - where: |
| 221 | + parameter-name: NonComplianceMessage |
| 222 | + set: |
| 223 | + parameter-name: NonComplianceMessageTable |
| 224 | + hide: true |
| 225 | + |
| 226 | +# Hide parameters that aren't supported. |
| 227 | +# For some reason these can't be hidden by hiding them in |
| 228 | +# the custom folder so we have to do it here. |
| 229 | + - where: |
| 230 | + verb: New|Update |
| 231 | + subject: PolicyAssignment|PolicyExemption |
| 232 | + parameter-name: PolicyDefinitionId|ResourceSelector|Override |
| 233 | + hide: true |
| 234 | + - where: |
| 235 | + verb: New |
| 236 | + subject: PolicyDefinition |
| 237 | + parameter-name: PolicyRule |
| 238 | + hide: true |
| 239 | + - where: |
| 240 | + verb: New|Update |
| 241 | + subject: PolicyDefinition|PolicySetDefinition |
| 242 | + parameter-name: Version|PropertiesVersions |
| 243 | + hide: true |
| 244 | + - where: |
| 245 | + verb: Get |
| 246 | + parameter-name: Top |
| 247 | + hide: true |
| 248 | + |
| 249 | + # Remove or hide cmdlets that are customized or not supported at all |
| 250 | + - where: |
| 251 | + verb: New|Get|Remove|Update |
| 252 | + hide: true |
| 253 | + - where: |
| 254 | + verb: New|Remove|Update |
| 255 | + subject: PolicyDefinitionVersion|PolicySetDefinitionVersion |
| 256 | + remove: true |
| 257 | + |
| 258 | +metadata: |
| 259 | + scriptsToProcess: |
| 260 | + - ./custom/Helpers.ps1 |
| 261 | + |
| 262 | +``` |
0 commit comments