Skip to content

Commit 6e35348

Browse files
authored
Update resource properties with consistent client provided key as Graph metadata (#64)
1 parent 8abab51 commit 6e35348

13 files changed

Lines changed: 131 additions & 56 deletions

File tree

generated/microsoftgraph/microsoft.graph/beta/types.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

generated/microsoftgraph/microsoft.graph/beta/types.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
* **isFallbackPublicClient**: bool
2424
* **keyCredentials**: [MicrosoftGraphKeyCredential](#microsoftgraphkeycredential)[]
2525
* **logo**: string
26-
* **name**: string (Required, DeployTimeConstant): The resource name
2726
* **notes**: string
2827
* **optionalClaims**: [MicrosoftGraphOptionalClaims](#microsoftgraphoptionalclaims)
2928
* **parentalControlSettings**: [MicrosoftGraphParentalControlSettings](#microsoftgraphparentalcontrolsettings)
@@ -40,6 +39,7 @@
4039
* **tags**: string[]
4140
* **tokenEncryptionKeyId**: string {minLength: 36, maxLength: 36, pattern: "^[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$"}
4241
* **type**: 'Microsoft.Graph/applications' (ReadOnly, DeployTimeConstant): The resource type
42+
* **uniqueName**: string (Required, DeployTimeConstant)
4343
* **verifiedPublisher**: [MicrosoftGraphVerifiedPublisher](#microsoftgraphverifiedpublisher)
4444
* **web**: [MicrosoftGraphWebApplication](#microsoftgraphwebapplication)
4545
* **windows**: [MicrosoftGraphWindowsApplication](#microsoftgraphwindowsapplication)
@@ -51,7 +51,6 @@
5151
* **appRoleId**: string {minLength: 36, maxLength: 36, pattern: "^[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$"} (Required)
5252
* **creationTimestamp**: string (ReadOnly)
5353
* **id**: string (ReadOnly, DeployTimeConstant): The resource id
54-
* **name**: string: The resource name
5554
* **principalDisplayName**: string (ReadOnly)
5655
* **principalId**: string {minLength: 36, maxLength: 36, pattern: "^[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$"} (Required)
5756
* **principalType**: string (ReadOnly)
@@ -81,7 +80,6 @@
8180
* **members**: string[]
8281
* **membershipRule**: string
8382
* **membershipRuleProcessingState**: string
84-
* **name**: string (Required, DeployTimeConstant): The resource name
8583
* **onPremisesDomainName**: string (ReadOnly)
8684
* **onPremisesLastSyncDateTime**: string (ReadOnly)
8785
* **onPremisesNetBiosName**: string (ReadOnly)
@@ -102,6 +100,7 @@
102100
* **serviceProvisioningErrors**: [MicrosoftGraphServiceProvisioningError](#microsoftgraphserviceprovisioningerror)[]
103101
* **theme**: string
104102
* **type**: 'Microsoft.Graph/groups' (ReadOnly, DeployTimeConstant): The resource type
103+
* **uniqueName**: string (Required, DeployTimeConstant)
105104
* **visibility**: string
106105
* **writebackConfiguration**: [MicrosoftGraphGroupWritebackConfiguration](#microsoftgraphgroupwritebackconfiguration)
107106

@@ -112,7 +111,6 @@
112111
* **clientId**: string (Required)
113112
* **consentType**: string (Required)
114113
* **id**: string (ReadOnly, DeployTimeConstant): The resource id
115-
* **name**: string: The resource name
116114
* **principalId**: string
117115
* **resourceId**: string (Required)
118116
* **scope**: string
@@ -142,7 +140,6 @@
142140
* **keyCredentials**: [MicrosoftGraphKeyCredential](#microsoftgraphkeycredential)[]
143141
* **loginUrl**: string
144142
* **logoutUrl**: string
145-
* **name**: string: The resource name
146143
* **notes**: string
147144
* **notificationEmailAddresses**: string[]
148145
* **passwordCredentials**: [MicrosoftGraphPasswordCredential](#microsoftgraphpasswordcredential)[]
@@ -188,6 +185,7 @@
188185

189186
## MicrosoftGraphAuthenticationBehaviors
190187
### Properties
188+
* **blockAzureADGraphAccess**: bool
191189
* **removeUnverifiedEmailClaim**: bool
192190
* **requireClientServicePrincipal**: bool
193191

src/autorest.bicep/src/type-generator.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ import { failure, success } from "./utils";
1111
export function generateTypes(host: AutorestExtensionHost, definition: ProviderDefinition) {
1212
const factory = new TypeFactory();
1313
const namedDefinitions: Dictionary<TypeReference> = {};
14-
const typesWithoutRequiredName: Set<string> = new Set([
15-
'Microsoft.Graph/servicePrincipals',
16-
'Microsoft.Graph/oauth2PermissionGrants',
17-
'Microsoft.Graph/appRoleAssignedTo',
18-
]);
1914

2015
function logWarning(message: string) {
2116
host.message({ Channel: Channel.Warning, Text: message, });
@@ -241,13 +236,9 @@ export function generateTypes(host: AutorestExtensionHost, definition: ProviderD
241236
function getStandardizedResourceProperties(descriptor: ResourceDescriptor, resourceName: TypeReference): Dictionary<ObjectTypeProperty> {
242237
const fullyQualifiedType = getFullyQualifiedType(descriptor);
243238
const type = factory.addStringLiteralType(fullyQualifiedType);
244-
const nameFlag = typesWithoutRequiredName.has(fullyQualifiedType)
245-
? ObjectTypePropertyFlags.None
246-
: ObjectTypePropertyFlags.Required | ObjectTypePropertyFlags.DeployTimeConstant;
247239

248240
return {
249241
id: createObjectTypeProperty(factory.addStringType(), ObjectTypePropertyFlags.ReadOnly | ObjectTypePropertyFlags.DeployTimeConstant, 'The resource id'),
250-
name: createObjectTypeProperty(resourceName, nameFlag, 'The resource name'),
251242
type: createObjectTypeProperty(type, ObjectTypePropertyFlags.ReadOnly | ObjectTypePropertyFlags.DeployTimeConstant, 'The resource type'),
252243
apiVersion: createObjectTypeProperty(factory.addStringLiteralType(descriptor.apiVersion), ObjectTypePropertyFlags.ReadOnly | ObjectTypePropertyFlags.DeployTimeConstant, 'The resource api version'),
253244
};
@@ -440,6 +431,10 @@ export function generateTypes(host: AutorestExtensionHost, definition: ProviderD
440431
flags |= ObjectTypePropertyFlags.WriteOnly;
441432
}
442433

434+
if (putProperty && putProperty.extensions?.['x-constant-key']) {
435+
flags |= ObjectTypePropertyFlags.DeployTimeConstant;
436+
}
437+
443438
return flags;
444439
}
445440

src/autorest.bicep/test/integration/generated/basic/test.rp1/2021-10-31/types.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

src/autorest.bicep/test/integration/generated/basic/test.rp1/2021-10-31/types.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
* **bar**: string: The bar property
1010
* **foo**: string: The foo property
1111
* **id**: string (ReadOnly, DeployTimeConstant): The resource id
12-
* **name**: string (Required, DeployTimeConstant): The resource name
1312
* **type**: 'Test.Rp1/discriminatedUnionTestType' (ReadOnly, DeployTimeConstant): The resource type
1413

1514
### DiscriminatedUnionTestTypeBranchWithInheritedProps
@@ -37,7 +36,7 @@
3736
* **apiVersion**: '2021-10-31' (ReadOnly, DeployTimeConstant): The resource api version
3837
* **id**: string (ReadOnly, DeployTimeConstant): The resource id
3938
* **location**: string (Required): The geo-location where the resource lives
40-
* **name**: string (Required, DeployTimeConstant): The resource name
39+
* **name**: string (ReadOnly): The name of the resource
4140
* **properties**: [TestType1Properties](#testtype1properties)
4241
* **systemData**: [SystemData](#systemdata) (ReadOnly): Azure Resource Manager metadata containing createdBy and modifiedBy information.
4342
* **tags**: [TrackedResourceTags](#trackedresourcetags): Resource tags.
@@ -49,7 +48,7 @@
4948
* **apiVersion**: '2021-10-31' (ReadOnly, DeployTimeConstant): The resource api version
5049
* **id**: string (ReadOnly, DeployTimeConstant): The resource id
5150
* **location**: string (ReadOnly): The geo-location where the resource lives
52-
* **name**: string (Required, DeployTimeConstant): The resource name
51+
* **name**: string (ReadOnly): The name of the resource
5352
* **properties**: [ReadOnlyTestTypeProperties](#readonlytesttypeproperties) (ReadOnly)
5453
* **systemData**: [SystemData](#systemdata) (ReadOnly): Azure Resource Manager metadata containing createdBy and modifiedBy information.
5554
* **tags**: [TrackedResourceTags](#trackedresourcetags) (ReadOnly): Resource tags.
@@ -61,7 +60,7 @@
6160
* **apiVersion**: '2021-10-31' (ReadOnly, DeployTimeConstant): The resource api version
6261
* **id**: string (ReadOnly, DeployTimeConstant): The resource id
6362
* **location**: string (Required): The geo-location where the resource lives
64-
* **name**: 'constantName' | 'yetAnotherName' | string (Required, DeployTimeConstant): The resource name
63+
* **name**: string (ReadOnly): The name of the resource
6564
* **properties**: [TestType1CreateOrUpdatePropertiesOrTestType1Properties](#testtype1createorupdatepropertiesortesttype1properties): The resource properties.
6665
* **systemData**: [SystemData](#systemdata) (ReadOnly): Azure Resource Manager metadata containing createdBy and modifiedBy information.
6766
* **tags**: [TrackedResourceTags](#trackedresourcetags): Resource tags.
@@ -73,7 +72,7 @@
7372
* **apiVersion**: '2021-10-31' (ReadOnly, DeployTimeConstant): The resource api version
7473
* **id**: string (ReadOnly, DeployTimeConstant): The resource id
7574
* **location**: string (Required): The geo-location where the resource lives
76-
* **name**: string (Required, DeployTimeConstant): The resource name
75+
* **name**: string (ReadOnly): The name of the resource
7776
* **properties**: [TestType1CreateOrUpdatePropertiesOrTestType1Properties](#testtype1createorupdatepropertiesortesttype1properties): The resource properties.
7877
* **systemData**: [SystemData](#systemdata) (ReadOnly): Azure Resource Manager metadata containing createdBy and modifiedBy information.
7978
* **tags**: [TrackedResourceTags](#trackedresourcetags): Resource tags.
@@ -82,7 +81,7 @@
8281
## Function listArrayOfFoos (Test.Rp1/testType1@2021-10-31)
8382
* **Resource**: Test.Rp1/testType1
8483
* **ApiVersion**: 2021-10-31
85-
* **Output**: [FoosResponse](#foosresponse)[]
84+
* **Output**: [FoosResponse](#foosresponse)[] {minLength: 1, maxLength: 10}
8685

8786
## Function listFoos (Test.Rp1/testType1@2021-10-31)
8887
* **Resource**: Test.Rp1/testType1
@@ -118,11 +117,11 @@
118117
* **city**: string: The city or locality where the resource is located.
119118
* **countryOrRegion**: string: The country or region where the resource is located
120119
* **district**: string: The district, state, or province where the resource is located.
121-
* **name**: string (Required): A canonical name for the geographic or physical location.
120+
* **name**: string {maxLength: 256} (Required): A canonical name for the geographic or physical location.
122121

123122
## Plan
124123
### Properties
125-
* **name**: string (Required): A user defined name of the 3rd Party Artifact that is being procured.
124+
* **name**: string (Required, DeployTimeConstant): A user defined name of the 3rd Party Artifact that is being procured.
126125
* **product**: string (Required): The 3rd Party artifact that is being procured. E.g. NewRelic. Product maps to the OfferID specified for the artifact at the time of Data Market onboarding.
127126
* **promotionCode**: string: A publisher provided promotion code as provisioned in Data Market for the said product/artifact.
128127
* **publisher**: string (Required): The publisher of the 3rd Party Artifact that is being bought. E.g. NewRelic
@@ -148,9 +147,12 @@
148147
* **binaryBuffer**: any (ReadOnly)
149148
* **encryptionProperties**: [EncryptionProperties](#encryptionproperties): TestType1 encryption properties
150149
* **locationData**: [LocationData](#locationdata) (ReadOnly): Metadata pertaining to the geographic location of the resource.
150+
* **password**: string {sensitive, pattern: "^[a-zA-Z0-9\.]$"}
151+
* **percentageProperty**: int {minValue: 0, maxValue: 100} (ReadOnly)
151152
* **skuTier**: 'Basic' | 'Free' | 'Premium' | 'Standard': This field is required to be implemented by the Resource Provider if the service has more than one tier, but is not required on a PUT.
152153
* **stringEnum**: 'Bar' | 'Foo' | string: Description for a basic enum property.
153154
* **subnetId**: string (ReadOnly): A fully-qualified resource ID
155+
* **uuidProperty**: string {minLength: 36, maxLength: 36, pattern: "^[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$"}
154156

155157
## TestType1Properties
156158
### Properties
@@ -159,9 +161,12 @@
159161
* **binaryBuffer**: any
160162
* **encryptionProperties**: [EncryptionProperties](#encryptionproperties): TestType1 encryption properties
161163
* **locationData**: [LocationData](#locationdata): Metadata pertaining to the geographic location of the resource.
164+
* **password**: string {sensitive, pattern: "^[a-zA-Z0-9\.]$"}
165+
* **percentageProperty**: int {minValue: 0, maxValue: 100}
162166
* **skuTier**: 'Basic' | 'Free' | 'Premium' | 'Standard': This field is required to be implemented by the Resource Provider if the service has more than one tier, but is not required on a PUT.
163167
* **stringEnum**: 'Bar' | 'Foo' | string: Description for a basic enum property.
164168
* **subnetId**: string: A fully-qualified resource ID
169+
* **uuidProperty**: string {minLength: 36, maxLength: 36, pattern: "^[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$"}
165170

166171
## TrackedResourceTags
167172
### Properties

src/autorest.bicep/test/integration/specs/basic/resource-manager/Test.Rp1/stable/2021-10-31/spec.json

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,15 @@
9292
"encryptionProperties": {
9393
"$ref": "../../../../../common-types/resource-management/v3/types.json#/definitions/encryptionProperties",
9494
"description": "TestType1 encryption properties"
95+
},
96+
"password": {
97+
"type": "string",
98+
"x-ms-secret": true,
99+
"pattern": "^[a-zA-Z0-9\\.]$"
100+
},
101+
"uuidProperty": {
102+
"type": "string",
103+
"format": "uuid"
95104
}
96105
}
97106
},
@@ -124,6 +133,11 @@
124133
}
125134
]
126135
}
136+
},
137+
"percentageProperty": {
138+
"type": "integer",
139+
"minimum": 0,
140+
"maximum": 100
127141
}
128142
}
129143
},
@@ -170,7 +184,9 @@
170184
"type": "array",
171185
"items": {
172186
"$ref": "#/definitions/FoosResponse"
173-
}
187+
},
188+
"minItems": 1,
189+
"maxItems": 10
174190
},
175191
"DiscriminatedUnionTestType": {
176192
"allOf": [

src/autorest.bicep/test/integration/specs/common-types/resource-management/v3/types.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@
265265
"properties": {
266266
"name": {
267267
"type": "string",
268-
"description": "A user defined name of the 3rd Party Artifact that is being procured."
268+
"description": "A user defined name of the 3rd Party Artifact that is being procured.",
269+
"x-constant-key": true
269270
},
270271
"publisher": {
271272
"type": "string",
@@ -692,4 +693,4 @@
692693
"x-ms-parameter-location": "method"
693694
}
694695
}
695-
}
696+
}

src/swagger-generation/config.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ EntityTypes:
5353
- securityIdentifier
5454
- serviceProvisioningErrors
5555
- theme
56+
- uniqueName
5657
- visibility
5758
- writebackConfiguration
5859
NavigationProperty:
@@ -63,6 +64,7 @@ EntityTypes:
6364
- mailEnabled
6465
- mailNickname
6566
- securityEnabled
67+
- uniqueName
6668
ReadOnly:
6769
- createdByAppId
6870
- createdDateTime
@@ -113,11 +115,13 @@ EntityTypes:
113115
- spa
114116
- tags
115117
- tokenEncryptionKeyId
118+
- uniqueName
116119
- verifiedPublisher
117120
- web
118121
- windows
119122
RequiredOnWrite:
120123
- displayName
124+
- uniqueName
121125
ReadOnly:
122126
- appId
123127
- certification

src/swagger-generation/output/microsoftgraph-beta.json

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@
154154
"theme": {
155155
"type": "string"
156156
},
157+
"uniqueName": {
158+
"type": "string",
159+
"x-constant-key": true
160+
},
157161
"visibility": {
158162
"type": "string"
159163
},
@@ -182,7 +186,8 @@
182186
"displayName",
183187
"mailEnabled",
184188
"mailNickname",
185-
"securityEnabled"
189+
"securityEnabled",
190+
"uniqueName"
186191
]
187192
},
188193
"microsoft.graph.application": {
@@ -309,6 +314,10 @@
309314
"type": "string",
310315
"format": "uuid"
311316
},
317+
"uniqueName": {
318+
"type": "string",
319+
"x-constant-key": true
320+
},
312321
"verifiedPublisher": {
313322
"$ref": "#/definitions/microsoft.graph.verifiedPublisher"
314323
},
@@ -325,7 +334,8 @@
325334
}
326335
},
327336
"required": [
328-
"displayName"
337+
"displayName",
338+
"uniqueName"
329339
]
330340
},
331341
"microsoft.graph.servicePrincipal": {
@@ -717,6 +727,9 @@
717727
"microsoft.graph.authenticationBehaviors": {
718728
"type": "object",
719729
"properties": {
730+
"blockAzureADGraphAccess": {
731+
"type": "boolean"
732+
},
720733
"removeUnverifiedEmailClaim": {
721734
"type": "boolean"
722735
},

src/swagger-generation/src/definitions/EntityType.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ export class EntityType extends Object {
7272
if (property.ReadOnly)
7373
swaggerProperty.readOnly = property.ReadOnly
7474

75+
if (this.AlternateKey && this.Name.toLowerCase() !== "serviceprincipal" && property.Name === this.AlternateKey)
76+
swaggerProperty["x-constant-key"] = true
77+
7578
definition.properties[property.Name] = swaggerProperty
7679
});
7780

0 commit comments

Comments
 (0)