-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Changes from all commits
bc51946
4db73a6
fec33d7
63228e0
29bb04f
2d38a7b
769d1d4
703a016
c50f7aa
f414e7f
91fc3bd
11cac72
c9e02e8
bd1e3e4
ff1e796
c4db1aa
bc11ebb
fb37e4a
3abd8c4
ccf27db
08b8d30
972d2e4
33f3a4e
d12552c
707f9f4
a9d233f
8250475
ad35927
1f22b07
7cb776b
3b8d68d
e64eab0
996ea93
9701861
8056611
28d1dad
709bd2c
bc30521
bacd49b
ac96eae
1e1b39c
9469447
47b7fcd
aaafb88
c4a0def
81fe25d
048cd3b
408c0c6
f6f7156
8198527
e4a3100
d52f4d9
653c649
606ad9f
69c1223
84f242b
d94c304
b1fd677
aff85d3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This may need a clientName too. OperationId is If service does like the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I follow. What needs a clientName? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pan, I assume you need the SDK is actually fine to take either name service prefer, as we are not GAed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you try at your side? There is another There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is under 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
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 | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.