Skip to content

Commit

Permalink
Add support for policy at ManagementGroup level (#1754)
Browse files Browse the repository at this point in the history
* Add support for policy at ManagementGroup level

* Add "x-ms-parameter-location": "method" for ManagementGroupId parameter
  • Loading branch information
vivsriaus authored and sarangan12 committed Oct 2, 2017
1 parent 1a9d396 commit 3022628
Show file tree
Hide file tree
Showing 5 changed files with 566 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,116 @@
}
}
},
"/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policydefinitions/{policyDefinitionName}": {
"put": {
"tags": [
"PolicyDefinitions"
],
"operationId": "PolicyDefinitions_CreateOrUpdateAtManagementGroup",
"description": "Creates or updates a policy definition at management group level.",
"parameters": [
{
"name": "policyDefinitionName",
"in": "path",
"required": true,
"type": "string",
"description": "The name of the policy definition to create."
},
{
"name": "parameters",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/PolicyDefinition"
},
"description": "The policy definition properties."
},
{
"$ref": "#/parameters/ApiVersionParameter"
},
{
"$ref": "#/parameters/SubscriptionIdParameter"
},
{
"$ref": "#/parameters/ManagementGroupIdParameter"
}
],
"responses": {
"201": {
"description": "Created - Returns information about the policy definition.",
"schema": {
"$ref": "#/definitions/PolicyDefinition"
}
}
}
},
"delete": {
"tags": [
"PolicyDefinitions"
],
"operationId": "PolicyDefinitions_DeleteAtManagementGroup",
"description": "Deletes a policy definition at management group level.",
"parameters": [
{
"name": "policyDefinitionName",
"in": "path",
"required": true,
"type": "string",
"description": "The name of the policy definition to delete."
},
{
"$ref": "#/parameters/ApiVersionParameter"
},
{
"$ref": "#/parameters/SubscriptionIdParameter"
},
{
"$ref": "#/parameters/ManagementGroupIdParameter"
}
],
"responses": {
"204": {
"description": "No Content"
},
"200": {
"description": "OK"
}
}
},
"get": {
"tags": [
"PolicyDefinitions"
],
"operationId": "PolicyDefinitions_GetAtManagementGroup",
"description": "Gets the policy definition at management group level.",
"parameters": [
{
"name": "policyDefinitionName",
"in": "path",
"required": true,
"type": "string",
"description": "The name of the policy definition to get."
},
{
"$ref": "#/parameters/ApiVersionParameter"
},
{
"$ref": "#/parameters/SubscriptionIdParameter"
},
{
"$ref": "#/parameters/ManagementGroupIdParameter"
}
],
"responses": {
"200": {
"description": "OK - Returns information about the policy definition.",
"schema": {
"$ref": "#/definitions/PolicyDefinition"
}
}
}
}
},
"/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policydefinitions": {
"get": {
"tags": [
Expand Down Expand Up @@ -172,6 +282,45 @@
},
"x-ms-odata": "#/definitions/PolicyDefinition"
}
},
"/providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policydefinitions": {
"get": {
"tags": [
"PolicyDefinitions"
],
"operationId": "PolicyDefinitions_ListByManagementGroup",
"description": "Gets all the policy definitions for a subscription at management group level.",
"parameters": [
{
"name": "$filter",
"in": "query",
"required": false,
"type": "string",
"description": "The filter to apply on the operation."
},
{
"$ref": "#/parameters/ApiVersionParameter"
},
{
"$ref": "#/parameters/SubscriptionIdParameter"
},
{
"$ref": "#/parameters/ManagementGroupIdParameter"
}
],
"responses": {
"200": {
"description": "OK - Returns ana array of policy definitions.",
"schema": {
"$ref": "#/definitions/PolicyDefinitionListResult"
}
}
},
"x-ms-pageable": {
"nextLinkName": "nextLink"
},
"x-ms-odata": "#/definitions/PolicyDefinition"
}
}
},
"definitions": {
Expand Down Expand Up @@ -272,6 +421,14 @@
"type": "string",
"description": "The ID of the target subscription."
},
"ManagementGroupIdParameter": {
"name": "managementGroupId",
"in": "path",
"required": true,
"type": "string",
"description": "The ID of the management group.",
"x-ms-parameter-location": "method"
},
"ApiVersionParameter": {
"name": "api-version",
"in": "query",
Expand Down
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"
}
}
}
}
}
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"
}
}
}
}
}
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"
}
}
]
}
}
}
}
Loading

0 comments on commit 3022628

Please sign in to comment.