@azure-tools/typespec-azure-resource-manager 0.58.0-dev.2 → 0.58.0-dev.4

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 (63) hide show
  1. package/README.md +45 -12
  2. package/dist/generated-defs/Azure.ResourceManager.Extension.Private.d.ts +25 -0
  3. package/dist/generated-defs/Azure.ResourceManager.Extension.Private.d.ts.map +1 -0
  4. package/dist/generated-defs/Azure.ResourceManager.Extension.Private.js +2 -0
  5. package/dist/generated-defs/Azure.ResourceManager.Extension.Private.js.map +1 -0
  6. package/dist/generated-defs/Azure.ResourceManager.Legacy.d.ts +14 -1
  7. package/dist/generated-defs/Azure.ResourceManager.Legacy.d.ts.map +1 -1
  8. package/dist/generated-defs/Azure.ResourceManager.Private.d.ts +8 -0
  9. package/dist/generated-defs/Azure.ResourceManager.Private.d.ts.map +1 -1
  10. package/dist/generated-defs/Azure.ResourceManager.d.ts +20 -6
  11. package/dist/generated-defs/Azure.ResourceManager.d.ts.map +1 -1
  12. package/dist/src/lib.d.ts +17 -2
  13. package/dist/src/lib.d.ts.map +1 -1
  14. package/dist/src/lib.js +6 -0
  15. package/dist/src/lib.js.map +1 -1
  16. package/dist/src/linter.d.ts.map +1 -1
  17. package/dist/src/linter.js +2 -0
  18. package/dist/src/linter.js.map +1 -1
  19. package/dist/src/namespace.d.ts.map +1 -1
  20. package/dist/src/namespace.js +14 -7
  21. package/dist/src/namespace.js.map +1 -1
  22. package/dist/src/operations.d.ts +3 -0
  23. package/dist/src/operations.d.ts.map +1 -1
  24. package/dist/src/operations.js +37 -2
  25. package/dist/src/operations.js.map +1 -1
  26. package/dist/src/private.decorators.d.ts.map +1 -1
  27. package/dist/src/private.decorators.js +61 -7
  28. package/dist/src/private.decorators.js.map +1 -1
  29. package/dist/src/resource.d.ts +16 -1
  30. package/dist/src/resource.d.ts.map +1 -1
  31. package/dist/src/resource.js +68 -14
  32. package/dist/src/resource.js.map +1 -1
  33. package/dist/src/rules/arm-custom-resource-no-key.d.ts +4 -0
  34. package/dist/src/rules/arm-custom-resource-no-key.d.ts.map +1 -0
  35. package/dist/src/rules/arm-custom-resource-no-key.js +28 -0
  36. package/dist/src/rules/arm-custom-resource-no-key.js.map +1 -0
  37. package/dist/src/rules/arm-resource-interfaces.d.ts.map +1 -1
  38. package/dist/src/rules/arm-resource-interfaces.js +2 -1
  39. package/dist/src/rules/arm-resource-interfaces.js.map +1 -1
  40. package/dist/src/rules/list-operation.js +1 -1
  41. package/dist/src/rules/list-operation.js.map +1 -1
  42. package/dist/src/state.d.ts +2 -0
  43. package/dist/src/state.d.ts.map +1 -1
  44. package/dist/src/state.js +2 -0
  45. package/dist/src/state.js.map +1 -1
  46. package/dist/src/tsp-index.d.ts.map +1 -1
  47. package/dist/src/tsp-index.js +2 -1
  48. package/dist/src/tsp-index.js.map +1 -1
  49. package/lib/Legacy/arm.legacy.tsp +4 -0
  50. package/lib/Legacy/decorator.tsp +18 -0
  51. package/lib/Legacy/extension.tsp +343 -0
  52. package/lib/Legacy/interfaces.tsp +38 -0
  53. package/lib/Legacy/operations.tsp +130 -32
  54. package/lib/arm.tsp +1 -0
  55. package/lib/common-types/internal.tsp +9 -0
  56. package/lib/common-types/types-ref.tsp +12 -3
  57. package/lib/decorators.tsp +38 -6
  58. package/lib/extension/extension.tsp +6 -0
  59. package/lib/extension/operations.tsp +507 -0
  60. package/lib/extension/parameters.tsp +223 -0
  61. package/lib/extension/private.decorators.tsp +24 -0
  62. package/lib/private.decorators.tsp +5 -0
  63. package/package.json +1 -1
@@ -0,0 +1,223 @@
1
+ namespace Azure.ResourceManager.Extension;
2
+
3
+ using Http;
4
+ using Rest;
5
+ using Azure.ResourceManager.Private;
6
+ using Azure.ResourceManager.Extension.Private;
7
+ using Azure.ResourceManager.CommonTypes;
8
+
9
+ /**
10
+ * The default scope parameter for an extension resource.
11
+ * @template Type The type of the scope parameter (default is string). This can be used to specify `Azure.Core.armResourceIdentifier` type or other constrained type
12
+ *
13
+ * @example
14
+ * ```typespec
15
+ * model Employee {
16
+ * ...ResourceUriParameter;
17
+ * }
18
+ * ```
19
+ */
20
+ @builtInResource
21
+ model ScopeParameter<Type extends string = string> {
22
+ @path(#{ allowReserved: true })
23
+ @key
24
+ @doc("The fully qualified Azure Resource manager identifier of the resource.")
25
+ scope: Type;
26
+ }
27
+
28
+ /**
29
+ * Base parameters for an extension target.
30
+ * @template Resource The resource model for an extension target (usually Extension.Tenant, Extension.Subscription, Extension.ResourceGroup, Extension.Scope, Extension.ManagementGroup or an external resource).
31
+ *
32
+ */
33
+ @resourceBaseParametersOf(Resource)
34
+ model TargetBaseParameters<Resource extends {}> {
35
+ ...ApiVersionParameter;
36
+
37
+ // unless built-in, tenant or extension
38
+ ...CommonTypes.SubscriptionIdParameter;
39
+
40
+ // unless built-in tenant, subscription, location, or extension
41
+ ...CommonTypes.ResourceGroupNameParameter;
42
+
43
+ // unless built-in
44
+ ...TargetProviderNamespace<Resource>;
45
+ }
46
+
47
+ /** The path parameters for a target resource for an extension
48
+ * @template Resource The resource model for an extension target (usually Extension.Tenant, Extension.Subscription, Extension.ResourceGroup, Extension.Scope, Extension.ManagementGroup or an external resource).
49
+ */
50
+ model TargetParameters<Resource extends {}> {
51
+ ...TargetBaseParameters<Resource>;
52
+ ...KeysOf<Resource>;
53
+ }
54
+
55
+ /** The provider namespace for an extension resource
56
+ * @template Resource The extension resource model
57
+ */
58
+ model ExtensionProviderNamespace<Resource extends {}> {
59
+ @path
60
+ @segment("providers")
61
+ @assignUniqueProviderNameValue(Resource)
62
+ @doc("The provider namespace for the resource.")
63
+ extensionProvider: "Microsoft.ExtensionProviderNamespace";
64
+ }
65
+
66
+ /** The provider namespace (if any) for a target resource for an extension
67
+ * @template Resource The resource model for an extension target (usually Extension.Tenant, Extension.Subscription, Extension.ResourceGroup, Extension.Scope, Extension.ManagementGroup or an external resource)
68
+ */
69
+ model TargetProviderNamespace<Resource extends {}> {
70
+ @resourceParameterBaseFor(
71
+ [
72
+ ResourceHome.Extension,
73
+ ResourceHome.Location,
74
+ ResourceHome.ResourceGroup,
75
+ ResourceHome.Subscription,
76
+ ResourceHome.Tenant
77
+ ]
78
+ )
79
+ @path
80
+ @segment("providers")
81
+ @doc("The provider namespace for the resource.")
82
+ @assignUniqueProviderNameValue(Resource)
83
+ provider: "Microsoft.TargetProviderNamespace";
84
+ }
85
+
86
+ /** The path parameters for an extension resource at the given target
87
+ * @template TargetResource The target of the extension resource (Extension.Tenant, Extension.Subscription, Extension.ResourceGroup, Extension.Scope, Extension.ManagementGroup or another resource).
88
+ * @template Resource The extension resource.
89
+ */
90
+ model ExtensionInstanceParameters<TargetResource extends {}, Resource extends {}> {
91
+ ...TargetParameters<TargetResource>;
92
+ ...ExtensionProviderNamespace<Resource>;
93
+ ...KeysOf<Resource>;
94
+ }
95
+
96
+ /** The path parameters for a collection of extension resources at the given target
97
+ * @template TargetResource The target of the extension resource (Extension.Tenant, Extension.Subscription, Extension.ResourceGroup, Extension.Scope, Extension.ManagementGroup or another resource).
98
+ * @template ExtensionResource The extension resource.
99
+ */
100
+ model ExtensionParentParameters<TargetResource extends {}, ExtensionResource extends {}> {
101
+ ...TargetParameters<TargetResource>;
102
+ ...ExtensionProviderNamespace<ExtensionResource>;
103
+ ...ParentKeysOf<ExtensionResource>;
104
+ }
105
+
106
+ /** A tenant target for the extension resource */
107
+ @builtInResource
108
+ model Tenant {}
109
+
110
+ /** A management group
111
+ * @template ParameterName The name of the 'name' parameter of the management group (usually managementGroupName or managementGroupId).
112
+ */
113
+ @tenantResource
114
+ @armVirtualResource("Microsoft.Management")
115
+ model ManagementGroup<ParameterName extends valueof string = "managementGroupName"> {
116
+ @path
117
+ @minLength(1)
118
+ @segment("managementGroups")
119
+ @key(ParameterName)
120
+ @doc("The management group ID.")
121
+ name: string;
122
+ }
123
+
124
+ /** An external resource target, used when an extension targets a resource from another provider namespace
125
+ * @template TargetNamespace The provider namespace for the external resource.
126
+ * @template ResourceType The type of the external resource.
127
+ * @template ResourceParameterName The name of the 'name' parameter of the external resource.
128
+ * @template NamePattern The pattern restriction for the name of the external resource (default is none).
129
+ * @template NameType The type of the name parameter of the external resource (default is string).
130
+ * @template Description The description of the name parameter of the external resource (default is "The name of the resource").
131
+ *
132
+ * @example
133
+ * ```typespec
134
+ * alias VirtualMachine = ExternalResource<"Microsoft.Compute", "virtualMachines", "vmName">;
135
+ *
136
+ * ```
137
+ *
138
+ * @example
139
+ * ```typespec
140
+ * alias Scaleset = Extension.ExternalResource<
141
+ * "Microsoft.Compute",
142
+ * "virtualMachineScaleSets",
143
+ * "scaleSetName"
144
+ * >;
145
+
146
+ * ```
147
+ */
148
+ @doc("")
149
+ @armVirtualResource(TargetNamespace)
150
+ @Http.Private.includeInapplicableMetadataInPayload(false)
151
+ model ExternalResource<
152
+ TargetNamespace extends valueof string,
153
+ ResourceType extends valueof string,
154
+ ResourceParameterName extends valueof string,
155
+ NamePattern extends valueof string = "",
156
+ NameType extends string = string,
157
+ Description extends valueof string = "The name of the resource"
158
+ > {
159
+ @doc(Description)
160
+ @visibility(Lifecycle.Read)
161
+ @path
162
+ @key(ResourceParameterName)
163
+ @segment(ResourceType)
164
+ @pattern(NamePattern)
165
+ name: NameType;
166
+ }
167
+
168
+ /** An external child resource target, used when an extension targets a child resource from another provider namespace
169
+ * @template ParentModel The parent of this resource.
170
+ * @template ResourceType The type of this resource.
171
+ * @template ResourceParameterName The name of the 'name' parameter of this resource.
172
+ * @template NamePattern The pattern restriction for the name of this resource (default is none).
173
+ * @template NameType The type of the name parameter of this resource (default is string).
174
+ * @template Description The description of the name parameter of this resource (default is "The name of the resource").
175
+ *
176
+ * @example
177
+ * ```typespec
178
+ * alias VirtualMachine = ExternalResource<"Microsoft.Compute", "virtualMachines", "vmName">;
179
+ *
180
+ * ```
181
+ *
182
+ * @example
183
+ * ```typespec
184
+ * alias Scaleset = Extension.ExternalResource<
185
+ * "Microsoft.Compute",
186
+ * "virtualMachineScaleSets",
187
+ * "scaleSetName"
188
+ * >;
189
+ *
190
+ * alias VirtualMachineScaleSetVm = Extension.ExternalChildResource<
191
+ * Scaleset,
192
+ * "virtualMachineScaleSetVms",
193
+ * "scaleSetVmName"
194
+ * >;
195
+ *
196
+ * ```
197
+ */
198
+ @doc("")
199
+ @parentResource(ParentModel)
200
+ @Http.Private.includeInapplicableMetadataInPayload(false)
201
+ model ExternalChildResource<
202
+ ParentModel extends {},
203
+ ResourceType extends valueof string,
204
+ ResourceParameterName extends valueof string,
205
+ NamePattern extends valueof string = "",
206
+ NameType extends string = string,
207
+ Description extends valueof string = "The name of the resource"
208
+ > {
209
+ @doc(Description)
210
+ @visibility(Lifecycle.Read)
211
+ @path
212
+ @key(ResourceParameterName)
213
+ @segment(ResourceType)
214
+ @pattern(NamePattern)
215
+ name: NameType;
216
+ }
217
+ /** A subscription target for an extension resource */
218
+ @builtInSubscriptionResource
219
+ model Subscription {}
220
+
221
+ /** A resource group target for an extension resource */
222
+ @builtInResourceGroupResource
223
+ model ResourceGroup {}
@@ -0,0 +1,24 @@
1
+ using Reflection;
2
+
3
+ namespace Azure.ResourceManager.Extension.Private;
4
+
5
+ /**
6
+ * `@builtInResource` marks a model as built-in to Azure ResourceManager at the tenant level
7
+ *
8
+ * @param target - The model that is marked as built-in.
9
+ */
10
+ extern dec builtInResource(target: Model);
11
+
12
+ /**
13
+ * `@builtInSubscriptionResource` marks a model as built-in to Azure ResourceManager at the Subscription level
14
+ *
15
+ * @param target - The model that is marked as built-in.
16
+ */
17
+ extern dec builtInSubscriptionResource(target: Model);
18
+
19
+ /**
20
+ * `@builtInResourceGroupResource` marks a model as built-in to Azure ResourceManager at the ResourceGroup level
21
+ *
22
+ * @param target - The model that is marked as built-in.
23
+ */
24
+ extern dec builtInResourceGroupResource(target: Model);
@@ -14,6 +14,11 @@ extern dec armUpdateProviderNamespace(target: Reflection.Operation);
14
14
  */
15
15
  extern dec assignProviderNameValue(target: ModelProperty, resource: Model);
16
16
 
17
+ /**
18
+ * @param resource Resource model
19
+ */
20
+ extern dec assignUniqueProviderNameValue(target: ModelProperty, resource: Model);
21
+
17
22
  /**
18
23
  * This decorator is used to identify Azure Resource Manager resource types and extract their
19
24
  * metadata. It is *not* meant to be used directly by a spec author, it instead
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure-tools/typespec-azure-resource-manager",
3
- "version": "0.58.0-dev.2",
3
+ "version": "0.58.0-dev.4",
4
4
  "author": "Microsoft Corporation",
5
5
  "description": "TypeSpec Azure Resource Manager library",
6
6
  "homepage": "https://azure.github.io/typespec-azure",