Skip to content

Commit 9cfe920

Browse files
mcgallanPan Shaokazrael2119v-jiaodimelina5656
authored
Convert StorageActions Swagger to TypeSpec (#34150)
* generate * update * Update models.tsp * Update tspconfig.yaml * Update tspconfig.yaml * update * update * update * Delete oldstorageactions.json * update * update * Update tspconfig.yaml * update * update * update * update * update * update * update * update * name fix * update * update * update * update * update * update * Update sdk-suppressions.yaml * Revert "Update sdk-suppressions.yaml" This reverts commit 8056611. * update * update * update * update * update * update * update * update * Update ListStorageTasksRunReportSummary.json * Update ListStorageTasksRunReportSummary.json * update * update * Update client.tsp * update * update * update * update --------- Co-authored-by: Pan Shao <[email protected]> Co-authored-by: kazrael2119 <[email protected]> Co-authored-by: Jiao Di (MSFT) <[email protected]> Co-authored-by: melina5656 <[email protected]> Co-authored-by: Yuchao Yan <[email protected]> Co-authored-by: Arthur Ma <[email protected]>
1 parent 793fd06 commit 9cfe920

28 files changed

+3164
-956
lines changed
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
import "@azure-tools/typespec-azure-core";
2+
import "@azure-tools/typespec-azure-resource-manager";
3+
import "@typespec/openapi";
4+
import "@typespec/rest";
5+
import "./models.tsp";
6+
7+
using TypeSpec.Rest;
8+
using Azure.ResourceManager;
9+
using TypeSpec.Http;
10+
using TypeSpec.OpenAPI;
11+
12+
namespace Microsoft.StorageActions;
13+
/**
14+
* Represents Storage Task.
15+
*/
16+
#suppress "@azure-tools/typespec-azure-core/no-private-usage" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
17+
#suppress "@azure-tools/typespec-azure-core/no-private-usage" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
18+
#suppress "@azure-tools/typespec-azure-core/composition-over-inheritance" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
19+
@Azure.ResourceManager.Private.armResourceInternal(StorageTaskProperties)
20+
@Http.Private.includeInapplicableMetadataInPayload(false)
21+
model StorageTask extends Foundations.TrackedResource {
22+
...ResourceNameParameter<
23+
Resource = StorageTask,
24+
KeyName = "storageTaskName",
25+
SegmentName = "storageTasks",
26+
NamePattern = "^[a-z0-9]{3,18}$"
27+
>;
28+
29+
/**
30+
* The managed service identity of the resource.
31+
*/
32+
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
33+
identity: Azure.ResourceManager.Foundations.ManagedServiceIdentity;
34+
35+
#suppress "@azure-tools/typespec-azure-core/no-private-usage" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
36+
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
37+
@doc("The resource-specific properties for this resource.")
38+
@Azure.ResourceManager.Private.armResourcePropertiesOptionality(false)
39+
properties?: StorageTaskProperties;
40+
}
41+
42+
@armResourceOperations
43+
interface StorageTasks {
44+
/**
45+
* Get the storage task properties
46+
*/
47+
get is ArmResourceRead<StorageTask>;
48+
49+
/**
50+
* Asynchronously creates a new storage task resource with the specified parameters. If a storage task is already created and a subsequent create request is issued with different properties, the storage task properties will be updated. If a storage task is already created and a subsequent create or update request is issued with the exact same set of properties, the request will succeed.
51+
*/
52+
#suppress "@azure-tools/typespec-azure-resource-manager/arm-put-operation-response-codes" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
53+
#suppress "@azure-tools/typespec-azure-core/invalid-final-state" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
54+
@Azure.Core.useFinalStateVia("azure-async-operation")
55+
create is ArmResourceCreateOrReplaceAsync<
56+
StorageTask,
57+
Response = ArmResourceUpdatedResponse<StorageTask> | ArmResourceCreatedResponse<
58+
StorageTask,
59+
ArmLroLocationHeader<FinalResult = StorageTask> &
60+
Azure.Core.Foundations.RetryAfterHeader
61+
> | ArmAcceptedLroResponse
62+
>;
63+
64+
/**
65+
* Update storage task properties
66+
*/
67+
@patch(#{ implicitOptionality: false })
68+
update is ArmCustomPatchAsync<
69+
StorageTask,
70+
PatchModel = StorageTaskUpdateParameters,
71+
Response = ArmResourceUpdatedResponse<StorageTask> | ArmAcceptedLroResponse<LroHeaders = ArmAsyncOperationHeader<FinalResult = StorageTask> &
72+
ArmLroLocationHeader<FinalResult = StorageTask> &
73+
Azure.Core.Foundations.RetryAfterHeader>
74+
>;
75+
76+
/**
77+
* Delete the storage task resource.
78+
*/
79+
delete is ArmResourceDeleteWithoutOkAsync<
80+
StorageTask,
81+
Response = ArmAcceptedLroResponse<LroHeaders = ArmAsyncOperationHeader<FinalResult = StorageTask> &
82+
ArmLroLocationHeader<FinalResult = StorageTask> &
83+
Azure.Core.Foundations.RetryAfterHeader> | ArmDeletedNoContentResponse
84+
>;
85+
86+
/**
87+
* Lists all the storage tasks available under the given resource group.
88+
*/
89+
listByResourceGroup is ArmResourceListByParent<
90+
StorageTask,
91+
Response = StorageTasksListResult
92+
>;
93+
94+
/**
95+
* Lists all the storage tasks available under the subscription.
96+
*/
97+
listBySubscription is ArmListBySubscription<
98+
StorageTask,
99+
Response = StorageTasksListResult
100+
>;
101+
102+
/**
103+
* Fetch the storage tasks run report summary for each assignment.
104+
*/
105+
#suppress "@azure-tools/typespec-azure-core/no-openapi" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
106+
@get
107+
@action("reports")
108+
@operationId("StorageTasksReport_List")
109+
list is ArmResourceActionSync<
110+
StorageTask,
111+
void,
112+
ArmResponse<StorageTaskReportSummary>,
113+
Parameters = {
114+
/**
115+
* Optional, specifies the maximum number of Storage Task Assignment Resource IDs to be included in the list response.
116+
*/
117+
@query("$maxpagesize")
118+
$maxpagesize?: int32;
119+
120+
/**
121+
* Optional. When specified, it can be used to query using reporting properties.
122+
*/
123+
@query("$filter")
124+
$filter?: string;
125+
}
126+
>;
127+
128+
/**
129+
* Lists Resource IDs of the Storage Task Assignments associated with this Storage Task.
130+
*/
131+
#suppress "@azure-tools/typespec-azure-core/no-openapi" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
132+
@get
133+
@action("storageTaskAssignments")
134+
@operationId("StorageTaskAssignment_List")
135+
storageTaskAssignmentList is ArmResourceActionSync<
136+
StorageTask,
137+
void,
138+
ArmResponse<StorageTaskAssignmentsListResult>,
139+
Parameters = {
140+
/**
141+
* Optional, specifies the maximum number of Storage Task Assignment Resource IDs to be included in the list response.
142+
*/
143+
@query("$maxpagesize")
144+
$maxpagesize?: int32;
145+
}
146+
>;
147+
}
148+
149+
@@maxLength(StorageTask.name, 18);
150+
@@minLength(StorageTask.name, 3);
151+
@@doc(StorageTask.name,
152+
"The name of the storage task within the specified resource group. Storage task names must be between 3 and 18 characters in length and use numbers and lower-case letters only."
153+
);
154+
@@doc(StorageTask.properties, "Properties of the storage task.");
155+
@@doc(StorageTasks.create::parameters.resource,
156+
"The parameters to create a Storage Task."
157+
);
158+
@@doc(StorageTasks.update::parameters.properties,
159+
"The parameters to provide to update the storage task resource."
160+
);
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import "@azure-tools/typespec-client-generator-core";
2+
3+
using Azure.ClientGenerator.Core;
4+
using Microsoft.StorageActions;
5+
6+
#suppress "deprecated" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
7+
@@flattenProperty(StorageTaskPreviewAction.properties, "!csharp");
8+
9+
#suppress "deprecated" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
10+
@@flattenProperty(StorageTaskUpdateParameters.properties, "!csharp");
11+
12+
@@clientName(StorageTasks.create::parameters.resource, "parameters");
13+
@@clientName(StorageTasks.update::parameters.properties, "parameters");
14+
@@clientName(StorageTasksOperationGroup.previewActions::parameters.body,
15+
"parameters"
16+
);
17+
@@clientName(StorageTasksOperationGroup.previewActions, "PreviewActions");
18+
#suppress "deprecated" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
19+
@@flattenProperty(StorageTask.properties, "!csharp");
20+
21+
// @@clientLocation decorators for operations with custom @operationId
22+
// These ensure consistent operationId generation in the output
23+
@@clientLocation(StorageTasksOperationGroup.previewActions, StorageTasks);
24+
@@clientLocation(StorageTasks.list, "StorageTasksReport");
25+
@@clientLocation(StorageTasks.storageTaskAssignmentList,
26+
"StorageTaskAssignment"
27+
);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import "@azure-tools/typespec-client-generator-core";
2+
import "./main.tsp";
3+
4+
using Azure.ClientGenerator.Core;
5+
using Microsoft.StorageActions;
6+
7+
@@clientName(Microsoft.StorageActions, "StorageActionsMgmtClient", "python");
8+
9+
@@clientName(StorageTaskOperation, "StorageTaskOperationInfo", "csharp");
10+
@@clientName(OnSuccess, "OnSuccessAction", "csharp");
11+
@@clientName(OnFailure, "OnFailureAction", "csharp");
12+
@@clientName(ElseCondition, "StorageTaskElseCondition", "csharp");
13+
@@clientName(IfCondition, "StorageTaskIfCondition", "csharp");
14+
@@clientName(ProvisioningState, "StorageTaskProvisioningState", "csharp");
15+
@@clientName(RunResult, "StorageTaskRunResult", "csharp");
16+
@@clientName(RunStatusEnum, "StorageTaskRunStatus", "csharp");
17+
@@clientName(StorageTaskProperties.enabled, "IsEnabled", "csharp");
18+
@@clientName(StorageTasks.storageTaskAssignmentList,
19+
"GetStorageTaskAssignments",
20+
"csharp"
21+
);
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"operationId": "Operations_List",
3+
"parameters": {
4+
"api-version": "2023-01-01"
5+
},
6+
"title": "OperationsList",
7+
"responses": {
8+
"200": {
9+
"body": {
10+
"value": [
11+
{
12+
"name": "Microsoft.StorageActions/storageTasks/read",
13+
"display": {
14+
"description": "Gets or Lists existing StorageTask resource(s).",
15+
"operation": "Get or List StorageTask resource(s).",
16+
"provider": "Microsoft StorageActions",
17+
"resource": "StorageTasks"
18+
},
19+
"isDataAction": false
20+
},
21+
{
22+
"name": "Microsoft.StorageActions/storageTasks/write",
23+
"display": {
24+
"description": "Creates or Updates StorageTask resource.",
25+
"operation": "Create or Update StorageTask resource.",
26+
"provider": "Microsoft StorageActions",
27+
"resource": "StorageTasks"
28+
},
29+
"isDataAction": false
30+
},
31+
{
32+
"name": "Microsoft.StorageActions/storageTasks/delete",
33+
"display": {
34+
"description": "Deletes StorageTask resource.",
35+
"operation": "Delete StorageTask resource.",
36+
"provider": "Microsoft StorageActions",
37+
"resource": "StorageTasks"
38+
},
39+
"isDataAction": false
40+
}
41+
]
42+
}
43+
}
44+
}
45+
}

0 commit comments

Comments
 (0)