@azure-tools/typespec-azure-resource-manager 0.71.0-dev.8 → 0.71.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/dist/generated-defs/Azure.ResourceManager.BaseTypes.d.ts +1 -1
- package/dist/src/base-types.d.ts +1 -1
- package/dist/src/base-types.d.ts.map +1 -1
- package/dist/src/common-types.d.ts +4 -4
- package/dist/src/common-types.d.ts.map +1 -1
- package/dist/src/commontypes.private.decorators.d.ts +2 -2
- package/dist/src/commontypes.private.decorators.d.ts.map +1 -1
- package/dist/src/linter.d.ts.map +1 -1
- package/dist/src/linter.js +6 -2
- package/dist/src/linter.js.map +1 -1
- package/dist/src/namespace.d.ts +2 -2
- package/dist/src/namespace.d.ts.map +1 -1
- package/dist/src/operations.d.ts +4 -4
- package/dist/src/operations.d.ts.map +1 -1
- package/dist/src/operations.js.map +1 -1
- package/dist/src/private.decorators.d.ts +2 -2
- package/dist/src/private.decorators.d.ts.map +1 -1
- package/dist/src/private.decorators.js +17 -6
- package/dist/src/private.decorators.js.map +1 -1
- package/dist/src/resource.d.ts +4 -4
- package/dist/src/resource.d.ts.map +1 -1
- package/dist/src/rules/arm-agent-base-type-child-resources.js.map +1 -1
- package/dist/src/rules/arm-agent-base-type-lifecycle-operations.js.map +1 -1
- package/dist/src/rules/arm-common-types-version.js.map +1 -1
- package/dist/src/rules/arm-custom-resource-no-key.js.map +1 -1
- package/dist/src/rules/arm-custom-resource-usage-discourage.d.ts.map +1 -1
- package/dist/src/rules/arm-custom-resource-usage-discourage.js +1 -1
- package/dist/src/rules/arm-custom-resource-usage-discourage.js.map +1 -1
- package/dist/src/rules/arm-delete-response-codes.js.map +1 -1
- package/dist/src/rules/arm-feature-file-usage-discourage.js.map +1 -1
- package/dist/src/rules/arm-legacy-operations-discourage.js.map +1 -1
- package/dist/src/rules/arm-post-response-codes.js.map +1 -1
- package/dist/src/rules/arm-put-response-codes.js.map +1 -1
- package/dist/src/rules/arm-resource-action-no-segment.js.map +1 -1
- package/dist/src/rules/arm-resource-interfaces.js.map +1 -1
- package/dist/src/rules/arm-resource-invalid-action-verb.js.map +1 -1
- package/dist/src/rules/arm-resource-invalid-envelope-property.d.ts.map +1 -1
- package/dist/src/rules/arm-resource-invalid-envelope-property.js +1 -1
- package/dist/src/rules/arm-resource-invalid-envelope-property.js.map +1 -1
- package/dist/src/rules/arm-resource-invalid-version-format.js.map +1 -1
- package/dist/src/rules/arm-resource-operation-response.js.map +1 -1
- package/dist/src/rules/arm-resource-path-invalid-chars.d.ts.map +1 -1
- package/dist/src/rules/arm-resource-path-invalid-chars.js +1 -1
- package/dist/src/rules/arm-resource-path-invalid-chars.js.map +1 -1
- package/dist/src/rules/arm-resource-provisioning-state-rule.d.ts.map +1 -1
- package/dist/src/rules/arm-resource-provisioning-state-rule.js +1 -1
- package/dist/src/rules/arm-resource-provisioning-state-rule.js.map +1 -1
- package/dist/src/rules/beyond-nesting-levels.js.map +1 -1
- package/dist/src/rules/envelope-properties.js.map +1 -1
- package/dist/src/rules/improper-subscription-list-operation.js.map +1 -1
- package/dist/src/rules/lro-location-header.js.map +1 -1
- package/dist/src/rules/no-empty-model.js.map +1 -1
- package/dist/src/rules/no-reserved-resource-property.js.map +1 -1
- package/dist/src/rules/no-resource-delete-operation.js.map +1 -1
- package/dist/src/rules/no-response-body.d.ts.map +1 -1
- package/dist/src/rules/no-response-body.js +1 -1
- package/dist/src/rules/no-response-body.js.map +1 -1
- package/dist/src/rules/patch-envelope-properties.d.ts.map +1 -1
- package/dist/src/rules/patch-envelope-properties.js +1 -1
- package/dist/src/rules/patch-envelope-properties.js.map +1 -1
- package/dist/src/rules/retry-after.js.map +1 -1
- package/dist/src/rules/use-api-version.d.ts +4 -0
- package/dist/src/rules/use-api-version.d.ts.map +1 -0
- package/dist/src/rules/use-api-version.js +45 -0
- package/dist/src/rules/use-api-version.js.map +1 -0
- package/dist/src/rules/use-interface.d.ts +4 -0
- package/dist/src/rules/use-interface.d.ts.map +1 -0
- package/dist/src/rules/use-interface.js +29 -0
- package/dist/src/rules/use-interface.js.map +1 -0
- package/dist/src/rules/use-operation-decorator.d.ts +5 -0
- package/dist/src/rules/use-operation-decorator.d.ts.map +1 -0
- package/dist/src/rules/use-operation-decorator.js +133 -0
- package/dist/src/rules/use-operation-decorator.js.map +1 -0
- package/dist/src/rules/use-relationship-required-properties.d.ts.map +1 -1
- package/dist/src/rules/use-relationship-required-properties.js +1 -1
- package/dist/src/rules/use-relationship-required-properties.js.map +1 -1
- package/dist/src/rules/utils.d.ts +2 -2
- package/dist/src/rules/utils.d.ts.map +1 -1
- package/dist/src/rules/utils.js.map +1 -1
- package/dist/src/rules/version-progression.d.ts.map +1 -1
- package/dist/src/rules/version-progression.js +1 -1
- package/dist/src/rules/version-progression.js.map +1 -1
- package/dist/src/testing/index.d.ts +1 -1
- package/dist/src/testing/index.d.ts.map +1 -1
- package/lib/base-types/agent.tsp +3 -10
- package/lib/base-types/base-types.tsp +1 -1
- package/lib/common-types/billing-data.tsp +211 -0
- package/lib/common-types/common-types.tsp +1 -1
- package/lib/common-types/managed-identity-with-delegation.tsp +1 -0
- package/lib/common-types/network-security-perimeter.tsp +29 -0
- package/lib/common-types/types.tsp +5 -0
- package/lib/extension/parameters.tsp +2 -0
- package/lib/foundations/arm.foundations.tsp +1 -0
- package/lib/interfaces.tsp +2 -24
- package/lib/legacy-types/resource.tsp +1 -0
- package/lib/models.tsp +19 -1
- package/lib/private-endpoints.tsp +0 -2
- package/lib/private-links.tsp +0 -5
- package/package.json +15 -15
- package/dist/src/rules/core-operations.d.ts +0 -6
- package/dist/src/rules/core-operations.d.ts.map +0 -1
- package/dist/src/rules/core-operations.js +0 -105
- package/dist/src/rules/core-operations.js.map +0 -1
package/lib/interfaces.tsp
CHANGED
|
@@ -33,11 +33,12 @@ interface Operations {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
* @deprecated Use Azure.ResourceManager.TrackedResourceOperations instead
|
|
37
36
|
* A composite interface for resources that include `ResourceInstanceOperations<Resource, Properties>`
|
|
38
37
|
* and `ResourceCollectionOperations<Resource>`. It includes: `GET`, `PUT`, `PATCH`, `DELETE`, ListByParent,
|
|
39
38
|
* ListBySubscription operations. The actual route depends on the resource model.
|
|
40
39
|
* This is the most common API pattern for Tracked Resources to use.
|
|
40
|
+
*
|
|
41
|
+
* Deprecated: use `Azure.ResourceManager.TrackedResourceOperations` instead.
|
|
41
42
|
* @template Resource the ArmResource that provides these operations
|
|
42
43
|
* @template Properties RP-specific property bag for the resource
|
|
43
44
|
* @template BaseParameters The http parameters that are part of the request
|
|
@@ -147,7 +148,6 @@ interface ResourceCollectionOperations<
|
|
|
147
148
|
interface ResourceListBySubscription<Resource extends Foundations.SimpleResource> {
|
|
148
149
|
/**
|
|
149
150
|
* List resources by subscription.
|
|
150
|
-
* @template Resource The ArmResource to list.
|
|
151
151
|
*/
|
|
152
152
|
@doc("List {name} resources by subscription ID", Resource)
|
|
153
153
|
listBySubscription is ArmListBySubscription<Resource>;
|
|
@@ -168,10 +168,6 @@ interface ResourceListByParent<
|
|
|
168
168
|
> {
|
|
169
169
|
/**
|
|
170
170
|
* List resources by parent.
|
|
171
|
-
* @template Resource The ArmResource to list.
|
|
172
|
-
* @template BaseParameters The http parameters that are part of the request
|
|
173
|
-
* @template ParentName The name of the parent resource
|
|
174
|
-
* @template ParentFriendlyName The friendly name of the parent resource
|
|
175
171
|
*/
|
|
176
172
|
@Private.armRenameListByOperation(Resource, ParentName, ParentFriendlyName, true) // This must come before @armResourceList!
|
|
177
173
|
listByParent is ArmResourceListByParent<Resource, BaseParameters, ParentName, ParentFriendlyName>;
|
|
@@ -188,8 +184,6 @@ interface ResourceRead<
|
|
|
188
184
|
> {
|
|
189
185
|
/**
|
|
190
186
|
* Retrieve a resource.
|
|
191
|
-
* @template Resource The ArmResource to retrieve.
|
|
192
|
-
* @template BaseParameters The http parameters that are part of the request
|
|
193
187
|
*/
|
|
194
188
|
@doc("Get a {name}", Resource)
|
|
195
189
|
get is ArmResourceRead<Resource, BaseParameters>;
|
|
@@ -206,8 +200,6 @@ interface ResourceCreateSync<
|
|
|
206
200
|
> {
|
|
207
201
|
/**
|
|
208
202
|
* Create or update a resource using the synchronous call pattern.
|
|
209
|
-
* @template Resource The ArmResource to create or update.
|
|
210
|
-
* @template BaseParameters The http parameters that are part of the request
|
|
211
203
|
*/
|
|
212
204
|
@doc("Create a {name}", Resource)
|
|
213
205
|
createOrUpdate is ArmResourceCreateOrReplaceSync<Resource, BaseParameters>;
|
|
@@ -224,8 +216,6 @@ interface ResourceCreateAsync<
|
|
|
224
216
|
> {
|
|
225
217
|
/**
|
|
226
218
|
* Create or update a resource using the asynchronous call pattern.
|
|
227
|
-
* @template Resource The ArmResource to create or update.
|
|
228
|
-
* @template BaseParameters The http parameters that are part of the request
|
|
229
219
|
*/
|
|
230
220
|
@doc("Create a {name}", Resource)
|
|
231
221
|
createOrUpdate is ArmResourceCreateOrUpdateAsync<Resource, BaseParameters>;
|
|
@@ -245,8 +235,6 @@ interface ResourceDeleteAsync<
|
|
|
245
235
|
> {
|
|
246
236
|
/**
|
|
247
237
|
* Delete a resource using the asynchronous call pattern.
|
|
248
|
-
* @template Resource The ArmResource to delete.
|
|
249
|
-
* @template BaseParameters The http parameters that are part of the request
|
|
250
238
|
*/
|
|
251
239
|
@doc("Delete a {name}", Resource)
|
|
252
240
|
delete is ArmResourceDeleteAsync<Resource, BaseParameters>;
|
|
@@ -265,8 +253,6 @@ interface ResourceDeleteWithoutOkAsync<
|
|
|
265
253
|
> {
|
|
266
254
|
/**
|
|
267
255
|
* Delete a resource using the asynchronous call pattern.
|
|
268
|
-
* @template Resource The ArmResource to delete.
|
|
269
|
-
* @template BaseParameters The http parameters that are part of the request
|
|
270
256
|
*/
|
|
271
257
|
@doc("Delete a {name}", Resource)
|
|
272
258
|
delete is ArmResourceDeleteWithoutOkAsync<Resource, BaseParameters>;
|
|
@@ -284,8 +270,6 @@ interface ResourceDeleteSync<
|
|
|
284
270
|
> {
|
|
285
271
|
/**
|
|
286
272
|
* Delete a resource using the synchronous call pattern.
|
|
287
|
-
* @template Resource The ArmResource to delete.
|
|
288
|
-
* @template BaseParameters The http parameters that are part of the request
|
|
289
273
|
*/
|
|
290
274
|
@doc("Delete a {name}", Resource)
|
|
291
275
|
delete is ArmResourceDeleteSync<Resource, BaseParameters>;
|
|
@@ -305,9 +289,6 @@ interface ResourceUpdateAsync<
|
|
|
305
289
|
> {
|
|
306
290
|
/**
|
|
307
291
|
* Update a resource using the asynchronous call pattern.
|
|
308
|
-
* @template Resource The ArmResource to update.
|
|
309
|
-
* @template Properties RP-specific property bag for the resource
|
|
310
|
-
* @template BaseParameters The http parameters that are part of the request
|
|
311
292
|
*/
|
|
312
293
|
@doc("Update a {name}", Resource)
|
|
313
294
|
update is ArmCustomPatchAsync<
|
|
@@ -331,9 +312,6 @@ interface ResourceUpdateSync<
|
|
|
331
312
|
> {
|
|
332
313
|
/**
|
|
333
314
|
* Update a resource using the synchronous call pattern.
|
|
334
|
-
* @template Resource The ArmResource to update.
|
|
335
|
-
* @template Properties RP-specific property bag for the resource
|
|
336
|
-
* @template BaseParameters The http parameters that are part of the request
|
|
337
315
|
*/
|
|
338
316
|
#suppress "@typespec/http/deprecated-implicit-optionality" "Legacy"
|
|
339
317
|
@patch(#{ implicitOptionality: true })
|
package/lib/models.tsp
CHANGED
|
@@ -11,7 +11,7 @@ namespace Azure.ResourceManager;
|
|
|
11
11
|
* is specified, the resource name will be properly camel cased and pluralized for `@key` and `@segment`
|
|
12
12
|
* automatically. You can also apply explicit override with `KeyName` and `SegmentName` template parameters.
|
|
13
13
|
*
|
|
14
|
-
* For additional decorators such as
|
|
14
|
+
* For additional decorators such as `@minLength`, you can use either augment decorator on `[Resource].name` or passing in a scalar string type with decorators.
|
|
15
15
|
*
|
|
16
16
|
* @template Resource The ARM resource this name parameter is applying to.
|
|
17
17
|
* @template KeyName Override default key name of the resource.
|
|
@@ -229,6 +229,7 @@ model DefaultProvisioningStateProperty {
|
|
|
229
229
|
* ```
|
|
230
230
|
*/
|
|
231
231
|
model ExtendedLocationProperty {
|
|
232
|
+
/** The extended location of the resource. */
|
|
232
233
|
@visibility(Lifecycle.Read, Lifecycle.Create)
|
|
233
234
|
extendedLocation?: Foundations.ExtendedLocation;
|
|
234
235
|
}
|
|
@@ -452,4 +453,21 @@ model AvailabilityZonesProperty {
|
|
|
452
453
|
zones?: string[];
|
|
453
454
|
}
|
|
454
455
|
|
|
456
|
+
/**
|
|
457
|
+
* Standard resource billing data property to represent the resource's current billing state.
|
|
458
|
+
* Spread this model directly into your resource property model when modeling e.g. prepaid resources.
|
|
459
|
+
*
|
|
460
|
+
* @example
|
|
461
|
+
*
|
|
462
|
+
* ```typespec
|
|
463
|
+
* model FooProperties {
|
|
464
|
+
* ...BillingDataProperty,
|
|
465
|
+
* }
|
|
466
|
+
* ```
|
|
467
|
+
*/
|
|
468
|
+
model BillingDataProperty {
|
|
469
|
+
/** The billing data of the resource. */
|
|
470
|
+
billingData: CommonTypes.BillingData;
|
|
471
|
+
}
|
|
472
|
+
|
|
455
473
|
//#endregion
|
|
@@ -60,8 +60,6 @@ interface PrivateEndpoints<
|
|
|
60
60
|
* @template ParentResource the parent resource of the PrivateEndpointConnection
|
|
61
61
|
* @template Resource Optional. The PrivateEndpointConnection resource being listed
|
|
62
62
|
* @template BaseParameters Optional. Allows overriding the operation parameters
|
|
63
|
-
* @template ParentName Optional. The name of the parent resource
|
|
64
|
-
* @template ParentFriendlyName Optional. The friendly name of the parent resource
|
|
65
63
|
* @template Parameters Optional. Additional parameters after the path parameters
|
|
66
64
|
* @template Response Optional. The success response for the list operation
|
|
67
65
|
* @template Error Optional. The error response, if non-standard.
|
package/lib/private-links.tsp
CHANGED
|
@@ -10,7 +10,6 @@ namespace Azure.ResourceManager;
|
|
|
10
10
|
* Resource providers must declare a private link resource type in their provider namespace if
|
|
11
11
|
* they support private link resources
|
|
12
12
|
* @template Description Optional. The documentary description of the private link resource name parameter.
|
|
13
|
-
* @template KeyName Optional. The name of the private link resource name parameter.
|
|
14
13
|
* @example
|
|
15
14
|
* ```ts
|
|
16
15
|
* namespace Microsoft.Contoso;
|
|
@@ -61,8 +60,6 @@ interface PrivateLinks<
|
|
|
61
60
|
* @template ParentResource the parent resource of the PrivateLink
|
|
62
61
|
* @template Resource Optional. The PrivateLink resource being listed
|
|
63
62
|
* @template BaseParameters Optional. Allows overriding the operation parameters
|
|
64
|
-
* @template ParentName Optional. The name of the parent resource
|
|
65
|
-
* @template ParentFriendlyName Optional. The friendly name of the parent resource
|
|
66
63
|
* @template Parameters Optional. Additional parameters after the path parameters
|
|
67
64
|
* @template Response Optional. The success response for the list operation
|
|
68
65
|
* @template Error Optional. The error response, if non-standard.
|
|
@@ -95,8 +92,6 @@ interface PrivateLinks<
|
|
|
95
92
|
* @template ParentResource the parent resource of the PrivateLink
|
|
96
93
|
* @template Resource Optional. The PrivateLink resource being listed
|
|
97
94
|
* @template BaseParameters Optional. Allows overriding the operation parameters
|
|
98
|
-
* @template ParentName Optional. The name of the parent resource
|
|
99
|
-
* @template ParentFriendlyName Optional. The friendly name of the parent resource
|
|
100
95
|
* @template Parameters Optional. Additional parameters after the path parameters
|
|
101
96
|
* @template Response Optional. The success response for the list operation
|
|
102
97
|
* @template Error Optional. The error response, if non-standard.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azure-tools/typespec-azure-resource-manager",
|
|
3
|
-
"version": "0.71.0
|
|
3
|
+
"version": "0.71.0",
|
|
4
4
|
"author": "Microsoft Corporation",
|
|
5
5
|
"description": "TypeSpec Azure Resource Manager library",
|
|
6
6
|
"homepage": "https://azure.github.io/typespec-azure",
|
|
@@ -47,15 +47,14 @@
|
|
|
47
47
|
"pluralize": "^8.0.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@azure-tools/typespec-azure-core": "^0.
|
|
51
|
-
"@typespec/
|
|
52
|
-
"@typespec/
|
|
53
|
-
"@typespec/
|
|
54
|
-
"@typespec/
|
|
55
|
-
"@typespec/
|
|
50
|
+
"@azure-tools/typespec-azure-core": "^0.71.0",
|
|
51
|
+
"@typespec/http": "^1.15.0",
|
|
52
|
+
"@typespec/rest": "^0.85.0",
|
|
53
|
+
"@typespec/openapi": "^1.15.0",
|
|
54
|
+
"@typespec/versioning": "^0.85.0",
|
|
55
|
+
"@typespec/compiler": "^1.15.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@azure-tools/typespec-azure-core": "^0.70.0 || >= 0.71.0-dev.3",
|
|
59
58
|
"@types/node": "^26.0.0",
|
|
60
59
|
"@types/pluralize": "^0.0.33",
|
|
61
60
|
"@vitest/coverage-v8": "^4.1.3",
|
|
@@ -63,13 +62,14 @@
|
|
|
63
62
|
"rimraf": "^6.1.3",
|
|
64
63
|
"typescript": "~6.0.2",
|
|
65
64
|
"vitest": "^4.1.3",
|
|
66
|
-
"@typespec
|
|
67
|
-
"@typespec/http": "^1.
|
|
68
|
-
"@typespec/
|
|
69
|
-
"@typespec/
|
|
70
|
-
"@typespec/
|
|
71
|
-
"@typespec/
|
|
72
|
-
"@typespec/
|
|
65
|
+
"@azure-tools/typespec-azure-core": "^0.71.0",
|
|
66
|
+
"@typespec/http": "^1.15.0",
|
|
67
|
+
"@typespec/library-linter": "^0.85.0",
|
|
68
|
+
"@typespec/tspd": "^0.77.0",
|
|
69
|
+
"@typespec/rest": "^0.85.0",
|
|
70
|
+
"@typespec/compiler": "^1.15.0",
|
|
71
|
+
"@typespec/versioning": "^0.85.0",
|
|
72
|
+
"@typespec/openapi": "^1.15.0"
|
|
73
73
|
},
|
|
74
74
|
"scripts": {
|
|
75
75
|
"clean": "rimraf ./dist ./temp",
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare const coreOperationsRule: import("@typespec/compiler").LinterRuleDefinition<"arm-resource-operation", {
|
|
2
|
-
readonly default: "All Resource operations must use an api-version parameter. Please include Azure.ResourceManager.ApiVersionParameter in the operation parameter list using the spread (...ApiVersionParameter) operator, or using one of the common resource parameter models.";
|
|
3
|
-
readonly opOutsideInterface: "All operations must be inside an interface declaration.";
|
|
4
|
-
readonly opMissingDecorator: import("@typespec/compiler").CallableMessage<["verb", "decorator"]>;
|
|
5
|
-
}, Record<string, never>>;
|
|
6
|
-
//# sourceMappingURL=core-operations.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"core-operations.d.ts","sourceRoot":"","sources":["../../../src/rules/core-operations.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,kBAAkB;;;;yBA8D7B,CAAC"}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { createRule, fileRef, isTemplateInstance, paramMessage, } from "@typespec/compiler";
|
|
2
|
-
import { SyntaxKind } from "@typespec/compiler/ast";
|
|
3
|
-
import { getOperationVerb } from "@typespec/http";
|
|
4
|
-
import { getSegment } from "@typespec/rest";
|
|
5
|
-
import { getNamespaceName, getSourceModel, isSourceOperationResourceManagerInternal, isTemplatedInterfaceOperation, } from "./utils.js";
|
|
6
|
-
export const coreOperationsRule = createRule({
|
|
7
|
-
name: "arm-resource-operation",
|
|
8
|
-
docs: fileRef.fromPackageRoot("src/rules/arm-resource-operation.md"),
|
|
9
|
-
severity: "warning",
|
|
10
|
-
description: "Validate ARM Resource operations.",
|
|
11
|
-
url: "https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-resource-operation",
|
|
12
|
-
messages: {
|
|
13
|
-
default: "All Resource operations must use an api-version parameter. Please include Azure.ResourceManager.ApiVersionParameter in the operation parameter list using the spread (...ApiVersionParameter) operator, or using one of the common resource parameter models.",
|
|
14
|
-
opOutsideInterface: "All operations must be inside an interface declaration.",
|
|
15
|
-
opMissingDecorator: paramMessage `Resource ${"verb"} operation must be decorated with ${"decorator"}.`,
|
|
16
|
-
},
|
|
17
|
-
create(context) {
|
|
18
|
-
return {
|
|
19
|
-
operation: (operation) => {
|
|
20
|
-
if (!isSourceOperationResourceManagerInternal(operation) &&
|
|
21
|
-
!isTemplateInstance(operation)) {
|
|
22
|
-
const verb = getOperationVerb(context.program, operation);
|
|
23
|
-
if (!isTemplatedInterfaceOperation(operation) &&
|
|
24
|
-
(!operation.node?.parent ||
|
|
25
|
-
operation.node.parent.kind !== SyntaxKind.InterfaceStatement)) {
|
|
26
|
-
context.reportDiagnostic({
|
|
27
|
-
messageId: "opOutsideInterface",
|
|
28
|
-
target: operation,
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
const parameters = operation.parameters;
|
|
32
|
-
if (parameters === undefined ||
|
|
33
|
-
parameters === null ||
|
|
34
|
-
!hasApiParameter(context.program, parameters)) {
|
|
35
|
-
context.reportDiagnostic({
|
|
36
|
-
target: operation,
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
if (verb) {
|
|
40
|
-
const requiredDecorators = resourceOperationDecorators[verb];
|
|
41
|
-
if (requiredDecorators?.length > 0) {
|
|
42
|
-
const decorator = operation.decorators.find((d) => requiredDecorators.indexOf(d.decorator.name) >= 0);
|
|
43
|
-
if (!decorator && !isArmProviderOperation(context.program, operation)) {
|
|
44
|
-
context.reportDiagnostic({
|
|
45
|
-
messageId: "opMissingDecorator",
|
|
46
|
-
target: operation,
|
|
47
|
-
format: {
|
|
48
|
-
verb: verb.toUpperCase(),
|
|
49
|
-
decorator: requiredDecorators.map((d) => `@${d.substring(1)}`).join(" or "),
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
},
|
|
59
|
-
});
|
|
60
|
-
const resourceOperationDecorators = {
|
|
61
|
-
put: ["$armResourceCreateOrUpdate"],
|
|
62
|
-
get: ["$armResourceRead", "$armResourceList"],
|
|
63
|
-
patch: ["$armResourceUpdate"],
|
|
64
|
-
delete: ["$armResourceDelete"],
|
|
65
|
-
post: ["$armResourceAction", "$armResourceCollectionAction"],
|
|
66
|
-
head: [],
|
|
67
|
-
};
|
|
68
|
-
function isApiParameter(program, property) {
|
|
69
|
-
if (property.type.kind !== "Scalar")
|
|
70
|
-
return false;
|
|
71
|
-
if (!property.sourceProperty)
|
|
72
|
-
return false;
|
|
73
|
-
const sourceModel = getSourceModel(property.sourceProperty);
|
|
74
|
-
if (sourceModel === undefined)
|
|
75
|
-
return false;
|
|
76
|
-
return (sourceModel.name === "ApiVersionParameter" &&
|
|
77
|
-
getNamespaceName(program, sourceModel) === "Azure.ResourceManager.CommonTypes");
|
|
78
|
-
}
|
|
79
|
-
function hasApiParameter(program, model) {
|
|
80
|
-
if (model.properties === undefined || model.properties.size === 0)
|
|
81
|
-
return false;
|
|
82
|
-
const apiVersionParams = [...model.properties.values()].filter((i) => isApiParameter(program, i));
|
|
83
|
-
return apiVersionParams !== null && apiVersionParams.length === 1;
|
|
84
|
-
}
|
|
85
|
-
function isStaticSegment(segment, property) {
|
|
86
|
-
return segment === undefined || segment === "locations";
|
|
87
|
-
}
|
|
88
|
-
function isArmProviderOperation(program, operation) {
|
|
89
|
-
let isProviderAction = false;
|
|
90
|
-
for (const [index, [, property]] of [...operation.parameters.properties].entries()) {
|
|
91
|
-
const segment = getSegment(program, property);
|
|
92
|
-
if (segment === "providers") {
|
|
93
|
-
isProviderAction = true;
|
|
94
|
-
}
|
|
95
|
-
else if (isProviderAction && !isStaticSegment(segment, property)) {
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
const isLastSegment = index === operation.parameters.properties.size - 1;
|
|
99
|
-
if (isLastSegment && !segment) {
|
|
100
|
-
return true;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return false;
|
|
104
|
-
}
|
|
105
|
-
//# sourceMappingURL=core-operations.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{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