Skip to content

Commit 1ca714a

Browse files
ReprezentAlex Riedel
and
Alex Riedel
authored
Convert Azure Data Transfer to typespec (2025-04-11-preview) (#34640)
* - Convert OpenAPI v2 JSON to typespec + rearrange models to not all be in one file. * - Update 201 Created to not be Async. * - Fix all doc warnings * - Suppress no-response-body linter rules to match prior OpenAPI spec * - Update provider actions + supress resource opreations lint rule since we are not operating on a resource * - Supress patch envelope linter rule as to match prior api spec * - Revert tspconfig back to its original output file * - Include typespec output updates * - remove resources.json * Fix openapi operationids being changed * Reset examples * Revert files to be based on what the autogenerated code does * Update spec based on generated code to reduce braking changes. * Remove temp json * Update operation ids * Update the json * Remove lintdiff violations since the underlying model is readOnly * Vibe code my problems away * Vibe code my problems away -- breaking changes for model names (sans FlowType arrays) * Change everything to make use of the proper Schemas object * Undo name change of schemas object. * Fix spreading of Flow/Connection Properties + Non templated Tracked Resource. + Update Sync operation to be LRO (as it was prior). * Rerun typespec compile to include changes in OpenAPI Spec v2 * Pendingflow use flow not connection. * Switch over some Enums to match their old types. * Switch over more enums to match their old type names. * Switch over the rest of the possible enums to match their old type names. * Update docs. * Update examples to have one for every operation. * Prettier the examples. * Remove some more ref changes * Remove some more ref changes2 * Remove extra version file from prior breakout. * Prettier the resources.json * Remove resources.json * Suppress LintDiff violation since an inline model became a ref'd defintion * Maybe figured out the correct way to suppress this. * Add newline at EOF to ensure git diff matches * Maybe figured out the correct way to suppress this. try 2 * Update verbiage of supression description * Fix double newline at EOF * Remove extra json path * Remove fixes for caps. * Correct PipelineConnection model to ensure that things are ReadOnly * Update supression to match new names with Typespec visibility templates. --------- Co-authored-by: Alex Riedel <[email protected]>
1 parent 907d8f1 commit 1ca714a

File tree

89 files changed

+6726
-2158
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+6726
-2158
lines changed
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
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.ClientGenerator.Core;
9+
using Azure.ResourceManager;
10+
using TypeSpec.Http;
11+
using TypeSpec.OpenAPI;
12+
13+
namespace Microsoft.AzureDataTransfer;
14+
/**
15+
* The connection resource definition.
16+
*/
17+
model Connection
18+
is Azure.ResourceManager.TrackedResource<ConnectionProperties> {
19+
...ResourceNameParameter<
20+
Resource = Connection,
21+
KeyName = "connectionName",
22+
SegmentName = "connections",
23+
NamePattern = "^[a-zA-Z0-9-]{3,64}$"
24+
>;
25+
...Azure.ResourceManager.ManagedServiceIdentityProperty;
26+
}
27+
28+
@armResourceOperations
29+
interface Connections {
30+
/**
31+
* Gets connection resource.
32+
*/
33+
get is ArmResourceRead<Connection>;
34+
35+
/**
36+
* Creates or updates the connection resource.
37+
*/
38+
createOrUpdate is ArmResourceCreateOrReplaceAsync<Connection>;
39+
40+
/**
41+
* Updates the connection resource.
42+
*/
43+
#suppress "@azure-tools/typespec-azure-resource-manager/no-response-body" "Prior OpenAPI2 Json spec provides the resource back in the LRO response."
44+
@patch(#{ implicitOptionality: false })
45+
update is ArmCustomPatchAsync<
46+
Connection,
47+
PatchModel = ConnectionsPatch,
48+
Response = ArmResponse<Connection> | (ArmAcceptedLroResponse & {
49+
@bodyRoot
50+
_: Connection;
51+
})
52+
>;
53+
54+
/**
55+
* Deletes the connection resource.
56+
*/
57+
delete is ArmResourceDeleteWithoutOkAsync<Connection>;
58+
59+
/**
60+
* Gets connections in a resource group.
61+
*/
62+
listByResourceGroup is ArmResourceListByParent<Connection>;
63+
64+
/**
65+
* Gets connections in a subscription.
66+
*/
67+
listBySubscription is ArmListBySubscription<Connection>;
68+
69+
/**
70+
* Links the connection to its pending connection.
71+
*/
72+
link is ArmResourceActionAsync<
73+
Connection,
74+
ResourceBody,
75+
ArmResponse<Connection>
76+
>;
77+
78+
/**
79+
* Lists all pending remote connections that are linkable to this connection.
80+
*/
81+
#suppress "@azure-tools/typespec-azure-core/no-openapi" "Operation Id generated does not match original OpenAPIv2 JSON specification."
82+
@action("listPendingConnections")
83+
@operationId("ListPendingConnections_List")
84+
list is ArmResourceActionSync<
85+
Connection,
86+
void,
87+
ArmResponse<ResourceListCustomResult<PendingConnection>>
88+
>;
89+
90+
/**
91+
* Lists all remote flows that have not yet been linked to local flows
92+
*/
93+
#suppress "@azure-tools/typespec-azure-core/no-openapi" "Operation Id generated does not match original OpenAPIv2 JSON specification."
94+
@action("listPendingFlows")
95+
@operationId("ListPendingFlows_List")
96+
listPendingFlowsList is ArmResourceActionSync<
97+
Connection,
98+
void,
99+
ArmResponse<ResourceListCustomResult<PendingFlow>>
100+
>;
101+
}
102+
103+
@@maxLength(Connection.name, 64);
104+
@@minLength(Connection.name, 3);
105+
@@doc(Connection.name,
106+
"The name for the connection to perform the operation on."
107+
);
108+
@@doc(Connection.properties, "Properties of connection");
109+
@@doc(Connections.createOrUpdate::parameters.resource, "Connection body");
110+
@@doc(Connections.update::parameters.properties, "Connection body");
111+
@@doc(Connections.link::parameters.body, "Connection body");
112+
113+
@@clientName(Connections.createOrUpdate::parameters.resource, "connection");
114+
@@clientName(Connections.update::parameters.properties, "connection");
115+
@@clientName(Connections.link::parameters.body, "connection");
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
import "@azure-tools/typespec-azure-core";
2+
import "@azure-tools/typespec-azure-resource-manager";
3+
import "@azure-tools/typespec-client-generator-core";
4+
import "@typespec/openapi";
5+
import "@typespec/rest";
6+
import "./models.tsp";
7+
import "./Connection.tsp";
8+
9+
using TypeSpec.Rest;
10+
using Azure.ClientGenerator.Core;
11+
using Azure.ResourceManager;
12+
using TypeSpec.Http;
13+
using TypeSpec.OpenAPI;
14+
15+
namespace Microsoft.AzureDataTransfer;
16+
/**
17+
* The flow resource definition.
18+
*/
19+
@parentResource(Connection)
20+
model Flow is Azure.ResourceManager.TrackedResource<FlowProperties> {
21+
...ResourceNameParameter<
22+
Resource = Flow,
23+
KeyName = "flowName",
24+
SegmentName = "flows",
25+
NamePattern = "^[a-zA-Z0-9-]{3,64}$"
26+
>;
27+
...Azure.ResourceManager.ResourcePlanProperty;
28+
...Azure.ResourceManager.ManagedServiceIdentityProperty;
29+
}
30+
31+
@armResourceOperations
32+
interface Flows {
33+
/**
34+
* Gets flow resource.
35+
*/
36+
get is ArmResourceRead<Flow>;
37+
38+
/**
39+
* Creates or updates the flow resource.
40+
*/
41+
createOrUpdate is ArmResourceCreateOrReplaceAsync<Flow>;
42+
43+
/**
44+
* Updates the flow resource.
45+
*/
46+
#suppress "@azure-tools/typespec-azure-resource-manager/no-response-body" "Prior OpenAPI2 Json spec provides the resource back in the LRO response."
47+
@patch(#{ implicitOptionality: false })
48+
update is ArmCustomPatchAsync<
49+
Flow,
50+
PatchModel = FlowsPatch,
51+
Response = ArmResponse<Flow> | (ArmAcceptedLroResponse & {
52+
@bodyRoot
53+
_: Flow;
54+
})
55+
>;
56+
57+
/**
58+
* Deletes the flow resource.
59+
*/
60+
delete is ArmResourceDeleteWithoutOkAsync<Flow>;
61+
62+
/**
63+
* Gets flows in a connection.
64+
*/
65+
listByConnection is ArmResourceListByParent<Flow>;
66+
67+
/**
68+
* Disables the specified flow
69+
*/
70+
disable is ArmResourceActionAsync<Flow, void, ArmResponse<Flow>>;
71+
72+
/**
73+
* Enables the specified flow.
74+
*/
75+
enable is ArmResourceActionAsync<Flow, void, ArmResponse<Flow>>;
76+
77+
/**
78+
* Generate a compliant passphrase for the specified flow.
79+
*/
80+
generatePassphrase is ArmResourceActionAsync<Flow, void, ArmResponse<Flow>>;
81+
82+
/**
83+
* Get the destination endpoint ports for the specified flow.
84+
*/
85+
getDestinationEndpointPorts is ArmResourceActionSync<
86+
Flow,
87+
void,
88+
ArmResponse<GetDestinationEndpointPortsResult>
89+
>;
90+
91+
/**
92+
* Get the destination endpoints for the specified flow.
93+
*/
94+
getDestinationEndpoints is ArmResourceActionSync<
95+
Flow,
96+
void,
97+
ArmResponse<GetDestinationEndpointsResult>
98+
>;
99+
100+
/**
101+
* Get the source addresses for the specified flow.
102+
*/
103+
getSourceAddresses is ArmResourceActionSync<
104+
Flow,
105+
void,
106+
ArmResponse<StreamSourceAddresses>
107+
>;
108+
109+
/**
110+
* Get the connection string for the specified flow.
111+
*/
112+
getStreamConnectionString is ArmResourceActionSync<
113+
Flow,
114+
void,
115+
ArmResponse<GetStreamConnectionStringResult>
116+
>;
117+
118+
/**
119+
* Links the specified flow.
120+
*/
121+
link is ArmResourceActionAsync<Flow, ResourceBody, ArmResponse<Flow>>;
122+
123+
/**
124+
* Set the destination endpoint ports for the specified flow.
125+
*/
126+
setDestinationEndpointPorts is ArmResourceActionAsync<
127+
Flow,
128+
SetDestinationEndpointPorts,
129+
ArmResponse<Flow>
130+
>;
131+
132+
/**
133+
* Set the destination endpoints for the specified flow.
134+
*/
135+
setDestinationEndpoints is ArmResourceActionAsync<
136+
Flow,
137+
SetDestinationEndpoints,
138+
ArmResponse<Flow>
139+
>;
140+
141+
/**
142+
* Sets the passphrase of the specified flow.
143+
*/
144+
setPassphrase is ArmResourceActionAsync<
145+
Flow,
146+
SetStreamPassphrase,
147+
ArmResponse<Flow>
148+
>;
149+
150+
/**
151+
* Set the source addresses for the specified flow.
152+
*/
153+
setSourceAddresses is ArmResourceActionAsync<
154+
Flow,
155+
SetSourceAddresses,
156+
ArmResponse<Flow>
157+
>;
158+
}
159+
160+
@@maxLength(Flow.name, 64);
161+
@@minLength(Flow.name, 3);
162+
@@doc(Flow.name, "The name for the flow to perform the operation on.");
163+
@@doc(Flow.properties, "Properties of flow");
164+
@@doc(Flows.createOrUpdate::parameters.resource, "Flow body");
165+
@@doc(Flows.update::parameters.properties, "Flow body");
166+
@@doc(Flows.link::parameters.body, "Flow body");
167+
@@doc(Flows.setDestinationEndpointPorts::parameters.body,
168+
"The destination endpoint ports wanted"
169+
);
170+
@@doc(Flows.setDestinationEndpoints::parameters.body,
171+
"Destination endpoints wanted."
172+
);
173+
@@doc(Flows.setPassphrase::parameters.body, "Passphrase to set");
174+
@@doc(Flows.setSourceAddresses::parameters.body, "Source addresses wanted");
175+
@@clientName(Flows.createOrUpdate::parameters.resource, "flow");
176+
@@clientName(Flows.update::parameters.properties, "flow");
177+
@@clientName(Flows.link::parameters.body, "flow");
178+
@@clientName(Flows.setDestinationEndpointPorts::parameters.body,
179+
"streamDestinationEndpointPorts"
180+
);
181+
@@clientName(Flows.setDestinationEndpoints::parameters.body,
182+
"streamDestinationEndpoints"
183+
);
184+
@@clientName(Flows.setPassphrase::parameters.body, "passphrase");
185+
@@clientName(Flows.setSourceAddresses::parameters.body, "sourceAddresses");

0 commit comments

Comments
 (0)