Skip to content

Convert Azure Data Transfer to typespec (2025-04-11-preview) #34640

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
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
d804a8d
- Convert OpenAPI v2 JSON to typespec + rearrange models to not all b…
May 13, 2025
c10c9f6
- Update 201 Created to not be Async.
May 13, 2025
efa5e0a
- Fix all doc warnings
May 13, 2025
262fec4
- Suppress no-response-body linter rules to match prior OpenAPI spec
May 13, 2025
297e08b
- Update provider actions + supress resource opreations lint rule sin…
May 13, 2025
b87bdda
- Supress patch envelope linter rule as to match prior api spec
May 13, 2025
1bc1e7b
- Revert tspconfig back to its original output file
May 13, 2025
93ea139
- Include typespec output updates
May 13, 2025
7f7ae8a
- remove resources.json
May 13, 2025
638ef34
Fix openapi operationids being changed
May 13, 2025
8fd3e42
Reset examples
May 13, 2025
1f593fc
Revert files to be based on what the autogenerated code does
May 14, 2025
536a03e
Update spec based on generated code to reduce braking changes.
May 14, 2025
130d195
Remove temp json
May 14, 2025
bca2522
Update operation ids
May 14, 2025
f2fe391
Update the json
May 14, 2025
fc0efc9
Remove lintdiff violations since the underlying model is readOnly
May 14, 2025
b87c941
Vibe code my problems away
May 14, 2025
04884aa
Vibe code my problems away -- breaking changes for model names (sans …
May 14, 2025
8dd69b3
Change everything to make use of the proper Schemas object
May 14, 2025
bd09f50
Undo name change of schemas object.
May 15, 2025
3e4724d
Fix spreading of Flow/Connection Properties + Non templated Tracked R…
May 15, 2025
b321151
Rerun typespec compile to include changes in OpenAPI Spec v2
May 15, 2025
025bcc6
Pendingflow use flow not connection.
May 15, 2025
382abe8
Switch over some Enums to match their old types.
May 15, 2025
0a697d8
Switch over more enums to match their old type names.
May 15, 2025
7275eb1
Switch over the rest of the possible enums to match their old type na…
May 15, 2025
8e098e0
Update docs.
May 16, 2025
a4a03d6
Update examples to have one for every operation.
May 16, 2025
d41a0b7
Prettier the examples.
May 16, 2025
7f1aa17
Remove some more ref changes
May 16, 2025
658fbcd
Remove some more ref changes2
May 16, 2025
905ccd3
Remove extra version file from prior breakout.
May 16, 2025
5509df2
Prettier the resources.json
May 16, 2025
b58f25f
Remove resources.json
May 16, 2025
fef92e6
Suppress LintDiff violation since an inline model became a ref'd defi…
May 16, 2025
704be0e
Maybe figured out the correct way to suppress this.
May 16, 2025
9e7050a
Add newline at EOF to ensure git diff matches
May 16, 2025
58f609b
Maybe figured out the correct way to suppress this. try 2
May 16, 2025
018c955
Update verbiage of supression description
May 16, 2025
0a4641d
Fix double newline at EOF
May 16, 2025
754c33d
Remove extra json path
May 16, 2025
9badf34
Remove fixes for caps.
May 19, 2025
72c6998
Correct PipelineConnection model to ensure that things are ReadOnly
May 19, 2025
c6ccd56
Update supression to match new names with Typespec visibility templates.
May 19, 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
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.ClientGenerator.Core;
using Azure.ResourceManager;
using TypeSpec.Http;
using TypeSpec.OpenAPI;

namespace Microsoft.AzureDataTransfer;
/**
* The connection resource definition.
*/
model Connection
is Azure.ResourceManager.TrackedResource<ConnectionProperties> {
...ResourceNameParameter<
Resource = Connection,
KeyName = "connectionName",
SegmentName = "connections",
NamePattern = "^[a-zA-Z0-9-]{3,64}$"
>;
...Azure.ResourceManager.ManagedServiceIdentityProperty;
}

@armResourceOperations
interface Connections {
/**
* Gets connection resource.
*/
get is ArmResourceRead<Connection>;

/**
* Creates or updates the connection resource.
*/
createOrUpdate is ArmResourceCreateOrReplaceAsync<Connection>;

/**
* Updates the connection resource.
*/
#suppress "@azure-tools/typespec-azure-resource-manager/no-response-body" "Prior OpenAPI2 Json spec provides the resource back in the LRO response."
@patch(#{ implicitOptionality: false })
update is ArmCustomPatchAsync<
Connection,
PatchModel = ConnectionsPatch,
Response = ArmResponse<Connection> | (ArmAcceptedLroResponse & {
@bodyRoot
_: Connection;
})
>;

/**
* Deletes the connection resource.
*/
delete is ArmResourceDeleteWithoutOkAsync<Connection>;

/**
* Gets connections in a resource group.
*/
listByResourceGroup is ArmResourceListByParent<Connection>;

/**
* Gets connections in a subscription.
*/
listBySubscription is ArmListBySubscription<Connection>;

/**
* Links the connection to its pending connection.
*/
link is ArmResourceActionAsync<
Connection,
ResourceBody,
ArmResponse<Connection>
>;

/**
* Lists all pending remote connections that are linkable to this connection.
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "Operation Id generated does not match original OpenAPIv2 JSON specification."
@action("listPendingConnections")
@operationId("ListPendingConnections_List")
list is ArmResourceActionSync<
Connection,
void,
ArmResponse<ResourceListCustomResult<PendingConnection>>
>;

/**
* Lists all remote flows that have not yet been linked to local flows
*/
#suppress "@azure-tools/typespec-azure-core/no-openapi" "Operation Id generated does not match original OpenAPIv2 JSON specification."
@action("listPendingFlows")
@operationId("ListPendingFlows_List")
listPendingFlowsList is ArmResourceActionSync<
Connection,
void,
ArmResponse<ResourceListCustomResult<PendingFlow>>
>;
}

@@maxLength(Connection.name, 64);
@@minLength(Connection.name, 3);
@@doc(Connection.name,
"The name for the connection to perform the operation on."
);
@@doc(Connection.properties, "Properties of connection");
@@doc(Connections.createOrUpdate::parameters.resource, "Connection body");
@@doc(Connections.update::parameters.properties, "Connection body");
@@doc(Connections.link::parameters.body, "Connection body");

@@clientName(Connections.createOrUpdate::parameters.resource, "connection");
@@clientName(Connections.update::parameters.properties, "connection");
@@clientName(Connections.link::parameters.body, "connection");
185 changes: 185 additions & 0 deletions specification/azuredatatransfer/AzureDataTransfer.Management/Flow.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";
import "@azure-tools/typespec-client-generator-core";
import "@typespec/openapi";
import "@typespec/rest";
import "./models.tsp";
import "./Connection.tsp";

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

namespace Microsoft.AzureDataTransfer;
/**
* The flow resource definition.
*/
@parentResource(Connection)
model Flow is Azure.ResourceManager.TrackedResource<FlowProperties> {
...ResourceNameParameter<
Resource = Flow,
KeyName = "flowName",
SegmentName = "flows",
NamePattern = "^[a-zA-Z0-9-]{3,64}$"
>;
...Azure.ResourceManager.ResourcePlanProperty;
...Azure.ResourceManager.ManagedServiceIdentityProperty;
}

@armResourceOperations
interface Flows {
/**
* Gets flow resource.
*/
get is ArmResourceRead<Flow>;

/**
* Creates or updates the flow resource.
*/
createOrUpdate is ArmResourceCreateOrReplaceAsync<Flow>;

/**
* Updates the flow resource.
*/
#suppress "@azure-tools/typespec-azure-resource-manager/no-response-body" "Prior OpenAPI2 Json spec provides the resource back in the LRO response."
@patch(#{ implicitOptionality: false })
update is ArmCustomPatchAsync<
Flow,
PatchModel = FlowsPatch,
Response = ArmResponse<Flow> | (ArmAcceptedLroResponse & {
@bodyRoot
_: Flow;
})
>;

/**
* Deletes the flow resource.
*/
delete is ArmResourceDeleteWithoutOkAsync<Flow>;

/**
* Gets flows in a connection.
*/
listByConnection is ArmResourceListByParent<Flow>;

/**
* Disables the specified flow
*/
disable is ArmResourceActionAsync<Flow, void, ArmResponse<Flow>>;

/**
* Enables the specified flow.
*/
enable is ArmResourceActionAsync<Flow, void, ArmResponse<Flow>>;

/**
* Generate a compliant passphrase for the specified flow.
*/
generatePassphrase is ArmResourceActionAsync<Flow, void, ArmResponse<Flow>>;

/**
* Get the destination endpoint ports for the specified flow.
*/
getDestinationEndpointPorts is ArmResourceActionSync<
Flow,
void,
ArmResponse<GetDestinationEndpointPortsResult>
>;

/**
* Get the destination endpoints for the specified flow.
*/
getDestinationEndpoints is ArmResourceActionSync<
Flow,
void,
ArmResponse<GetDestinationEndpointsResult>
>;

/**
* Get the source addresses for the specified flow.
*/
getSourceAddresses is ArmResourceActionSync<
Flow,
void,
ArmResponse<StreamSourceAddresses>
>;

/**
* Get the connection string for the specified flow.
*/
getStreamConnectionString is ArmResourceActionSync<
Flow,
void,
ArmResponse<GetStreamConnectionStringResult>
>;

/**
* Links the specified flow.
*/
link is ArmResourceActionAsync<Flow, ResourceBody, ArmResponse<Flow>>;

/**
* Set the destination endpoint ports for the specified flow.
*/
setDestinationEndpointPorts is ArmResourceActionAsync<
Flow,
SetDestinationEndpointPorts,
ArmResponse<Flow>
>;

/**
* Set the destination endpoints for the specified flow.
*/
setDestinationEndpoints is ArmResourceActionAsync<
Flow,
SetDestinationEndpoints,
ArmResponse<Flow>
>;

/**
* Sets the passphrase of the specified flow.
*/
setPassphrase is ArmResourceActionAsync<
Flow,
SetStreamPassphrase,
ArmResponse<Flow>
>;

/**
* Set the source addresses for the specified flow.
*/
setSourceAddresses is ArmResourceActionAsync<
Flow,
SetSourceAddresses,
ArmResponse<Flow>
>;
}

@@maxLength(Flow.name, 64);
@@minLength(Flow.name, 3);
@@doc(Flow.name, "The name for the flow to perform the operation on.");
@@doc(Flow.properties, "Properties of flow");
@@doc(Flows.createOrUpdate::parameters.resource, "Flow body");
@@doc(Flows.update::parameters.properties, "Flow body");
@@doc(Flows.link::parameters.body, "Flow body");
@@doc(Flows.setDestinationEndpointPorts::parameters.body,
"The destination endpoint ports wanted"
);
@@doc(Flows.setDestinationEndpoints::parameters.body,
"Destination endpoints wanted."
);
@@doc(Flows.setPassphrase::parameters.body, "Passphrase to set");
@@doc(Flows.setSourceAddresses::parameters.body, "Source addresses wanted");
@@clientName(Flows.createOrUpdate::parameters.resource, "flow");
@@clientName(Flows.update::parameters.properties, "flow");
@@clientName(Flows.link::parameters.body, "flow");
@@clientName(Flows.setDestinationEndpointPorts::parameters.body,
"streamDestinationEndpointPorts"
);
@@clientName(Flows.setDestinationEndpoints::parameters.body,
"streamDestinationEndpoints"
);
@@clientName(Flows.setPassphrase::parameters.body, "passphrase");
@@clientName(Flows.setSourceAddresses::parameters.body, "sourceAddresses");
Loading