@azure-tools/typespec-azure-resource-manager 0.41.0-dev.0 → 0.41.0-dev.10

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.
Files changed (30) hide show
  1. package/README.md +5 -1
  2. package/dist/src/linter.d.ts.map +1 -1
  3. package/dist/src/linter.js +8 -0
  4. package/dist/src/linter.js.map +1 -1
  5. package/dist/src/rules/arm-delete-response-codes.d.ts.map +1 -1
  6. package/dist/src/rules/arm-delete-response-codes.js +17 -17
  7. package/dist/src/rules/arm-delete-response-codes.js.map +1 -1
  8. package/dist/src/rules/arm-post-response-codes.d.ts +8 -0
  9. package/dist/src/rules/arm-post-response-codes.d.ts.map +1 -0
  10. package/dist/src/rules/arm-post-response-codes.js +97 -0
  11. package/dist/src/rules/arm-post-response-codes.js.map +1 -0
  12. package/dist/src/rules/arm-put-response-codes.d.ts +7 -0
  13. package/dist/src/rules/arm-put-response-codes.d.ts.map +1 -0
  14. package/dist/src/rules/arm-put-response-codes.js +46 -0
  15. package/dist/src/rules/arm-put-response-codes.js.map +1 -0
  16. package/dist/src/rules/arm-resource-name-pattern.d.ts +7 -0
  17. package/dist/src/rules/arm-resource-name-pattern.d.ts.map +1 -0
  18. package/dist/src/rules/arm-resource-name-pattern.js +64 -0
  19. package/dist/src/rules/arm-resource-name-pattern.js.map +1 -0
  20. package/dist/src/rules/lro-location-header.d.ts +7 -0
  21. package/dist/src/rules/lro-location-header.d.ts.map +1 -0
  22. package/dist/src/rules/lro-location-header.js +47 -0
  23. package/dist/src/rules/lro-location-header.js.map +1 -0
  24. package/lib/arm.tsp +1 -1
  25. package/lib/customer-managed-keys.tsp +2 -2
  26. package/lib/models.tsp +5 -32
  27. package/lib/operations.tsp +18 -10
  28. package/lib/private-links.tsp +1 -1
  29. package/lib/responses.tsp +17 -9
  30. package/package.json +6 -6
package/README.md CHANGED
@@ -24,7 +24,7 @@ linter:
24
24
 
25
25
  Available ruleSets:
26
26
 
27
- - [`@azure-tools/typespec-azure-resource-manager/all`](#@azure-tools/typespec-azure-resource-manager/all)
27
+ - `@azure-tools/typespec-azure-resource-manager/all`
28
28
 
29
29
  ### Rules
30
30
 
@@ -33,11 +33,14 @@ Available ruleSets:
33
33
  | [`@azure-tools/typespec-azure-resource-manager/arm-no-record`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/no-record) | Don't use Record types for ARM resources. |
34
34
  | `@azure-tools/typespec-azure-resource-manager/arm-common-types-version` | Specify the ARM common-types version using @armCommonTypesVersion. |
35
35
  | [`@azure-tools/typespec-azure-resource-manager/arm-delete-operation-response-codes`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/delete-operation-response-codes) | Ensure delete operations have the appropriate status codes. |
36
+ | [`@azure-tools/typespec-azure-resource-manager/arm-put-operation-response-codes`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/put-operation-response-codes) | Ensure put operations have the appropriate status codes. |
37
+ | [`@azure-tools/typespec-azure-resource-manager/arm-post-operation-response-codes`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/post-operation-response-codes) | Ensure post operations have the appropriate status codes. |
36
38
  | `@azure-tools/typespec-azure-resource-manager/arm-resource-action-no-segment` | `@armResourceAction` should not be used with `@segment`. |
37
39
  | `@azure-tools/typespec-azure-resource-manager/arm-resource-duplicate-property` | Warn about duplicate properties in resources. |
38
40
  | `@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property` | Check for invalid resource envelope properties. |
39
41
  | `@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-version-format` | Check for valid versions. |
40
42
  | `@azure-tools/typespec-azure-resource-manager/arm-resource-key-invalid-chars` | Arm resource key must contain only alphanumeric characters. |
43
+ | [`@azure-tools/typespec-azure-resource-manager/arm-resource-name-pattern`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/resource-name-pattern) | The resource name parameter should be defined with a 'pattern' restriction. |
41
44
  | `@azure-tools/typespec-azure-resource-manager/arm-resource-operation-response` | [RPC 008]: PUT, GET, PATCH & LIST must return the same resource schema. |
42
45
  | `@azure-tools/typespec-azure-resource-manager/arm-resource-path-segment-invalid-chars` | Arm resource name must contain only alphanumeric characters. |
43
46
  | `@azure-tools/typespec-azure-resource-manager/arm-resource-provisioning-state` | Check for properly configured provisioningState property. |
@@ -48,6 +51,7 @@ Available ruleSets:
48
51
  | `@azure-tools/typespec-azure-resource-manager/arm-resource-interface-requires-decorator` | Each resource interface must have an @armResourceOperations decorator. |
49
52
  | `@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-action-verb` | Actions must be HTTP Post operations. |
50
53
  | `@azure-tools/typespec-azure-resource-manager/improper-subscription-list-operation` | Tenant and Extension resources should not define a list by subscription operation. |
54
+ | [`@azure-tools/typespec-azure-resource-manager/lro-location-header`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/lro-location-header) | A 202 response should include a Location response header. |
51
55
  | [`@azure-tools/typespec-azure-resource-manager/missing-x-ms-identifiers`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/missing-x-ms-identifiers) | Azure services should not use enums. |
52
56
  | `@azure-tools/typespec-azure-resource-manager/no-response-body` | The body of 202 response should be empty. |
53
57
  | `@azure-tools/typespec-azure-resource-manager/missing-operations-endpoint` | Check for missing Operations interface. |
@@ -1 +1 @@
1
- {"version":3,"file":"linter.d.ts","sourceRoot":"","sources":["../../src/linter.ts"],"names":[],"mappings":"AA6DA,eAAO,MAAM,OAAO,+CAmBlB,CAAC"}
1
+ {"version":3,"file":"linter.d.ts","sourceRoot":"","sources":["../../src/linter.ts"],"names":[],"mappings":"AAqEA,eAAO,MAAM,OAAO,+CAmBlB,CAAC"}
@@ -2,6 +2,8 @@ import { defineLinter } from "@typespec/compiler";
2
2
  import { armCommonTypesVersionRule } from "./rules/arm-common-types-version.js";
3
3
  import { armDeleteResponseCodesRule } from "./rules/arm-delete-response-codes.js";
4
4
  import { armNoRecordRule } from "./rules/arm-no-record.js";
5
+ import { armPostResponseCodesRule } from "./rules/arm-post-response-codes.js";
6
+ import { armPutResponseCodesRule } from "./rules/arm-put-response-codes.js";
5
7
  import { armResourceActionNoSegmentRule } from "./rules/arm-resource-action-no-segment.js";
6
8
  import { armResourceDuplicatePropertiesRule } from "./rules/arm-resource-duplicate-property.js";
7
9
  import { interfacesRule } from "./rules/arm-resource-interfaces.js";
@@ -9,6 +11,7 @@ import { invalidActionVerbRule } from "./rules/arm-resource-invalid-action-verb.
9
11
  import { armResourceEnvelopeProperties } from "./rules/arm-resource-invalid-envelope-property.js";
10
12
  import { armResourceInvalidVersionFormatRule } from "./rules/arm-resource-invalid-version-format.js";
11
13
  import { armResourceKeyInvalidCharsRule } from "./rules/arm-resource-key-invalid-chars.js";
14
+ import { armResourceNamePatternRule } from "./rules/arm-resource-name-pattern.js";
12
15
  import { armResourceOperationsRule } from "./rules/arm-resource-operation-response.js";
13
16
  import { patchOperationsRule } from "./rules/arm-resource-patch.js";
14
17
  import { armResourcePathInvalidCharsRule } from "./rules/arm-resource-path-invalid-chars.js";
@@ -18,6 +21,7 @@ import { coreOperationsRule } from "./rules/core-operations.js";
18
21
  import { deleteOperationMissingRule } from "./rules/delete-operation.js";
19
22
  import { envelopePropertiesRules } from "./rules/envelope-properties.js";
20
23
  import { listBySubscriptionRule } from "./rules/list-operation.js";
24
+ import { lroLocationHeaderRule } from "./rules/lro-location-header.js";
21
25
  import { missingXmsIdentifiersRule } from "./rules/missing-x-ms-identifiers.js";
22
26
  import { noResponseBodyRule } from "./rules/no-response-body.js";
23
27
  import { operationsInterfaceMissingRule } from "./rules/operations-interface-missing.js";
@@ -29,11 +33,14 @@ const rules = [
29
33
  armNoRecordRule,
30
34
  armCommonTypesVersionRule,
31
35
  armDeleteResponseCodesRule,
36
+ armPutResponseCodesRule,
37
+ armPostResponseCodesRule,
32
38
  armResourceActionNoSegmentRule,
33
39
  armResourceDuplicatePropertiesRule,
34
40
  armResourceEnvelopeProperties,
35
41
  armResourceInvalidVersionFormatRule,
36
42
  armResourceKeyInvalidCharsRule,
43
+ armResourceNamePatternRule,
37
44
  armResourceOperationsRule,
38
45
  armResourcePathInvalidCharsRule,
39
46
  armResourceProvisioningStateRule,
@@ -44,6 +51,7 @@ const rules = [
44
51
  interfacesRule,
45
52
  invalidActionVerbRule,
46
53
  listBySubscriptionRule,
54
+ lroLocationHeaderRule,
47
55
  missingXmsIdentifiersRule,
48
56
  noResponseBodyRule,
49
57
  operationsInterfaceMissingRule,
@@ -1 +1 @@
1
- {"version":3,"file":"linter.js","sourceRoot":"","sources":["../../src/linter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAChF,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,8BAA8B,EAAE,MAAM,2CAA2C,CAAC;AAC3F,OAAO,EAAE,kCAAkC,EAAE,MAAM,4CAA4C,CAAC;AAChG,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AACpF,OAAO,EAAE,6BAA6B,EAAE,MAAM,mDAAmD,CAAC;AAClG,OAAO,EAAE,mCAAmC,EAAE,MAAM,gDAAgD,CAAC;AACrG,OAAO,EAAE,8BAA8B,EAAE,MAAM,2CAA2C,CAAC;AAC3F,OAAO,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AACvF,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,+BAA+B,EAAE,MAAM,4CAA4C,CAAC;AAC7F,OAAO,EAAE,gCAAgC,EAAE,MAAM,iDAAiD,CAAC;AACnG,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,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AAmB;CACpB,CAAC;AAEF,MAAM,eAAe,GAAG,MAAM,CAAC,WAAW,CACxC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,gDAAgD,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI,CAAC,CAAC,CACzF,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAG,YAAY,CAAC;IAClC,KAAK;IACL,QAAQ,EAAE;QACR,GAAG,EAAE;YACH,OAAO,EAAE;gBACP,sCAAsC;gBACtC,uDAAuD;aACxD;YACD,MAAM,EAAE;gBACN,GAAG,eAAe;gBAClB,+EAA+E;gBAC/E,CAAC,gDAAgD,yBAAyB,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK;aAC1F;YACD,OAAO,EAAE;gBACP,CAAC,kDAAkD,CAAC,EAClD,6CAA6C;aAChD;SACF;KACF;CACF,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"arm-delete-response-codes.d.ts","sourceRoot":"","sources":["../../../src/rules/arm-delete-response-codes.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,eAAO,MAAM,0BAA0B;;;EAmCrC,CAAC"}
1
+ {"version":3,"file":"arm-delete-response-codes.d.ts","sourceRoot":"","sources":["../../../src/rules/arm-delete-response-codes.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,eAAO,MAAM,0BAA0B;;;EAqCrC,CAAC"}
@@ -1,6 +1,5 @@
1
1
  import { createRule } from "@typespec/compiler";
2
2
  import { getLroMetadata } from "@azure-tools/typespec-azure-core";
3
- import { getHttpOperation } from "@typespec/http";
4
3
  import { getArmResources } from "../resource.js";
5
4
  /**
6
5
  * Verify that a delete operation only
@@ -16,22 +15,23 @@ export const armDeleteResponseCodesRule = createRule({
16
15
  },
17
16
  create(context) {
18
17
  return {
19
- model: (model) => {
20
- const resources = getArmResources(context.program);
21
- const armResource = resources.find((re) => re.typespecType === model);
22
- if (armResource && armResource.operations.lifecycle.delete) {
23
- const deleteOperation = armResource.operations.lifecycle.delete;
24
- const isAsync = getLroMetadata(context.program, deleteOperation.operation) !== undefined;
25
- const [httpOp, _] = getHttpOperation(context.program, deleteOperation.operation);
26
- const statusCodes = new Set([...httpOp.responses.map((r) => r.statusCodes.toString())]);
27
- const expected = new Set(["204", "*"]);
28
- expected.add(isAsync ? "202" : "200");
29
- if (statusCodes.size !== expected.size ||
30
- ![...statusCodes].every((v) => expected.has(v))) {
31
- context.reportDiagnostic({
32
- target: deleteOperation.operation,
33
- messageId: isAsync ? "async" : "sync",
34
- });
18
+ root: (program) => {
19
+ const resources = getArmResources(program);
20
+ for (const resource of resources) {
21
+ if (resource.operations.lifecycle.delete) {
22
+ const deleteOperation = resource.operations.lifecycle.delete;
23
+ const isAsync = getLroMetadata(context.program, deleteOperation.operation) !== undefined;
24
+ const httpOp = deleteOperation.httpOperation;
25
+ const statusCodes = new Set([...httpOp.responses.map((r) => r.statusCodes.toString())]);
26
+ const expected = new Set(["204", "*"]);
27
+ expected.add(isAsync ? "202" : "200");
28
+ if (statusCodes.size !== expected.size ||
29
+ ![...statusCodes].every((v) => expected.has(v))) {
30
+ context.reportDiagnostic({
31
+ target: deleteOperation.operation,
32
+ messageId: isAsync ? "async" : "sync",
33
+ });
34
+ }
35
35
  }
36
36
  }
37
37
  },
@@ -1 +1 @@
1
- {"version":3,"file":"arm-delete-response-codes.js","sourceRoot":"","sources":["../../../src/rules/arm-delete-response-codes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,UAAU,CAAC;IACnD,IAAI,EAAE,qCAAqC;IAC3C,QAAQ,EAAE,SAAS;IACnB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,SAAS,CAAC,KAAK,SAAS,CAAC;wBAC3E,MAAM,MAAM,GAAG,eAAe,CAAC,aAAa,CAAC;wBAC7C,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC;wBACxF,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;wBACvC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;wBAEtC,IACE,WAAW,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI;4BAClC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAC/C,CAAC;4BACD,OAAO,CAAC,gBAAgB,CAAC;gCACvB,MAAM,EAAE,eAAe,CAAC,SAAS;gCACjC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM;6BACtC,CAAC,CAAC;wBACL,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Verify that a post operation has the correct response codes.
3
+ */
4
+ export declare const armPostResponseCodesRule: import("@typespec/compiler").LinterRuleDefinition<"arm-post-operation-response-codes", {
5
+ readonly sync: "Synchronous post operations must have a 200 or 204 response and a default response. They must not have any other responses.";
6
+ readonly async: "Long-running post operations must have 202 and default responses. They must also have a 200 response if the final response has a schema. They must not have any other responses.";
7
+ }>;
8
+ //# sourceMappingURL=arm-post-response-codes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arm-post-response-codes.d.ts","sourceRoot":"","sources":["../../../src/rules/arm-post-response-codes.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;EAkGnC,CAAC"}
@@ -0,0 +1,97 @@
1
+ import { createRule } from "@typespec/compiler";
2
+ import { getLroMetadata } from "@azure-tools/typespec-azure-core";
3
+ import { getArmResources } from "../resource.js";
4
+ /**
5
+ * Verify that a post operation has the correct response codes.
6
+ */
7
+ export const armPostResponseCodesRule = createRule({
8
+ name: "arm-post-operation-response-codes",
9
+ severity: "warning",
10
+ url: "https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/post-operation-response-codes",
11
+ description: "Ensure post operations have the appropriate status codes.",
12
+ messages: {
13
+ sync: `Synchronous post operations must have a 200 or 204 response and a default response. They must not have any other responses.`,
14
+ async: `Long-running post operations must have 202 and default responses. They must also have a 200 response if the final response has a schema. They must not have any other responses.`,
15
+ },
16
+ create(context) {
17
+ function getResponseBody(response) {
18
+ if (response === undefined)
19
+ return undefined;
20
+ if (response.responses.length > 1) {
21
+ throw new Error("Multiple responses are not supported.");
22
+ }
23
+ if (response.responses[0].body !== undefined) {
24
+ return response.responses[0].body;
25
+ }
26
+ return undefined;
27
+ }
28
+ function validateAsyncPost(op) {
29
+ const statusCodes = new Set([
30
+ ...op.httpOperation.responses.map((r) => r.statusCodes.toString()),
31
+ ]);
32
+ // validate that there are 202 and * status codes, and maybe 200
33
+ const expected = statusCodes.size === 2 ? new Set(["202", "*"]) : new Set(["202", "200", "*"]);
34
+ if (statusCodes.size !== expected.size || ![...statusCodes].every((v) => expected.has(v))) {
35
+ context.reportDiagnostic({
36
+ target: op.operation,
37
+ messageId: "async",
38
+ });
39
+ }
40
+ // validate that 202 does not have a schema
41
+ const response202 = op.httpOperation.responses.find((r) => r.statusCodes === 202);
42
+ const body202 = getResponseBody(response202);
43
+ if (body202 !== undefined) {
44
+ context.reportDiagnostic({
45
+ target: op.operation.returnType,
46
+ messageId: "async",
47
+ });
48
+ }
49
+ // validate that a 200 response does have a schema
50
+ const response200 = op.httpOperation.responses.find((r) => r.statusCodes === 200);
51
+ const body200 = getResponseBody(response200);
52
+ if (response200 && body200 === undefined) {
53
+ context.reportDiagnostic({
54
+ target: op.operation.returnType,
55
+ messageId: "async",
56
+ });
57
+ }
58
+ }
59
+ function validateSyncPost(op) {
60
+ const allowed = [new Set(["200", "*"]), new Set(["204", "*"])];
61
+ const statusCodes = new Set([
62
+ ...op.httpOperation.responses.map((r) => r.statusCodes.toString()),
63
+ ]);
64
+ if (!allowed.some((expected) => statusCodes.size === expected.size && [...statusCodes].every((v) => expected.has(v)))) {
65
+ context.reportDiagnostic({
66
+ target: op.operation,
67
+ messageId: "sync",
68
+ });
69
+ }
70
+ }
71
+ return {
72
+ root: (program) => {
73
+ const resources = getArmResources(program);
74
+ for (const resource of resources) {
75
+ const operations = [
76
+ resource.operations.lifecycle.createOrUpdate,
77
+ resource.operations.lifecycle.update,
78
+ ...Object.values(resource.operations.actions),
79
+ ];
80
+ for (const op of operations) {
81
+ if (op === undefined || op.httpOperation.verb !== "post") {
82
+ continue;
83
+ }
84
+ const isAsync = getLroMetadata(context.program, op.operation) !== undefined;
85
+ if (isAsync) {
86
+ validateAsyncPost(op);
87
+ }
88
+ else {
89
+ validateSyncPost(op);
90
+ }
91
+ }
92
+ }
93
+ },
94
+ };
95
+ },
96
+ });
97
+ //# sourceMappingURL=arm-post-response-codes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arm-post-response-codes.js","sourceRoot":"","sources":["../../../src/rules/arm-post-response-codes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAGlE,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,UAAU,CAAC;IACjD,IA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AAC,CAAC;wBACxB,CAAC;6BAAM,CAAC;4BACN,gBAAgB,CAAC,EAAE,CAAC,CAAC;wBACvB,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Verify that a put operation has the correct response codes.
3
+ */
4
+ export declare const armPutResponseCodesRule: import("@typespec/compiler").LinterRuleDefinition<"arm-put-operation-response-codes", {
5
+ readonly default: "Put operations must have 200, 201 and default responses. They must not have any other responses.";
6
+ }>;
7
+ //# sourceMappingURL=arm-put-response-codes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arm-put-response-codes.d.ts","sourceRoot":"","sources":["../../../src/rules/arm-put-response-codes.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,eAAO,MAAM,uBAAuB;;EAyClC,CAAC"}
@@ -0,0 +1,46 @@
1
+ import { createRule } from "@typespec/compiler";
2
+ import { getArmResources } from "../resource.js";
3
+ /**
4
+ * Verify that a put operation has the correct response codes.
5
+ */
6
+ export const armPutResponseCodesRule = createRule({
7
+ name: "arm-put-operation-response-codes",
8
+ severity: "warning",
9
+ url: "https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/put-operation-response-codes",
10
+ description: "Ensure put operations have the appropriate status codes.",
11
+ messages: {
12
+ default: `Put operations must have 200, 201 and default responses. They must not have any other responses.`,
13
+ },
14
+ create(context) {
15
+ return {
16
+ root: (program) => {
17
+ const resources = getArmResources(program);
18
+ const expected = new Set(["200", "201", "*"]);
19
+ for (const resource of resources) {
20
+ const operations = [
21
+ resource.operations.lifecycle.createOrUpdate,
22
+ resource.operations.lifecycle.update,
23
+ ...Object.values(resource.operations.actions),
24
+ ];
25
+ for (const op of operations) {
26
+ if (op === undefined) {
27
+ continue;
28
+ }
29
+ if (op.httpOperation.verb === "put") {
30
+ const statusCodes = new Set([
31
+ ...op.httpOperation.responses.map((r) => r.statusCodes.toString()),
32
+ ]);
33
+ if (statusCodes.size !== expected.size ||
34
+ ![...statusCodes].every((v) => expected.has(v))) {
35
+ context.reportDiagnostic({
36
+ target: op.operation,
37
+ });
38
+ }
39
+ }
40
+ }
41
+ }
42
+ },
43
+ };
44
+ },
45
+ });
46
+ //# sourceMappingURL=arm-put-response-codes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arm-put-response-codes.js","sourceRoot":"","sources":["../../../src/rules/arm-put-response-codes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,UAAU,CAAC;IAChD,IAAI,EAAE,kCAAkC;IACxC,QAAQ,EAAE,SAAS;IACnB,GAAG,EAAE,iHAAiH;IACtH,WAAW,EAAE,0DAA0D;IACvE,QAAQ,EAAE;QACR,OAAO,EAAE,kGAAkG;KAC5G;IACD,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,IAAI,EAAE,CAAC,OAAgB,EAAE,EAAE;gBACzB,MAAM,SAAS,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;gBAC3C,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;gBAC9C,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;oBACjC,MAAM,UAAU,GAAG;wBACjB,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,cAAc;wBAC5C,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,MAAM;wBACpC,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC;qBAC9C,CAAC;oBACF,KAAK,MAAM,EAAE,IAAI,UAAU,EAAE,CAAC;wBAC5B,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;4BACrB,SAAS;wBACX,CAAC;wBACD,IAAI,EAAE,CAAC,aAAa,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;4BACpC,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC;gCAC1B,GAAG,EAAE,CAAC,aAAa,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;6BACnE,CAAC,CAAC;4BACH,IACE,WAAW,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI;gCAClC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAC/C,CAAC;gCACD,OAAO,CAAC,gBAAgB,CAAC;oCACvB,MAAM,EAAE,EAAE,CAAC,SAAS;iCACrB,CAAC,CAAC;4BACL,CAAC;wBACH,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Verify that a delete operation only
3
+ */
4
+ export declare const armResourceNamePatternRule: import("@typespec/compiler").LinterRuleDefinition<"arm-resource-name-pattern", {
5
+ readonly default: "The resource name parameter should be defined with a 'pattern' restriction. Decorate the \"name\" property in the resource definition using the @pattern decorator, with a regular expression indicating the allowed characters in the resource name.";
6
+ }>;
7
+ //# sourceMappingURL=arm-resource-name-pattern.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arm-resource-name-pattern.d.ts","sourceRoot":"","sources":["../../../src/rules/arm-resource-name-pattern.ts"],"names":[],"mappings":"AA0CA;;GAEG;AACH,eAAO,MAAM,0BAA0B;;EA4BrC,CAAC"}
@@ -0,0 +1,64 @@
1
+ import { createRule, defineCodeFix, getPattern, getSourceLocation, } from "@typespec/compiler";
2
+ import { getArmResources } from "../resource.js";
3
+ // TODO: Replace this with a reusable implementation from the compiler package when implemented.
4
+ // Issue: https://github.com/microsoft/typespec/issues/3044
5
+ function createPatternCodeFix(diagnosticTarget) {
6
+ return defineCodeFix({
7
+ id: "add-pattern-decorator",
8
+ label: "Add `@pattern` decorator to the resource name property with the default ARM pattern.",
9
+ fix: (context) => {
10
+ const location = getSourceLocation(diagnosticTarget);
11
+ const { lineStart, indent } = findLineStartAndIndent(location);
12
+ const updatedLocation = { ...location, pos: lineStart };
13
+ return context.prependText(updatedLocation, `${indent}@pattern(/^[a-zA-Z0-9-]{3,24}$/)\n`);
14
+ },
15
+ });
16
+ }
17
+ function findLineStartAndIndent(location) {
18
+ const text = location.file.text;
19
+ let pos = location.pos;
20
+ let indent = 0;
21
+ while (pos > 0 && text[pos - 1] !== "\n") {
22
+ if ([" ", "\t", "\n"].includes(text[pos - 1])) {
23
+ indent++;
24
+ }
25
+ else {
26
+ indent = 0;
27
+ }
28
+ pos--;
29
+ }
30
+ return { lineStart: pos, indent: location.file.text.slice(pos, pos + indent) };
31
+ }
32
+ /**
33
+ * Verify that a delete operation only
34
+ */
35
+ export const armResourceNamePatternRule = createRule({
36
+ name: "arm-resource-name-pattern",
37
+ severity: "warning",
38
+ url: "https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/resource-name-pattern",
39
+ description: "The resource name parameter should be defined with a 'pattern' restriction.",
40
+ messages: {
41
+ default: `The resource name parameter should be defined with a 'pattern' restriction. Decorate the "name" property in the resource definition using the @pattern decorator, with a regular expression indicating the allowed characters in the resource name.`,
42
+ },
43
+ create(context) {
44
+ return {
45
+ root: (program) => {
46
+ const resources = getArmResources(program);
47
+ for (const resource of resources) {
48
+ // find the name property
49
+ const nameProperty = resource.typespecType.properties.get("name");
50
+ if (nameProperty !== undefined) {
51
+ const pattern = getPattern(program, nameProperty);
52
+ if (pattern === undefined) {
53
+ context.reportDiagnostic({
54
+ target: nameProperty,
55
+ codefixes: [createPatternCodeFix(nameProperty)],
56
+ });
57
+ }
58
+ }
59
+ }
60
+ },
61
+ };
62
+ },
63
+ });
64
+ //# sourceMappingURL=arm-resource-name-pattern.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arm-resource-name-pattern.js","sourceRoot":"","sources":["../../../src/rules/arm-resource-name-pattern.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,UAAU,EACV,aAAa,EACb,UAAU,EACV,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,gGAAgG;AAChG,2DAA2D;AAC3D,SAAS,oBAAoB,CAAC,gBAAkC;IAC9D,OAAO,aAAa,CAAC;QACnB,EAAE,EAAE,uBAAuB;QAC3B,KAAK,EAAE,sFAAsF;QAC7F,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE;YACf,MAAM,QAAQ,GAAG,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;YACrD,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,sBAAsB,CAAC,QAAQ,CAAC,CAAC;YAC/D,MAAM,eAAe,GAAG,EAAE,GAAG,QAAQ,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;YACxD,OAAO,OAAO,CAAC,WAAW,CAAC,eAAe,EAAE,GAAG,MAAM,oCAAoC,CAAC,CAAC;QAC7F,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAED,SAAS,sBAAsB,CAAC,QAAwB;IACtD,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;IAChC,IAAI,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC;IACvB,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,OAAO,GAAG,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QACzC,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE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responses have a Location Header.
3
+ */
4
+ export declare const lroLocationHeaderRule: import("@typespec/compiler").LinterRuleDefinition<"lro-location-header", {
5
+ readonly default: "A 202 response should include a Location response header.";
6
+ }>;
7
+ //# sourceMappingURL=lro-location-header.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lro-location-header.d.ts","sourceRoot":"","sources":["../../../src/rules/lro-location-header.ts"],"names":[],"mappings":"AAkBA;;GAEG;AACH,eAAO,MAAM,qBAAqB;;EA6BhC,CAAC"}
@@ -0,0 +1,47 @@
1
+ import { createRule } from "@typespec/compiler";
2
+ import { getHttpOperation } from "@typespec/http";
3
+ function getCaseInsensitiveHeader(headers, key) {
4
+ if (!headers) {
5
+ return undefined;
6
+ }
7
+ for (const header of Object.keys(headers)) {
8
+ if (header.toLowerCase() === key.toLowerCase()) {
9
+ return header;
10
+ }
11
+ }
12
+ return undefined;
13
+ }
14
+ /**
15
+ * Ensure that LRO 202 responses have a Location Header.
16
+ */
17
+ export const lroLocationHeaderRule = createRule({
18
+ name: "lro-location-header",
19
+ severity: "warning",
20
+ url: "https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/lro-location-header",
21
+ description: "A 202 response should include a Location response header.",
22
+ messages: {
23
+ default: `A 202 response should include a Location response header.`,
24
+ },
25
+ create(context) {
26
+ return {
27
+ operation: (op) => {
28
+ const [httpOperation, _] = getHttpOperation(context.program, op);
29
+ const responses = httpOperation.responses;
30
+ for (const response of responses) {
31
+ if (response.statusCodes !== 202) {
32
+ continue;
33
+ }
34
+ for (const resp of response.responses) {
35
+ if (getCaseInsensitiveHeader(resp.headers, "Location") === undefined) {
36
+ context.reportDiagnostic({
37
+ target: op,
38
+ });
39
+ return;
40
+ }
41
+ }
42
+ }
43
+ },
44
+ };
45
+ },
46
+ });
47
+ //# sourceMappingURL=lro-location-header.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lro-location-header.js","sourceRoot":"","sources":["../../../src/rules/lro-location-header.ts"],"names":[],"mapp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AC;gCACvB,MAAM,EAAE,EAAE;6BACX,CAAC,CAAC;4BACH,OAAO;wBACT,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
package/lib/arm.tsp CHANGED
@@ -34,6 +34,6 @@ namespace Azure.ResourceManager;
34
34
  @doc("Supported versions of Azure.ResourceManager building blocks.")
35
35
  enum Versions {
36
36
  @doc("Version 1.0-preview.1")
37
- @useDependency(Azure.Core.Versions.v1_0_Preview_1)
37
+ @useDependency(Azure.Core.Versions.v1_0_Preview_2)
38
38
  v1_0_Preview_1: "1.0-preview.1",
39
39
  }
@@ -30,7 +30,7 @@ model CustomerManagedKeyEncryption {
30
30
  keyEncryptionIdentity?: KeyEncryptionIdentity;
31
31
 
32
32
  @doc("User assigned identity to use for accessing key encryption key Url. Ex: /subscriptions/fa5fc227-a624-475e-b696-cdd604c735bc/resourceGroups/<resource group>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myId. Mutually exclusive with identityType systemAssignedIdentity.")
33
- userAssignedIdentityResourceId?: ResourceIdentifier<[
33
+ userAssignedIdentityResourceId?: Azure.Core.armResourceIdentifier<[
34
34
  {
35
35
  type: "Microsoft.ManagedIdentity/userAssignedIdentities";
36
36
  }
@@ -40,7 +40,7 @@ model CustomerManagedKeyEncryption {
40
40
  federatedClientId?: uuid;
41
41
 
42
42
  @doc("delegated identity to use for accessing key encryption key Url. Ex: /subscriptions/fa5fc227-a624-475e-b696-cdd604c735bc/resourceGroups/<resource group>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myId. Mutually exclusive with identityType systemAssignedIdentity and userAssignedIdentity - internal use only.")
43
- delegatedIdentityClientId: uuid;
43
+ delegatedIdentityClientId?: uuid;
44
44
  }
45
45
 
46
46
  @doc("All encryption configuration for a resource.")
package/lib/models.tsp CHANGED
@@ -90,40 +90,13 @@ model ProviderNamespace<Resource extends {}> {
90
90
  //#region Common Azure Resource Manager type definitions
91
91
 
92
92
  /**
93
- * A type definition that refers the id to an Azure Resource Manager resource.
94
- *
95
- * Sample usage:
96
- * otherArmId: ResourceIdentifier;
97
- * networkId: ResourceIdentifier<[{type:"\\Microsoft.Network\\vnet"}]>
98
- * vmIds: ResourceIdentifier<[{type:"\\Microsoft.Compute\\vm", scopes["*"]}]>
99
- * @template AllowedResourceTypes An array of allowed resource types for the resource reference
93
+ * Use Azure.Core.armResourceIdentifier<AllowedResourceTypes>
100
94
  */
101
- @doc("A type definition that refers the id to an Azure Resource Manager resource.")
102
- @format("arm-id")
103
- @OpenAPI.extension(
104
- "x-ms-arm-id-details",
105
- {
106
- allowedResources: AllowedResourceTypes,
107
- }
108
- )
109
- scalar ResourceIdentifier<AllowedResourceTypes extends ResourceIdentifierAllowedResource[] = []>
110
- extends string;
95
+ #deprecated "Use Azure.Core.armResourceIdentifier<AllowedResourceTypes> instead."
96
+ alias ResourceIdentifier<AllowedResourceTypes extends ArmResourceIdentifierAllowedResource[] = never> = Azure.Core.armResourceIdentifier<AllowedResourceTypes>;
111
97
 
112
- /**
113
- * Used in ResourceIdentifier definition to represent a particular type of Azure Resource Manager resource, enabling constraints based on resource type.
114
- * See [link](https://github.com/Azure/autorest/tree/main/docs/extensions#schema)
115
- */
116
- @doc("Optional definition represents a particular type of Azure Resource Manager resource which can be referred to by a ResourceIdentifier.")
117
- model ResourceIdentifierAllowedResource {
118
- @doc("The type of resource that is being referred to. For example Microsoft.Network/virtualNetworks or Microsoft.Network/virtualNetworks/subnets. See Example Types for more examples.")
119
- type: string;
120
-
121
- @doc("""
122
- An array of scopes. If not specified, the default scope is ["ResourceGroup"].
123
- See [Allowed Scopes](https://github.com/Azure/autorest/tree/main/docs/extensions#allowed-scopes).
124
- """)
125
- scopes?: string[] = [];
126
- }
98
+ #deprecated "Use ArmResourceIdentifierAllowedResource instead."
99
+ alias ResourceIdentifierAllowedResource = ArmResourceIdentifierAllowedResource;
127
100
 
128
101
  /**
129
102
  * Standard terminal provisioning state of resource type. You can spread into your
@@ -154,7 +154,7 @@ op ArmResourceCheckExistence<
154
154
  op ArmResourceCreateOrUpdateAsync<
155
155
  Resource extends ArmResource,
156
156
  BaseParameters = DefaultBaseParameters<Resource>,
157
- LroHeaders extends TypeSpec.Reflection.Model = {},
157
+ LroHeaders extends TypeSpec.Reflection.Model = Azure.Core.Foundations.RetryAfterHeader,
158
158
  Parameters extends {} = {},
159
159
  Response extends {} = ArmResourceUpdatedResponse<Resource> | ArmResourceCreatedResponse<
160
160
  Resource,
@@ -231,7 +231,7 @@ op ArmResourceCreateOrReplaceSync<
231
231
  op ArmResourceCreateOrReplaceAsync<
232
232
  Resource extends ArmResource,
233
233
  BaseParameters = DefaultBaseParameters<Resource>,
234
- LroHeaders extends TypeSpec.Reflection.Model = {},
234
+ LroHeaders extends TypeSpec.Reflection.Model = Azure.Core.Foundations.RetryAfterHeader,
235
235
  Parameters extends {} = {},
236
236
  Response extends {} = ArmResourceUpdatedResponse<Resource> | ArmResourceCreatedResponse<
237
237
  Resource,
@@ -262,7 +262,8 @@ op ArmTagsPatchAsync<
262
262
  Azure.Core.StatusMonitorPollingOptions<ArmOperationStatus>,
263
263
  Resource,
264
264
  string
265
- >,
265
+ > &
266
+ Azure.Core.Foundations.RetryAfterHeader,
266
267
  Parameters extends {} = {}
267
268
  > is ArmCustomPatchAsync<
268
269
  Resource,
@@ -288,7 +289,8 @@ op ArmResourcePatchAsync<
288
289
  Azure.Core.StatusMonitorPollingOptions<ArmOperationStatus>,
289
290
  Resource,
290
291
  string
291
- >,
292
+ > &
293
+ Azure.Core.Foundations.RetryAfterHeader,
292
294
  Parameters extends {} = {}
293
295
  > is ArmCustomPatchAsync<
294
296
  Resource,
@@ -327,7 +329,8 @@ op ArmCustomPatchAsync<
327
329
  Azure.Core.StatusMonitorPollingOptions<ArmOperationStatus>,
328
330
  Resource,
329
331
  string
330
- >,
332
+ > &
333
+ Azure.Core.Foundations.RetryAfterHeader,
331
334
  Parameters extends {} = {},
332
335
  Response extends {} = ArmResponse<Resource> | ArmAcceptedLroResponse<
333
336
  "Resource update request accepted.",
@@ -439,7 +442,8 @@ op ArmResourceDeleteAsyncBase<
439
442
  op ArmResourceDeleteAsync<
440
443
  Resource extends ArmResource,
441
444
  BaseParameters = DefaultBaseParameters<Resource>,
442
- LroHeaders extends TypeSpec.Reflection.Model = ArmLroLocationHeader,
445
+ LroHeaders extends TypeSpec.Reflection.Model = ArmLroLocationHeader &
446
+ Azure.Core.Foundations.RetryAfterHeader,
443
447
  Parameters extends {} = {},
444
448
  Response extends {} = ArmDeletedResponse | ArmDeleteAcceptedLroResponse<LroHeaders> | ArmDeletedNoContentResponse,
445
449
  Error extends {} = ErrorResponse
@@ -457,7 +461,8 @@ op ArmResourceDeleteAsync<
457
461
  op ArmResourceDeleteWithoutOkAsync<
458
462
  Resource extends ArmResource,
459
463
  BaseParameters = DefaultBaseParameters<Resource>,
460
- LroHeaders extends TypeSpec.Reflection.Model = ArmLroLocationHeader,
464
+ LroHeaders extends TypeSpec.Reflection.Model = ArmLroLocationHeader &
465
+ Azure.Core.Foundations.RetryAfterHeader,
461
466
  Parameters extends {} = {},
462
467
  Response extends {} = ArmDeleteAcceptedLroResponse<LroHeaders> | ArmDeletedNoContentResponse,
463
468
  Error extends {} = ErrorResponse
@@ -538,7 +543,8 @@ op ArmResourceActionAsync<
538
543
  Azure.Core.StatusMonitorPollingOptions<ArmOperationStatus>,
539
544
  Response,
540
545
  string
541
- >,
546
+ > &
547
+ Azure.Core.Foundations.RetryAfterHeader,
542
548
  Parameters extends {} = {},
543
549
  Error extends {} = ErrorResponse
544
550
  > is ArmResourceActionAsyncBase<
@@ -592,7 +598,8 @@ op ArmResourceActionNoContentAsync<
592
598
  Resource extends ArmResource,
593
599
  Request extends TypeSpec.Reflection.Model | void,
594
600
  BaseParameters extends TypeSpec.Reflection.Model = DefaultBaseParameters<Resource>,
595
- LroHeaders extends TypeSpec.Reflection.Model = ArmLroLocationHeader,
601
+ LroHeaders extends TypeSpec.Reflection.Model = ArmLroLocationHeader &
602
+ Azure.Core.Foundations.RetryAfterHeader,
596
603
  Parameters extends {} = {},
597
604
  Error extends {} = ErrorResponse
598
605
  > is ArmResourceActionAsyncBase<
@@ -624,7 +631,8 @@ op ArmResourceActionNoResponseContentAsync<
624
631
  Azure.Core.StatusMonitorPollingOptions<ArmOperationStatus>,
625
632
  void,
626
633
  string
627
- >,
634
+ > &
635
+ Azure.Core.Foundations.RetryAfterHeader,
628
636
  Parameters extends {} = {},
629
637
  Error extends {} = ErrorResponse
630
638
  > is ArmResourceActionAsyncBase<
@@ -28,7 +28,7 @@ namespace Azure.ResourceManager;
28
28
  )
29
29
  model PrivateEndpoint {
30
30
  /** The resource identifier for private endpoint */
31
- id?: ResourceIdentifier<[
31
+ id?: Azure.Core.armResourceIdentifier<[
32
32
  {
33
33
  type: "Microsoft.Network/privateEndpoints";
34
34
  }
package/lib/responses.tsp CHANGED
@@ -19,11 +19,15 @@ model ArmResponse<ResponseBody> {
19
19
  /**
20
20
  * The Azure Resource Manager 201 response for a resource
21
21
  * @template ResponseBody The contents of the response body
22
+ * @template ExtraHeaders Additional headers in the response. Default includes Retry-After header
22
23
  */
23
24
  @doc("Azure create operation completed successfully.")
24
- model ArmCreatedResponse<ResponseBody> {
25
+ model ArmCreatedResponse<
26
+ ResponseBody,
27
+ ExtraHeaders extends TypeSpec.Reflection.Model = Azure.Core.Foundations.RetryAfterHeader
28
+ > {
25
29
  ...CreatedResponse;
26
- ...Azure.Core.Foundations.RetryAfterHeader;
30
+ ...ExtraHeaders;
27
31
  ...Body<ResponseBody>;
28
32
  }
29
33
 
@@ -39,7 +43,8 @@ model ArmDeletedResponse {
39
43
  * @dev The response for asynchronous Azure Resource Manager delete ACCEPTED
40
44
  * @template LroHeaders Optional. Allows overriding the Lro headers returned in the response.
41
45
  */
42
- model ArmDeleteAcceptedLroResponse<LroHeaders extends TypeSpec.Reflection.Model = ArmLroLocationHeader>
46
+ model ArmDeleteAcceptedLroResponse<LroHeaders extends TypeSpec.Reflection.Model = ArmLroLocationHeader &
47
+ Azure.Core.Foundations.RetryAfterHeader>
43
48
  is ArmAcceptedLroResponse<"Resource deletion accepted.", LroHeaders>;
44
49
 
45
50
  /**
@@ -50,11 +55,15 @@ model ArmDeleteAcceptedResponse is ArmAcceptedResponse<"Resource deletion accept
50
55
  /**
51
56
  * @dev The standard ACCEPTED response
52
57
  * @template Message The description of the response status (defaults to `Resource operation accepted`)
58
+ * @template ExtraHeaders Additional headers in the response. Default includes Retry-After header
53
59
  */
54
60
  @doc(Message)
55
- model ArmAcceptedResponse<Message extends valueof string = "Resource operation accepted."> {
61
+ model ArmAcceptedResponse<
62
+ Message extends valueof string = "Resource operation accepted.",
63
+ ExtraHeaders extends TypeSpec.Reflection.Model = Azure.Core.Foundations.RetryAfterHeader
64
+ > {
56
65
  ...AcceptedResponse;
57
- ...Azure.Core.Foundations.RetryAfterHeader;
66
+ ...ExtraHeaders;
58
67
  }
59
68
 
60
69
  /**
@@ -65,10 +74,10 @@ model ArmAcceptedResponse<Message extends valueof string = "Resource operation a
65
74
  @doc(Description)
66
75
  model ArmAcceptedLroResponse<
67
76
  Description extends valueof string = "Resource operation accepted.",
68
- LroHeaders extends TypeSpec.Reflection.Model = ArmLroLocationHeader
77
+ LroHeaders extends TypeSpec.Reflection.Model = ArmLroLocationHeader &
78
+ Azure.Core.Foundations.RetryAfterHeader
69
79
  > {
70
80
  ...AcceptedResponse;
71
- ...Azure.Core.Foundations.RetryAfterHeader;
72
81
  ...LroHeaders;
73
82
  }
74
83
 
@@ -203,10 +212,9 @@ model ArmResourceUpdatedResponse<Resource extends Azure.ResourceManager.Foundati
203
212
  @doc("Resource '{name}' create operation succeeded", Resource)
204
213
  model ArmResourceCreatedResponse<
205
214
  Resource extends Azure.ResourceManager.Foundations.ArmResource,
206
- LroHeaders extends TypeSpec.Reflection.Model = {}
215
+ LroHeaders extends TypeSpec.Reflection.Model = Azure.Core.Foundations.RetryAfterHeader
207
216
  > {
208
217
  ...CreatedResponse;
209
- ...Azure.Core.Foundations.RetryAfterHeader;
210
218
  ...LroHeaders;
211
219
 
212
220
  @Azure.Core.pollingLocation(Azure.Core.StatusMonitorPollingOptions<Resource>)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure-tools/typespec-azure-resource-manager",
3
- "version": "0.41.0-dev.0",
3
+ "version": "0.41.0-dev.10",
4
4
  "author": "Microsoft Corporation",
5
5
  "description": "TypeSpec Azure Resource Manager library",
6
6
  "homepage": "https://azure.github.io/typespec-azure",
@@ -59,13 +59,13 @@
59
59
  "@typespec/openapi": "~0.54.0 || >=0.55.0-dev <0.55.0",
60
60
  "@typespec/rest": "~0.54.0 || >=0.55.0-dev <0.55.0",
61
61
  "@typespec/versioning": "~0.54.0 || >=0.55.0-dev <0.55.0",
62
- "@vitest/coverage-v8": "^1.2.2",
63
- "@vitest/ui": "^1.2.2",
62
+ "@vitest/coverage-v8": "^1.4.0",
63
+ "@vitest/ui": "^1.4.0",
64
64
  "c8": "^9.1.0",
65
- "eslint": "^8.56.0",
65
+ "eslint": "^8.57.0",
66
66
  "rimraf": "~5.0.5",
67
- "typescript": "~5.3.3",
68
- "vitest": "^1.2.2",
67
+ "typescript": "~5.4.2",
68
+ "vitest": "^1.4.0",
69
69
  "@typespec/tspd": "~0.46.0"
70
70
  },
71
71
  "dependencies": {},