-
Notifications
You must be signed in to change notification settings - Fork 5.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add support for policy at ManagementGroup level #1754
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
...ation/2017-06-01-preview/examples/createOrUpdatePolicySetDefinitionAtManagementGroup.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
{ | ||
"parameters": { | ||
"subscriptionId": "subid", | ||
"managementGroupId": "mgid", | ||
"policySetDefinitionName": "costManagement", | ||
"api-version": "2017-06-01-preview", | ||
"parameters": { | ||
"properties": { | ||
"displayName": "VM and Storage Cost Management", | ||
"description": "Policies required to minimize the risk of accidental cost overruns", | ||
"metadata": { | ||
"category": "Cost Management" | ||
}, | ||
"policyDefinitions": [ | ||
{ | ||
"policyDefinitionId": "/subscriptions/subId/providers/Microsoft.Authorization/policyDefinitions/storageSkus", | ||
"parameters": { | ||
"listOfAllowedSKUs": { | ||
"value": [ | ||
"Standard_GRS", | ||
"Standard_LRS" | ||
] | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"responses": { | ||
"201": { | ||
"headers": {}, | ||
"body": { | ||
"id": "/providers/Microsoft.Management/managementgroups/mgid/providers/Microsoft.Authorization/policySetDefinitions/costManagement", | ||
"type": "Microsoft.Authorization/policySetDefinitions", | ||
"name": "costManagement", | ||
"properties": { | ||
"displayName": "VM and Storage Cost Management", | ||
"description": "Policies required to minimize the risk of accidental cost overruns", | ||
"metadata": { | ||
"category": "Cost Management" | ||
}, | ||
"policyDefinitions": [ | ||
{ | ||
"policyDefinitionId": "/subscriptions/subid/providers/Microsoft.Authorization/policyDefinitions/storageSkus", | ||
"parameters": { | ||
"listOfAllowedSKUs": { | ||
"value": [ | ||
"Standard_GRS", | ||
"Standard_LRS" | ||
] | ||
} | ||
} | ||
} | ||
], | ||
"policyType": "Custom" | ||
} | ||
} | ||
}, | ||
"200": { | ||
"headers": {}, | ||
"body": { | ||
"id": "/providers/Microsoft.Management/managementgroups/mgid/providers/Microsoft.Authorization/policySetDefinitions/costManagement", | ||
"type": "Microsoft.Authorization/policySetDefinitions", | ||
"name": "costManagement", | ||
"properties": { | ||
"displayName": "VM and Storage Cost Management", | ||
"description": "Policies required to minimize the risk of accidental cost overruns", | ||
"metadata": { | ||
"category": "Cost Management" | ||
}, | ||
"policyDefinitions": [ | ||
{ | ||
"policyDefinitionId": "/subscriptions/subid/providers/Microsoft.Authorization/policyDefinitions/storageSkus", | ||
"parameters": { | ||
"listOfAllowedSKUs": { | ||
"value": [ | ||
"Standard_GRS", | ||
"Standard_LRS" | ||
] | ||
} | ||
} | ||
} | ||
], | ||
"policyType": "Custom" | ||
} | ||
} | ||
} | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...ft.Authorization/2017-06-01-preview/examples/getPolicySetDefinitionAtManagementGroup.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
{ | ||
"parameters": { | ||
"subscriptionId": "subid", | ||
"managementGroupId": "mgid", | ||
"policySetDefinitionName": "costManagement", | ||
"api-version": "2017-06-01-preview" | ||
}, | ||
"responses": { | ||
"200": { | ||
"headers": {}, | ||
"body": { | ||
"id": "/providers/Microsoft.Management/managementgroups/mgid/providers/Microsoft.Authorization/policySetDefinitions/costManagement", | ||
"type": "Microsoft.Authorization/policySetDefinitions", | ||
"name": "costManagement", | ||
"properties": { | ||
"displayName": "VM and Storage Cost Management", | ||
"description": "Policies required to minimize the risk of accidental cost overruns", | ||
"metadata": { | ||
"category": "Cost Management" | ||
}, | ||
"parameters": { | ||
"allowedLocations": { | ||
"type": "array", | ||
"metadata": { | ||
"description": "Regions that resources can be deployed to", | ||
"displayName": "Valid Regions" | ||
} | ||
} | ||
}, | ||
"policyDefinitions": [ | ||
{ | ||
"policyDefinitionId": "/subscriptions/subid/providers/Microsoft.Authorization/policyDefinitions/storageSkus", | ||
"parameters": { | ||
"listOfAllowedSKUs": { | ||
"value": [ | ||
"Standard_GRS", | ||
"Standard_LRS" | ||
] | ||
} | ||
} | ||
}, | ||
{ | ||
"policyDefinitionId": "/subscriptions/subid/providers/Microsoft.Authorization/policyDefinitions/vmSkus" | ||
}, | ||
{ | ||
"policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/policyDefinitionId", | ||
"parameters": { | ||
"listOfAllowedLocations": { | ||
"value": "[parameters('allowedLocations')]" | ||
} | ||
} | ||
} | ||
], | ||
"policyType": "Custom" | ||
} | ||
} | ||
} | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
....Authorization/2017-06-01-preview/examples/listPolicySetDefinitionsByManagementGroup.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
{ | ||
"parameters": { | ||
"subscriptionId": "subid", | ||
"managementGroupId": "mgid", | ||
"api-version": "2017-06-01-preview" | ||
}, | ||
"responses": { | ||
"200": { | ||
"headers": {}, | ||
"body": { | ||
"value": [ | ||
{ | ||
"id": "/providers/Microsoft.Management/managementgroups/mgid/providers/Microsoft.Authorization/policySetDefinitions/costManagement", | ||
"type": "Microsoft.Authorization/policySetDefinitions", | ||
"name": "costManagement", | ||
"properties": { | ||
"displayName": "VM and Storage Cost Management", | ||
"description": "Policies required to minimize the risk of accidental cost overruns", | ||
"metadata": { | ||
"category": "Cost Management" | ||
}, | ||
"parameters": { | ||
"allowedLocations": { | ||
"type": "array", | ||
"metadata": { | ||
"description": "Regions that resources can be deployed to", | ||
"displayName": "Valid Regions" | ||
} | ||
} | ||
}, | ||
"policyDefinitions": [ | ||
{ | ||
"policyDefinitionId": "/subscriptions/subid/providers/Microsoft.Authorization/policyDefinitions/storageSkus", | ||
"parameters": { | ||
"locations": { | ||
"value": "[parameters('allowedLocations')]" | ||
} | ||
} | ||
} | ||
], | ||
"policyType": "Custom" | ||
} | ||
}, | ||
{ | ||
"id": "/providers/Microsoft.Management/managementgroups/mgid/providers/Microsoft.Authorization/policySetDefinitions/skuManagement", | ||
"type": "Microsoft.Authorization/policySetDefinitions", | ||
"name": "skuManagement", | ||
"properties": { | ||
"displayName": "VM Sku Management", | ||
"description": "Policies required to minimize the risk of accidental cost overruns", | ||
"metadata": { | ||
"category": "Sku Management" | ||
}, | ||
"policyDefinitions": [ | ||
{ | ||
"policyDefinitionId": "/subscriptions/subid/providers/Microsoft.Authorization/policyDefinitions/vmSkus" | ||
} | ||
], | ||
"policyType": "Custom" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: @sarangan12 is still the assigned reviewer. He will be finally reviewing the spec.
@vivsriaus - I noted an anomaly that I wanted to point out. Whenever you define a parameter in the global "prameters" section, Autorest treats it as a client property. This will end up as a required parameter in the constructor. I am sure this is not motive over here. It is ok to define parameters in the global parameters section so that you can reference it at multiple places in the swagger spec. However, if the parameter should not be a client property then please add the following extension:
"x-ms-parameter-location": "method"
.There is an issue filed in the linter repo for checking this Azure/azure-openapi-validator#84
Azure/azure-openapi-validator#84
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @amarzavery thanks for the comment. I'm not sure what a client property is. What do you mean when you say"required parameter in the constructor"? You mean of the policy client?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @vivsriaus - That is correct. The constructor of the policy client will have a required parameter named
managementGroupId
. An example TypeScript client:This would be the case in C# and other languages as well. I am sure this is not the desired behavior. If so then please add the extension
"x-ms-parameter-location": "method"
to the parameter in this and the other swagger spec below.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @amarzavery. Yes, we definitely don't want managementGroupId to be a required parameter in the constructor. I'll make the changes.