Skip to content

Convert StorageActions Swagger to TypeSpec #34150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 59 commits into from
Jun 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
bc51946
generate
mcgallan Apr 18, 2025
4db73a6
update
mcgallan Apr 21, 2025
fec33d7
Update models.tsp
mcgallan Apr 21, 2025
63228e0
Merge remote-tracking branch 'upstream/main' into StorageAction-TypeS…
mcgallan Apr 22, 2025
29bb04f
Update tspconfig.yaml
mcgallan Apr 22, 2025
2d38a7b
Update tspconfig.yaml
mcgallan Apr 22, 2025
769d1d4
update
mcgallan Apr 23, 2025
703a016
Merge remote-tracking branch 'upstream/main' into StorageAction-TypeS…
mcgallan Apr 23, 2025
c50f7aa
update
mcgallan Apr 23, 2025
f414e7f
update
mcgallan Apr 23, 2025
91fc3bd
Delete oldstorageactions.json
mcgallan Apr 23, 2025
11cac72
update
mcgallan Apr 24, 2025
c9e02e8
update
mcgallan Apr 24, 2025
bd1e3e4
Update tspconfig.yaml
mcgallan Apr 25, 2025
ff1e796
update
mcgallan Apr 27, 2025
c4db1aa
update
mcgallan Apr 27, 2025
bc11ebb
update
mcgallan Apr 28, 2025
fb37e4a
update
mcgallan Apr 28, 2025
3abd8c4
update
mcgallan Apr 28, 2025
ccf27db
update
mcgallan May 7, 2025
08b8d30
Merge branch 'main' of https://github.com/Azure/azure-rest-api-specs …
May 7, 2025
972d2e4
update
mcgallan May 8, 2025
33f3a4e
update
May 8, 2025
d12552c
Merge branch 'StorageAction-TypeSpec-complie' of https://github.com/m…
May 8, 2025
707f9f4
Merge remote-tracking branch 'upstream/main' into StorageAction-TypeS…
mcgallan May 9, 2025
a9d233f
Merge branch 'main' into StorageAction-TypeSpec-complie
mcgallan May 9, 2025
8250475
name fix
mcgallan May 9, 2025
ad35927
update
mcgallan May 9, 2025
1f22b07
update
mcgallan May 9, 2025
7cb776b
update
mcgallan May 9, 2025
3b8d68d
update
mcgallan May 9, 2025
e64eab0
Merge branch 'main' of https://github.com/Azure/azure-rest-api-specs …
May 14, 2025
996ea93
update
May 14, 2025
9701861
update
May 14, 2025
8056611
Update sdk-suppressions.yaml
kazrael2119 May 21, 2025
28d1dad
Revert "Update sdk-suppressions.yaml"
kazrael2119 May 21, 2025
709bd2c
Merge branch 'main' into StorageAction-TypeSpec-complie
mcgallan May 22, 2025
bc30521
Merge branch 'main' into StorageAction-TypeSpec-complie
v-jiaodi May 23, 2025
bacd49b
update
melina5656 Jun 6, 2025
ac96eae
update
mcgallan Jun 6, 2025
1e1b39c
Merge branch 'StorageAction-TypeSpec-complie' of https://github.com/m…
mcgallan Jun 6, 2025
9469447
update
melina5656 Jun 9, 2025
47b7fcd
update
Jun 9, 2025
aaafb88
update
mcgallan Jun 10, 2025
c4a0def
update
mcgallan Jun 10, 2025
81fe25d
Merge remote-tracking branch 'upstream/main' into StorageAction-TypeS…
melina5656 Jun 10, 2025
048cd3b
update
mcgallan Jun 10, 2025
408c0c6
update
mcgallan Jun 12, 2025
f6f7156
Update ListStorageTasksRunReportSummary.json
melina5656 Jun 18, 2025
8198527
Update ListStorageTasksRunReportSummary.json
melina5656 Jun 18, 2025
e4a3100
Merge remote-tracking branch 'upstream/main' into StorageAction-TypeS…
mcgallan Jun 19, 2025
d52f4d9
update
mcgallan Jun 19, 2025
653c649
update
mcgallan Jun 19, 2025
606ad9f
Update client.tsp
msyyc Jun 20, 2025
69c1223
update
ArthurMa1978 Jun 20, 2025
84f242b
update
mcgallan Jun 25, 2025
d94c304
Merge remote-tracking branch 'upstream/main' into StorageAction-TypeS…
mcgallan Jun 25, 2025
b1fd677
update
mcgallan Jun 25, 2025
aff85d3
update
mcgallan Jun 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 160 additions & 0 deletions specification/storageactions/StorageAction.Management/StorageTask.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";
import "@typespec/openapi";
import "@typespec/rest";
import "./models.tsp";

using TypeSpec.Rest;
using Azure.ResourceManager;
using TypeSpec.Http;
using TypeSpec.OpenAPI;

namespace Microsoft.StorageActions;
/**
* Represents Storage Task.
*/
#suppress "@azure-tools/typespec-azure-core/no-private-usage" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
#suppress "@azure-tools/typespec-azure-core/no-private-usage" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
#suppress "@azure-tools/typespec-azure-core/composition-over-inheritance" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@Azure.ResourceManager.Private.armResourceInternal(StorageTaskProperties)
@Http.Private.includeInapplicableMetadataInPayload(false)
model StorageTask extends Foundations.TrackedResource {
...ResourceNameParameter<
Resource = StorageTask,
KeyName = "storageTaskName",
SegmentName = "storageTasks",
NamePattern = "^[a-z0-9]{3,18}$"
>;

/**
* The managed service identity of the resource.
*/
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
identity: Azure.ResourceManager.Foundations.ManagedServiceIdentity;

#suppress "@azure-tools/typespec-azure-core/no-private-usage" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@doc("The resource-specific properties for this resource.")
@Azure.ResourceManager.Private.armResourcePropertiesOptionality(false)
properties?: StorageTaskProperties;
}

@armResourceOperations
interface StorageTasks {
/**
* Get the storage task properties
*/
get is ArmResourceRead<StorageTask>;

/**
* 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.
*/
#suppress "@azure-tools/typespec-azure-resource-manager/arm-put-operation-response-codes" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
#suppress "@azure-tools/typespec-azure-core/invalid-final-state" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@Azure.Core.useFinalStateVia("azure-async-operation")
create is ArmResourceCreateOrReplaceAsync<
StorageTask,
Response = ArmResourceUpdatedResponse<StorageTask> | ArmResourceCreatedResponse<
StorageTask,
ArmLroLocationHeader<FinalResult = StorageTask> &
Azure.Core.Foundations.RetryAfterHeader
> | ArmAcceptedLroResponse
>;

/**
* Update storage task properties
*/
@patch(#{ implicitOptionality: false })
update is ArmCustomPatchAsync<
StorageTask,
PatchModel = StorageTaskUpdateParameters,
Response = ArmResourceUpdatedResponse<StorageTask> | ArmAcceptedLroResponse<LroHeaders = ArmAsyncOperationHeader<FinalResult = StorageTask> &
ArmLroLocationHeader<FinalResult = StorageTask> &
Azure.Core.Foundations.RetryAfterHeader>
>;

/**
* Delete the storage task resource.
*/
delete is ArmResourceDeleteWithoutOkAsync<
StorageTask,
Response = ArmAcceptedLroResponse<LroHeaders = ArmAsyncOperationHeader<FinalResult = StorageTask> &
ArmLroLocationHeader<FinalResult = StorageTask> &
Azure.Core.Foundations.RetryAfterHeader> | ArmDeletedNoContentResponse
>;

/**
* Lists all the storage tasks available under the given resource group.
*/
listByResourceGroup is ArmResourceListByParent<
StorageTask,
Response = StorageTasksListResult
>;

/**
* Lists all the storage tasks available under the subscription.
*/
listBySubscription is ArmListBySubscription<
StorageTask,
Response = StorageTasksListResult
>;

/**
* Fetch the storage tasks run report summary for each assignment.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@get
@action("reports")
@operationId("StorageTasksReport_List")
list is ArmResourceActionSync<
StorageTask,
void,
ArmResponse<StorageTaskReportSummary>,
Parameters = {
/**
* Optional, specifies the maximum number of Storage Task Assignment Resource IDs to be included in the list response.
*/
@query("$maxpagesize")
$maxpagesize?: int32;

/**
* Optional. When specified, it can be used to query using reporting properties.
*/
@query("$filter")
$filter?: string;
}
>;

/**
* Lists Resource IDs of the Storage Task Assignments associated with this Storage Task.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@get
@action("storageTaskAssignments")
@operationId("StorageTaskAssignment_List")
storageTaskAssignmentList is ArmResourceActionSync<
StorageTask,
void,
ArmResponse<StorageTaskAssignmentsListResult>,
Parameters = {
/**
* Optional, specifies the maximum number of Storage Task Assignment Resource IDs to be included in the list response.
*/
@query("$maxpagesize")
$maxpagesize?: int32;
}
>;
}

@@maxLength(StorageTask.name, 18);
@@minLength(StorageTask.name, 3);
@@doc(StorageTask.name,
"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."
);
@@doc(StorageTask.properties, "Properties of the storage task.");
@@doc(StorageTasks.create::parameters.resource,
"The parameters to create a Storage Task."
);
@@doc(StorageTasks.update::parameters.properties,
"The parameters to provide to update the storage task resource."
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import "@azure-tools/typespec-client-generator-core";

using Azure.ClientGenerator.Core;
using Microsoft.StorageActions;

#suppress "deprecated" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@@flattenProperty(StorageTaskPreviewAction.properties, "!csharp");

#suppress "deprecated" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@@flattenProperty(StorageTaskUpdateParameters.properties, "!csharp");
Comment on lines +6 to +10
Copy link
Member

@weidongxu-microsoft weidongxu-microsoft Jun 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#suppress "deprecated" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@@flattenProperty(StorageTaskPreviewAction.properties, "!csharp");
#suppress "deprecated" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@@flattenProperty(StorageTaskUpdateParameters.properties, "!csharp");
#suppress "deprecated" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@@flattenProperty(StorageTaskPreviewAction.properties, "!csharp,!java");
#suppress "deprecated" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@@flattenProperty(StorageTaskUpdateParameters.properties, "!csharp,!java");

Hope this is the correct syntax. Java already disabled flatten in this RP.


@@clientName(StorageTasks.create::parameters.resource, "parameters");
@@clientName(StorageTasks.update::parameters.properties, "parameters");
@@clientName(StorageTasksOperationGroup.previewActions::parameters.body,
"parameters"
);
@@clientName(StorageTasksOperationGroup.previewActions, "PreviewActions");
#suppress "deprecated" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details"
@@flattenProperty(StorageTask.properties, "!csharp");

// @@clientLocation decorators for operations with custom @operationId
// These ensure consistent operationId generation in the output
@@clientLocation(StorageTasksOperationGroup.previewActions, StorageTasks);
@@clientLocation(StorageTasks.list, "StorageTasksReport");
@@clientLocation(StorageTasks.storageTaskAssignmentList,
"StorageTaskAssignment"
);
Comment on lines +25 to +27
Copy link
Member

@weidongxu-microsoft weidongxu-microsoft Jun 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may need a clientName too.

OperationId is StorageTaskAssignment_List. Mind the List vs storageTaskAssignmentList.

If service does like the storageTaskAssignmentList in SDK, one can use the scope=autorest to make it only apply to generated Swagger but not SDK.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I follow. What needs a clientName?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand weidong means we need another @clientName(StorageTasks.storageTaskAssignmentList, "list") for SDK to avoid the operation name breaking:
image

Copy link
Member

@weidongxu-microsoft weidongxu-microsoft Jun 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pan, I assume you need the @clientName with at least scope=autorest to avoid break Swagger in future (e.g. after @operationId get retired, and @operationId(StorageTaskAssignment_List) no longer affect Swagger).

SDK is actually fine to take either name service prefer, as we are not GAed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you try at your side? There is another StorageTasksReport_List. I'm not sure if it will throw conflict.

Copy link
Member

@weidongxu-microsoft weidongxu-microsoft Jun 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is under StorageTasks or StorageTaskAssignment, why it would conflict with the list in StorageTasksReport?

It is fine whether you do it or not. I can do this in client.tsp. But client.tsp won't affect Swagger. That's all.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

21 changes: 21 additions & 0 deletions specification/storageactions/StorageAction.Management/client.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import "@azure-tools/typespec-client-generator-core";
import "./main.tsp";

using Azure.ClientGenerator.Core;
using Microsoft.StorageActions;

@@clientName(Microsoft.StorageActions, "StorageActionsMgmtClient", "python");

@@clientName(StorageTaskOperation, "StorageTaskOperationInfo", "csharp");
@@clientName(OnSuccess, "OnSuccessAction", "csharp");
@@clientName(OnFailure, "OnFailureAction", "csharp");
@@clientName(ElseCondition, "StorageTaskElseCondition", "csharp");
@@clientName(IfCondition, "StorageTaskIfCondition", "csharp");
@@clientName(ProvisioningState, "StorageTaskProvisioningState", "csharp");
@@clientName(RunResult, "StorageTaskRunResult", "csharp");
@@clientName(RunStatusEnum, "StorageTaskRunStatus", "csharp");
@@clientName(StorageTaskProperties.enabled, "IsEnabled", "csharp");
@@clientName(StorageTasks.storageTaskAssignmentList,
"GetStorageTaskAssignments",
"csharp"
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"operationId": "Operations_List",
"parameters": {
"api-version": "2023-01-01"
},
"title": "OperationsList",
"responses": {
"200": {
"body": {
"value": [
{
"name": "Microsoft.StorageActions/storageTasks/read",
"display": {
"description": "Gets or Lists existing StorageTask resource(s).",
"operation": "Get or List StorageTask resource(s).",
"provider": "Microsoft StorageActions",
"resource": "StorageTasks"
},
"isDataAction": false
},
{
"name": "Microsoft.StorageActions/storageTasks/write",
"display": {
"description": "Creates or Updates StorageTask resource.",
"operation": "Create or Update StorageTask resource.",
"provider": "Microsoft StorageActions",
"resource": "StorageTasks"
},
"isDataAction": false
},
{
"name": "Microsoft.StorageActions/storageTasks/delete",
"display": {
"description": "Deletes StorageTask resource.",
"operation": "Delete StorageTask resource.",
"provider": "Microsoft StorageActions",
"resource": "StorageTasks"
},
"isDataAction": false
}
]
}
}
}
}
Loading
Loading