Skip to content

Commit 84cb1b1

Browse files
Merge pull request #1546 from robga/robga/policy
Onboarding auth RP for policy for autogeneration
2 parents 2637bf1 + 498b0f2 commit 84cb1b1

File tree

38 files changed

+17077
-5073
lines changed

38 files changed

+17077
-5073
lines changed

generator/autogenlist.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { postProcessor as resourcesPostProcessor } from './processors/Microsoft.
44
import { postProcessor as machineLearningPostProcessor } from './processors/Microsoft.MachineLearning';
55
import { postProcessor as machineLearningServicesPostProcessor } from './processors/Microsoft.MachineLearningServices';
66
import { postProcessor as storageProcessor } from './processors/Microsoft.Storage';
7+
import { postProcessor as policyProcessor } from './processors/Microsoft.Authorization';
78
import { lowerCaseEquals } from './utils';
89

910
// Run "npm run list-basepaths" to discover all the valid readme files to add to this list
@@ -466,6 +467,33 @@ const autoGenList: AutoGenConfig[] = [
466467
],
467468
postProcessor: resourcesPostProcessor,
468469
},
470+
{
471+
basePath: 'resources/resource-manager',
472+
namespace: 'Microsoft.Authorization',
473+
resourceConfig: [
474+
{
475+
type: 'policyDefinitions',
476+
scopes: ScopeType.Tenant | ScopeType.ManagementGroup | ScopeType.Subcription,
477+
},
478+
{
479+
type: 'policySetDefinitions',
480+
scopes: ScopeType.Tenant | ScopeType.ManagementGroup | ScopeType.Subcription,
481+
},
482+
{
483+
type: 'policyAssignments',
484+
scopes: ScopeType.ManagementGroup | ScopeType.Subcription | ScopeType.ResourceGroup | ScopeType.Extension,
485+
},
486+
{
487+
type: 'policyExemptions',
488+
scopes: ScopeType.ManagementGroup | ScopeType.Subcription | ScopeType.ResourceGroup | ScopeType.Extension,
489+
},
490+
{
491+
type: 'locks',
492+
scopes: ScopeType.Subcription | ScopeType.ResourceGroup | ScopeType.Extension,
493+
},
494+
],
495+
postProcessor: policyProcessor
496+
},
469497
{
470498
basePath: 'relay/resource-manager',
471499
namespace: 'Microsoft.Relay',
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { SchemaPostProcessor } from '../models';
2+
3+
export const postProcessor: SchemaPostProcessor = (_namespace: string, _apiVersion: string, schema: any) => {
4+
const allowedValues = schema.definitions?.ParameterDefinitionsValue?.properties?.allowedValues;
5+
if (allowedValues && allowedValues.oneOf) {
6+
const allowedValuesItems = allowedValues.oneOf[0]?.items
7+
removeObjectType(allowedValuesItems);
8+
}
9+
10+
const defaultValue = schema.definitions?.ParameterDefinitionsValue?.properties?.defaultValue;
11+
removeObjectType(defaultValue);
12+
13+
const assignmentParameter = schema.definitions?.PolicyAssignmentProperties?.properties?.parameters;
14+
removeObjectType(assignmentParameter);
15+
removeDataplaneParameterRestriction(assignmentParameter);
16+
17+
const definitionParameter = schema.definitions?.PolicyDefinitionProperties?.properties?.parameters;
18+
removeObjectType(definitionParameter);
19+
removeDataplaneParameterRestriction(definitionParameter);
20+
21+
const definitionReferenceParameter = schema.definitions?.PolicyDefinitionReference?.properties?.parameters;
22+
removeObjectType(definitionReferenceParameter);
23+
removeDataplaneParameterRestriction(definitionReferenceParameter);
24+
25+
const setDefinitionParameter = schema.definitions?.PolicySetDefinitionProperties?.properties?.parameters;
26+
removeObjectType(setDefinitionParameter);
27+
removeDataplaneParameterRestriction(setDefinitionParameter);
28+
}
29+
30+
function removeObjectType(property: any) {
31+
if (property && property['type'] && property['type'] === 'object') {
32+
delete property['type'];
33+
delete property['properties'];
34+
}
35+
}
36+
37+
function removeDataplaneParameterRestriction(property: any) {
38+
if (property?.oneOf && property.oneOf[0]?.additionalProperties && property.oneOf[0]['type'] === 'object') {
39+
delete property['oneOf'];
40+
}
41+
}

schemas/2014-04-01-preview/deploymentTemplate.json

Lines changed: 6311 additions & 2092 deletions
Large diffs are not rendered by default.
Lines changed: 125 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,157 @@
11
{
2-
"id": "https://schema.management.azure.com/schemas/2015-01-01/Microsoft.Authorization.json",
2+
"id": "https://schema.management.azure.com/schemas/2015-01-01/Microsoft.Authorization.json#",
33
"$schema": "http://json-schema.org/draft-04/schema#",
44
"title": "Microsoft.Authorization",
5-
"description": "Microsoft Microsoft.Authorization Resource Types",
5+
"description": "Microsoft Authorization Resource Types",
66
"resourceDefinitions": {
77
"locks": {
88
"type": "object",
99
"properties": {
10+
"apiVersion": {
11+
"type": "string",
12+
"enum": [
13+
"2015-01-01"
14+
]
15+
},
16+
"name": {
17+
"type": "string",
18+
"description": "The lock name."
19+
},
20+
"properties": {
21+
"oneOf": [
22+
{
23+
"$ref": "#/definitions/ManagementLockProperties"
24+
},
25+
{
26+
"$ref": "https://schema.management.azure.com/schemas/common/definitions.json#/definitions/expression"
27+
}
28+
],
29+
"description": "The management lock properties."
30+
},
1031
"type": {
32+
"type": "string",
1133
"enum": [
1234
"Microsoft.Authorization/locks"
1335
]
14-
},
36+
}
37+
},
38+
"required": [
39+
"apiVersion",
40+
"name",
41+
"properties",
42+
"type"
43+
],
44+
"description": "Microsoft.Authorization/locks"
45+
}
46+
},
47+
"subscription_resourceDefinitions": {
48+
"locks": {
49+
"type": "object",
50+
"properties": {
1551
"apiVersion": {
52+
"type": "string",
1653
"enum": [
1754
"2015-01-01"
1855
]
1956
},
2057
"name": {
2158
"type": "string",
22-
"minLength": 1,
23-
"maxLength": 64,
24-
"description": "Name of the lock"
25-
},
26-
"dependsOn": {
27-
"type": "array",
28-
"items": {
29-
"type": "string"
30-
},
31-
"description": "Collection of resources this resource depends on"
59+
"description": "The name of lock."
3260
},
3361
"properties": {
34-
"type": "object",
35-
"properties": {
36-
"level": {
37-
"oneOf": [
38-
{
39-
"enum": [
40-
"CannotDelete",
41-
"ReadOnly"
42-
]
43-
},
44-
{ "$ref": "https://schema.management.azure.com/schemas/common/definitions.json#/definitions/expression" }
45-
]
46-
,
47-
"description": "Microsoft.Authorization/locks: level - specifies the type of lock to apply to the scope. CanNotDelete allows modification but prevents deletion, ReadOnly prevents modification or deletion."
62+
"oneOf": [
63+
{
64+
"$ref": "#/definitions/ManagementLockProperties"
4865
},
49-
"notes": {
50-
"type": "string",
51-
"minLength": 1,
52-
"maxLength": 512,
53-
"description": "Microsoft.Authorization/locks: notes - user defined notes for the lock"
66+
{
67+
"$ref": "https://schema.management.azure.com/schemas/common/definitions.json#/definitions/expression"
5468
}
55-
},
56-
"required": [
57-
"level"
69+
],
70+
"description": "The management lock properties."
71+
},
72+
"type": {
73+
"type": "string",
74+
"enum": [
75+
"Microsoft.Authorization/locks"
5876
]
5977
}
6078
},
6179
"required": [
80+
"apiVersion",
6281
"name",
63-
"type",
82+
"properties",
83+
"type"
84+
],
85+
"description": "Microsoft.Authorization/locks"
86+
}
87+
},
88+
"extension_resourceDefinitions": {
89+
"locks": {
90+
"type": "object",
91+
"properties": {
92+
"apiVersion": {
93+
"type": "string",
94+
"enum": [
95+
"2015-01-01"
96+
]
97+
},
98+
"name": {
99+
"type": "string",
100+
"description": "The name of lock."
101+
},
102+
"properties": {
103+
"oneOf": [
104+
{
105+
"$ref": "#/definitions/ManagementLockProperties"
106+
},
107+
{
108+
"$ref": "https://schema.management.azure.com/schemas/common/definitions.json#/definitions/expression"
109+
}
110+
],
111+
"description": "The management lock properties."
112+
},
113+
"type": {
114+
"type": "string",
115+
"enum": [
116+
"Microsoft.Authorization/locks"
117+
]
118+
}
119+
},
120+
"required": [
64121
"apiVersion",
65-
"properties"
122+
"name",
123+
"properties",
124+
"type"
66125
],
67-
"description": "Microsoft.Authorization/locks resource"
126+
"description": "Microsoft.Authorization/locks"
127+
}
128+
},
129+
"definitions": {
130+
"ManagementLockProperties": {
131+
"type": "object",
132+
"properties": {
133+
"level": {
134+
"oneOf": [
135+
{
136+
"type": "string",
137+
"enum": [
138+
"NotSpecified",
139+
"CanNotDelete",
140+
"ReadOnly"
141+
]
142+
},
143+
{
144+
"$ref": "https://schema.management.azure.com/schemas/common/definitions.json#/definitions/expression"
145+
}
146+
],
147+
"description": "The lock level of the management lock."
148+
},
149+
"notes": {
150+
"type": "string",
151+
"description": "The notes of the management lock."
152+
}
153+
},
154+
"description": "The management lock properties."
68155
}
69156
}
70157
}

0 commit comments

Comments
 (0)