-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Convert Servicelinker Swagger to Tsp #34326
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
base: main
Are you sure you want to change the base?
Changes from 49 commits
d0ddf99
90045ba
a9ac2a0
9389cb6
ee2b24e
90447bf
16439d7
5d0721d
ca12b7b
4b5dba1
6204228
9c08008
f16e1cc
4039c1d
89e683b
c11983a
f6e832e
783f394
feed1fc
280ad3e
8be12aa
50d8b4f
ee6ad6c
eb11fe5
e2b99e2
0aadd4e
3ed0c78
dc1af98
3fc3584
e94fc03
14d2e8d
74a7283
d59a7e1
72b4deb
423fee2
d0c7048
f05aabe
47fc363
de7befb
9c14341
a9d2931
ffbfe26
ea0ee07
a4052c4
83c96cb
dca4e65
c920b74
5c97657
e3e66a0
e8756ae
92394ac
3c38f07
0e3900b
793bd2c
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,142 @@ | ||
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; | ||
|
||
namespace Microsoft.ServiceLinker; | ||
/** | ||
* a dryrun job resource | ||
*/ | ||
@subscriptionResource | ||
@parentResource(SubscriptionLocationResource) | ||
model DryrunResource is Azure.ResourceManager.ProxyResource<DryrunProperties> { | ||
...ResourceNameParameter< | ||
Resource = DryrunResource, | ||
KeyName = "dryrunName", | ||
SegmentName = "dryruns", | ||
NamePattern = "" | ||
>; | ||
} | ||
|
||
@armResourceOperations | ||
interface DryrunResourceOps | ||
extends Azure.ResourceManager.Legacy.LegacyOperations< | ||
{ | ||
...ApiVersionParameter, | ||
...SubscriptionIdParameter, | ||
...ResourceGroupParameter, | ||
...Azure.ResourceManager.Legacy.Provider, | ||
...LocationParameter, | ||
}, | ||
KeysOf<ResourceNameParameter< | ||
Resource = DryrunResource, | ||
KeyName = "dryrunName", | ||
SegmentName = "dryruns", | ||
NamePattern = "" | ||
>> | ||
> {} | ||
|
||
@armResourceOperations | ||
interface DryrunResources { | ||
/** | ||
* get a dryrun job | ||
*/ | ||
getDryrun is DryrunResourceOps.Read<DryrunResource>; | ||
|
||
/** | ||
* create a dryrun job to do necessary check before actual creation | ||
*/ | ||
createDryrun is DryrunResourceOps.CreateOrUpdateAsync<DryrunResource>; | ||
|
||
/** | ||
* update a dryrun job to do necessary check before actual creation | ||
*/ | ||
#suppress "@azure-tools/typespec-azure-resource-manager/lro-location-header" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" | ||
@patch(#{ implicitOptionality: false }) | ||
updateDryrun is DryrunResourceOps.CustomPatchAsync< | ||
DryrunResource, | ||
PatchModel = DryrunPatch, | ||
Response = ArmResourceUpdatedResponse<DryrunResource> | ArmAcceptedLroResponse<LroHeaders = ArmAsyncOperationHeader<FinalResult = DryrunResource>> | ||
>; | ||
|
||
/** | ||
* delete a dryrun job | ||
*/ | ||
deleteDryrun is DryrunResourceOps.DeleteSync<DryrunResource>; | ||
|
||
/** | ||
* list dryrun jobs | ||
*/ | ||
listDryrun is DryrunResourceOps.List< | ||
DryrunResource, | ||
Response = ArmResponse<DryrunList> | ||
>; | ||
} | ||
|
||
@armResourceOperations | ||
interface LinkersOps | ||
extends Azure.ResourceManager.Legacy.LegacyOperations< | ||
{ | ||
...ApiVersionParameter, | ||
|
||
/** The fully qualified Azure Resource manager identifier of the resource to be connected. */ | ||
@path(#{ allowReserved: true }) | ||
resourceUri: string, | ||
|
||
...Azure.ResourceManager.Legacy.Provider, | ||
}, | ||
KeysOf<ResourceNameParameter< | ||
Resource = DryrunResource, | ||
KeyName = "dryrunName", | ||
SegmentName = "dryruns", | ||
NamePattern = "" | ||
>> | ||
> {} | ||
@armResourceOperations | ||
interface Linkers { | ||
/** | ||
* get a dryrun job | ||
*/ | ||
getDryrun is LinkersOps.Read<DryrunResource>; | ||
|
||
/** | ||
* create a dryrun job to do necessary check before actual creation | ||
*/ | ||
createDryrun is LinkersOps.CreateOrUpdateAsync<DryrunResource>; | ||
|
||
/** | ||
* add a dryrun job to do necessary check before actual creation | ||
*/ | ||
#suppress "@azure-tools/typespec-azure-resource-manager/lro-location-header" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" | ||
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. Is this an lro? And if so, how does it perform polling? 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. Yes, LRO! I didn't get your question actually. How service perform polling? I feel like it's not a question to me. |
||
@patch(#{ implicitOptionality: false }) | ||
updateDryrun is LinkersOps.CustomPatchAsync< | ||
DryrunResource, | ||
PatchModel = DryrunPatch, | ||
Response = ArmResourceUpdatedResponse<DryrunResource> | ArmAcceptedLroResponse<LroHeaders = ArmAsyncOperationHeader<FinalResult = DryrunResource>> | ||
>; | ||
|
||
/** | ||
* delete a dryrun job | ||
*/ | ||
deleteDryrun is LinkersOps.DeleteSync<DryrunResource>; | ||
|
||
/** | ||
* list dryrun jobs | ||
*/ | ||
listDryrun is LinkersOps.List< | ||
DryrunResource, | ||
Response = ArmResponse<DryrunList> | ||
>; | ||
} | ||
|
||
@@doc(DryrunResource.name, "The name of dryrun."); | ||
@@doc(DryrunResource.properties, "The properties of the dryrun job."); | ||
@@doc(DryrunResources.createDryrun::parameters.resource, "dryrun resource."); | ||
@@doc(DryrunResources.updateDryrun::parameters.properties, "dryrun resource."); | ||
@@doc(Linkers.createDryrun::parameters.resource, "dryrun resource."); | ||
@@doc(Linkers.updateDryrun::parameters.properties, "dryrun resource."); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,214 @@ | ||
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; | ||
|
||
namespace Microsoft.ServiceLinker; | ||
/** | ||
* Linker of source and target resource | ||
*/ | ||
@subscriptionResource | ||
@parentResource(SubscriptionLocationResource) | ||
model LinkerResource | ||
is Azure.ResourceManager.ProxyResource<LinkerProperties, false> { | ||
...ResourceNameParameter< | ||
Resource = LinkerResource, | ||
KeyName = "connectorName", | ||
SegmentName = "connectors", | ||
NamePattern = "" | ||
>; | ||
} | ||
|
||
@armResourceOperations | ||
interface LinkerResourceOps | ||
extends Azure.ResourceManager.Legacy.LegacyOperations< | ||
{ | ||
...ApiVersionParameter, | ||
...SubscriptionIdParameter, | ||
...ResourceGroupParameter, | ||
...Azure.ResourceManager.Legacy.Provider, | ||
...LocationParameter, | ||
}, | ||
KeysOf<ResourceNameParameter< | ||
Resource = LinkerResource, | ||
KeyName = "connectorName", | ||
SegmentName = "connectors", | ||
NamePattern = "" | ||
>> | ||
> {} | ||
|
||
@armResourceOperations | ||
interface LinkerResources { | ||
/** | ||
* Returns Connector resource for a given name. | ||
*/ | ||
get is LinkerResourceOps.Read<LinkerResource>; | ||
|
||
/** | ||
* Create or update Connector resource. | ||
*/ | ||
createOrUpdate is LinkerResourceOps.CreateOrUpdateAsync<LinkerResource>; | ||
/** | ||
* Operation to update an existing Connector. | ||
*/ | ||
#suppress "@azure-tools/typespec-azure-resource-manager/no-response-body" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" | ||
#suppress "@azure-tools/typespec-azure-resource-manager/lro-location-header" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" | ||
@patch(#{ implicitOptionality: false }) | ||
update is LinkerResourceOps.CustomPatchAsync< | ||
LinkerResource, | ||
PatchModel = LinkerPatch, | ||
Response = ArmResponse<LinkerResource> | (ArmAcceptedLroResponse<LroHeaders = ArmAsyncOperationHeader<FinalResult = LinkerResource>> & { | ||
@bodyRoot | ||
_: LinkerResource; | ||
}) | ||
>; | ||
|
||
/** | ||
* Delete a Connector. | ||
*/ | ||
#suppress "@azure-tools/typespec-azure-resource-manager/lro-location-header" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" | ||
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. Why is the location header missing? What is the polling method for this operation? Will downstream client libraries know how to perform polling with this spec? 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've no ideas what the polling operation is. I just honored what swagger defined. There is no place in swagger could identify a polling operation. |
||
#suppress "@azure-tools/typespec-azure-resource-manager/arm-delete-operation-response-codes" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" | ||
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. Why are we getting this linter warning with this template? I dont see it modifying the response code. If this is non-standard behavior that is purposefully added for legacy reasons, seems like the suppression should be on the template itself instead of making every user of this template add suppressions for it 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. It does. The Response is already customzied. |
||
delete is LinkerResourceOps.DeleteWithoutOkAsync< | ||
LinkerResource, | ||
Response = ArmDeletedResponse | ArmDeleteAcceptedLroResponse<ArmAsyncOperationHeader & | ||
Azure.Core.Foundations.RetryAfterHeader> | ArmDeletedNoContentResponse | ||
>; | ||
|
||
/** | ||
* Returns list of connector which connects to the resource, which supports to config the target service during the resource provision. | ||
*/ | ||
list is LinkerResourceOps.List< | ||
LinkerResource, | ||
Response = ArmResponse<ResourceList> | ||
>; | ||
|
||
/** | ||
* Validate a Connector. | ||
*/ | ||
validate is LinkerResourceOps.ActionAsync< | ||
LinkerResource, | ||
void, | ||
ValidateOperationResult | ||
>; | ||
|
||
/** | ||
* Generate configurations for a Connector. | ||
*/ | ||
generateConfigurations is LinkerResourceOps.ActionSync< | ||
LinkerResource, | ||
ConfigurationInfo, | ||
ArmResponse<ConfigurationResult>, | ||
OptionalRequestBody = true | ||
>; | ||
} | ||
@armResourceOperations | ||
interface LinkerOps | ||
extends Azure.ResourceManager.Legacy.LegacyOperations< | ||
{ | ||
...ApiVersionParameter, | ||
|
||
/** The fully qualified Azure Resource manager identifier of the resource to be connected. */ | ||
@path(#{ allowReserved: true }) | ||
resourceUri: string, | ||
|
||
...Azure.ResourceManager.Legacy.Provider, | ||
}, | ||
KeysOf<ResourceNameParameter< | ||
Resource = LinkerResource, | ||
KeyName = "linkerName", | ||
SegmentName = "linkers", | ||
NamePattern = "" | ||
>> | ||
> {} | ||
|
||
@armResourceOperations | ||
interface Linker { | ||
/** | ||
* Returns Linker resource for a given name. | ||
*/ | ||
get is LinkerOps.Read<LinkerResource>; | ||
|
||
/** | ||
* Create or update Linker resource. | ||
*/ | ||
createOrUpdate is LinkerOps.CreateOrUpdateAsync<LinkerResource>; | ||
|
||
/** | ||
* Operation to update an existing Linker. | ||
*/ | ||
@patch(#{ implicitOptionality: false }) | ||
update is LinkerOps.CustomPatchAsync< | ||
LinkerResource, | ||
PatchModel = LinkerPatch, | ||
Response = ArmResponse<LinkerResource> | ArmResourceCreatedResponse< | ||
LinkerResource, | ||
LroHeaders = ArmAsyncOperationHeader<FinalResult = LinkerResource> | ||
> | ||
>; | ||
|
||
/** | ||
* Delete a Linker. | ||
*/ | ||
#suppress "@azure-tools/typespec-azure-resource-manager/lro-location-header" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" | ||
#suppress "@azure-tools/typespec-azure-resource-manager/arm-delete-operation-response-codes" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" | ||
delete is LinkerOps.DeleteWithoutOkAsync< | ||
LinkerResource, | ||
Response = ArmDeletedResponse | ArmDeleteAcceptedLroResponse<ArmAsyncOperationHeader & | ||
Azure.Core.Foundations.RetryAfterHeader> | ArmDeletedNoContentResponse | ||
>; | ||
|
||
/** | ||
* Returns list of Linkers which connects to the resource. which supports to config both application and target service during the resource provision. | ||
*/ | ||
@segment("linkers") | ||
list is LinkerOps.List<LinkerResource, Response = ArmResponse<ResourceList>>; | ||
|
||
/** | ||
* Validate a Linker. | ||
*/ | ||
@action("validateLinker") | ||
validate is LinkerOps.ActionAsync< | ||
LinkerResource, | ||
void, | ||
ValidateOperationResult | ||
>; | ||
|
||
/** | ||
* list source configurations for a Linker. | ||
*/ | ||
listConfigurations is LinkerOps.ActionSync< | ||
LinkerResource, | ||
void, | ||
ArmResponse<ConfigurationResult> | ||
>; | ||
|
||
/** | ||
* Generate configurations for a Linker. | ||
*/ | ||
generateConfigurations is LinkerOps.ActionSync< | ||
LinkerResource, | ||
ConfigurationInfo, | ||
ArmResponse<ConfigurationResult>, | ||
OptionalRequestBody = true | ||
>; | ||
} | ||
|
||
@@doc(LinkerResource.name, "The name of resource."); | ||
@@doc(LinkerResource.properties, "The properties of the Linker."); | ||
@@doc(LinkerResources.createOrUpdate::parameters.resource, | ||
"Connector details." | ||
); | ||
@@doc(LinkerResources.update::parameters.properties, "Connector details."); | ||
@@doc(Linker.createOrUpdate::parameters.resource, "Linker details."); | ||
@@doc(Linker.update::parameters.properties, "Linker details."); | ||
@@doc(LinkerResources.generateConfigurations::parameters.body, | ||
"Connection Info, including format, secret store, etc" | ||
); | ||
@@doc(Linker.generateConfigurations::parameters.body, | ||
"Connection Info, including format, secret store, etc" | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: can we use the same casing for all .tsp file names in the project directory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same casing you mean "DryRunResource"? We honored what service defined here.