Skip to content

Commit 14c6c9c

Browse files
authored
Identify @readsResource as resource get operation (#54203)
* Identify `@readsResource` as resource get operation * regen
1 parent f52db35 commit 14c6c9c

18 files changed

+4650
-2039
lines changed

eng/packages/http-client-csharp-mgmt/emitter/src/resource-detection.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
extensionResourceOperationName,
3939
nonResourceMethodMetadata,
4040
parentResourceName,
41+
readsResourceName,
4142
resourceGroupResource,
4243
resourceMetadata,
4344
singleton,
@@ -195,6 +196,7 @@ function parseResourceOperation(
195196
const decorators = serviceMethod?.__raw?.decorators;
196197
for (const decorator of decorators ?? []) {
197198
switch (decorator.definition?.name) {
199+
case readsResourceName:
198200
case armResourceReadName:
199201
return [
200202
ResourceOperationKind.Get,

eng/packages/http-client-csharp-mgmt/emitter/src/sdk-context-options.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ export const armResourceRead = "Azure.ResourceManager.@armResourceRead";
2727
export const armResourceReadName = "@armResourceRead";
2828
const armResourceReadRegex = "Azure\\.ResourceManager\\.@armResourceRead";
2929

30+
export const readsResourceName = "@readsResource";
31+
3032
// https://github.com/Azure/typespec-azure/blob/main/packages/typespec-azure-resource-manager/README.md#armresourcecreateorupdate
3133
export const armResourceCreateOrUpdate =
3234
"Azure.ResourceManager.@armResourceCreateOrUpdate";

eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/quota.tsp

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,97 @@ model AllocatedToSubscription {
9999
* The amount of quota allocated to this subscriptionId from the GroupQuotasEntity.
100100
*/
101101
quotaAllocated?: int64;
102+
}
103+
104+
model GroupQuotaLimitList
105+
is Azure.ResourceManager.ProxyResource<GroupQuotaLimitListProperties> {
106+
...ResourceNameParameter<
107+
Resource = GroupQuotaLimitList,
108+
KeyName = "location",
109+
SegmentName = "groupQuotaLimits",
110+
NamePattern = ""
111+
>;
112+
}
113+
114+
#suppress "@azure-tools/typespec-azure-core/documentation-required" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
115+
model GroupQuotaLimitListProperties {
116+
/**
117+
* The URL to use for getting the next set of results.
118+
*/
119+
@visibility(Lifecycle.Read)
120+
nextLink?: string;
121+
}
122+
123+
alias GroupQuotaLimitListsOps = Azure.ResourceManager.Legacy.ExtensionOperations<
124+
{
125+
...ApiVersionParameter;
126+
127+
/** the provider namespace */
128+
@path
129+
@segment("providers")
130+
@key
131+
providerNamespace: "Microsoft.Management";
132+
133+
/**
134+
* The management group ID.
135+
*/
136+
@path
137+
@segment("managementGroups")
138+
@key
139+
@minLength(3)
140+
@maxLength(63)
141+
managementGroupId: string;
142+
},
143+
{
144+
},
145+
{
146+
/**
147+
* The GroupQuota name. The name should be unique for the provided context tenantId/MgId.
148+
*/
149+
@path
150+
@segment("groupQuotas")
151+
@minLength(3)
152+
@maxLength(63)
153+
@key
154+
@pattern("^[a-z][a-z0-9]*$")
155+
groupQuotaName: string;
156+
157+
/**
158+
* The resource provider name, such as - Microsoft.Compute. Currently only Microsoft.Compute resource provider supports this API.
159+
*/
160+
@path
161+
@key
162+
@segment("resourceProviders")
163+
@pattern("^((?!-)[a-zA-Z0-9-]{1,63}(?<!-)\\.)+[a-zA-Z]{2,63}$")
164+
resourceProviderName: string;
165+
166+
/**
167+
* The name of the Azure region.
168+
*/
169+
@path
170+
@minLength(1)
171+
@segment("groupQuotaLimits")
172+
location: Azure.Core.azureLocation;
173+
}
174+
>;
175+
176+
@armResourceOperations
177+
interface GroupQuotaLimitLists {
178+
/**
179+
* Gets the GroupQuotaLimits for the specified resource provider and location for resource names passed in $filter=resourceName eq {SKU}.
180+
*/
181+
list is GroupQuotaLimitListsOps.Read<GroupQuotaLimitList>;
182+
183+
/**
184+
* Create the GroupQuota requests for a specific ResourceProvider/Location/Resource. The resourceName properties are specified in the request body. Only 1 resource quota can be requested. Please note that patch request creates a new groupQuota request.
185+
* Use the polling API - OperationsStatus URI specified in Azure-AsyncOperation header field, with retry-after duration in seconds to check the intermediate status. This API provides the finals status with the request details and status.
186+
*/
187+
@patch(#{ implicitOptionality: false })
188+
update is GroupQuotaLimitListsOps.CustomPatchAsync<
189+
GroupQuotaLimitList,
190+
PatchModel = GroupQuotaLimitList,
191+
OptionalRequestBody = true,
192+
Response = ArmResponse<GroupQuotaLimitList> | ArmAcceptedLroResponse<LroHeaders = ArmCombinedLroHeaders<FinalResult = GroupQuotaLimitList> &
193+
Azure.Core.Foundations.RetryAfterHeader>
194+
>;
102195
}

eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Extensions/AzureGeneratorMgmtTypeSpecTestsExtensions.cs

Lines changed: 81 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Extensions/MockableAzureGeneratorMgmtTypeSpecTestsArmClient.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)