| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | // <auto-generated/> |
| | 5 | |
|
| | 6 | | #nullable disable |
| | 7 | |
|
| | 8 | | using System; |
| | 9 | | using System.Text.Json; |
| | 10 | | using System.Threading; |
| | 11 | | using System.Threading.Tasks; |
| | 12 | | using Azure; |
| | 13 | | using Azure.Analytics.Synapse.Artifacts.Models; |
| | 14 | | using Azure.Core; |
| | 15 | | using Azure.Core.Pipeline; |
| | 16 | |
|
| | 17 | | namespace Azure.Analytics.Synapse.Artifacts |
| | 18 | | { |
| | 19 | | internal partial class DataFlowRestClient |
| | 20 | | { |
| | 21 | | private string endpoint; |
| | 22 | | private string apiVersion; |
| | 23 | | private ClientDiagnostics _clientDiagnostics; |
| | 24 | | private HttpPipeline _pipeline; |
| | 25 | |
|
| | 26 | | /// <summary> Initializes a new instance of DataFlowRestClient. </summary> |
| | 27 | | /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param> |
| | 28 | | /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param> |
| | 29 | | /// <param name="endpoint"> The workspace development endpoint, for example https://myworkspace.dev.azuresynapse |
| | 30 | | /// <param name="apiVersion"> Api Version. </param> |
| | 31 | | /// <exception cref="ArgumentNullException"> <paramref name="endpoint"/> or <paramref name="apiVersion"/> is nul |
| 0 | 32 | | public DataFlowRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string endpoint, string ap |
| | 33 | | { |
| 0 | 34 | | if (endpoint == null) |
| | 35 | | { |
| 0 | 36 | | throw new ArgumentNullException(nameof(endpoint)); |
| | 37 | | } |
| 0 | 38 | | if (apiVersion == null) |
| | 39 | | { |
| 0 | 40 | | throw new ArgumentNullException(nameof(apiVersion)); |
| | 41 | | } |
| | 42 | |
|
| 0 | 43 | | this.endpoint = endpoint; |
| 0 | 44 | | this.apiVersion = apiVersion; |
| 0 | 45 | | _clientDiagnostics = clientDiagnostics; |
| 0 | 46 | | _pipeline = pipeline; |
| 0 | 47 | | } |
| | 48 | |
|
| | 49 | | internal HttpMessage CreateCreateOrUpdateDataFlowRequest(string dataFlowName, DataFlowResource dataFlow, string |
| | 50 | | { |
| 0 | 51 | | var message = _pipeline.CreateMessage(); |
| 0 | 52 | | var request = message.Request; |
| 0 | 53 | | request.Method = RequestMethod.Put; |
| 0 | 54 | | var uri = new RawRequestUriBuilder(); |
| 0 | 55 | | uri.AppendRaw(endpoint, false); |
| 0 | 56 | | uri.AppendPath("/dataflows/", false); |
| 0 | 57 | | uri.AppendPath(dataFlowName, true); |
| 0 | 58 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 59 | | request.Uri = uri; |
| 0 | 60 | | if (ifMatch != null) |
| | 61 | | { |
| 0 | 62 | | request.Headers.Add("If-Match", ifMatch); |
| | 63 | | } |
| 0 | 64 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 65 | | var content = new Utf8JsonRequestContent(); |
| 0 | 66 | | content.JsonWriter.WriteObjectValue(dataFlow); |
| 0 | 67 | | request.Content = content; |
| 0 | 68 | | return message; |
| | 69 | | } |
| | 70 | |
|
| | 71 | | /// <summary> Creates or updates a data flow. </summary> |
| | 72 | | /// <param name="dataFlowName"> The data flow name. </param> |
| | 73 | | /// <param name="dataFlow"> Data flow resource definition. </param> |
| | 74 | | /// <param name="ifMatch"> ETag of the data flow entity. Should only be specified for update, for which it shoul |
| | 75 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 76 | | /// <exception cref="ArgumentNullException"> <paramref name="dataFlowName"/> or <paramref name="dataFlow"/> is n |
| | 77 | | public async Task<Response<DataFlowResource>> CreateOrUpdateDataFlowAsync(string dataFlowName, DataFlowResource |
| | 78 | | { |
| 0 | 79 | | if (dataFlowName == null) |
| | 80 | | { |
| 0 | 81 | | throw new ArgumentNullException(nameof(dataFlowName)); |
| | 82 | | } |
| 0 | 83 | | if (dataFlow == null) |
| | 84 | | { |
| 0 | 85 | | throw new ArgumentNullException(nameof(dataFlow)); |
| | 86 | | } |
| | 87 | |
|
| 0 | 88 | | using var message = CreateCreateOrUpdateDataFlowRequest(dataFlowName, dataFlow, ifMatch); |
| 0 | 89 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 90 | | switch (message.Response.Status) |
| | 91 | | { |
| | 92 | | case 200: |
| | 93 | | { |
| | 94 | | DataFlowResource value = default; |
| 0 | 95 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 96 | | value = DataFlowResource.DeserializeDataFlowResource(document.RootElement); |
| 0 | 97 | | return Response.FromValue(value, message.Response); |
| | 98 | | } |
| | 99 | | default: |
| 0 | 100 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 101 | | } |
| 0 | 102 | | } |
| | 103 | |
|
| | 104 | | /// <summary> Creates or updates a data flow. </summary> |
| | 105 | | /// <param name="dataFlowName"> The data flow name. </param> |
| | 106 | | /// <param name="dataFlow"> Data flow resource definition. </param> |
| | 107 | | /// <param name="ifMatch"> ETag of the data flow entity. Should only be specified for update, for which it shoul |
| | 108 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 109 | | /// <exception cref="ArgumentNullException"> <paramref name="dataFlowName"/> or <paramref name="dataFlow"/> is n |
| | 110 | | public Response<DataFlowResource> CreateOrUpdateDataFlow(string dataFlowName, DataFlowResource dataFlow, string |
| | 111 | | { |
| 0 | 112 | | if (dataFlowName == null) |
| | 113 | | { |
| 0 | 114 | | throw new ArgumentNullException(nameof(dataFlowName)); |
| | 115 | | } |
| 0 | 116 | | if (dataFlow == null) |
| | 117 | | { |
| 0 | 118 | | throw new ArgumentNullException(nameof(dataFlow)); |
| | 119 | | } |
| | 120 | |
|
| 0 | 121 | | using var message = CreateCreateOrUpdateDataFlowRequest(dataFlowName, dataFlow, ifMatch); |
| 0 | 122 | | _pipeline.Send(message, cancellationToken); |
| 0 | 123 | | switch (message.Response.Status) |
| | 124 | | { |
| | 125 | | case 200: |
| | 126 | | { |
| | 127 | | DataFlowResource value = default; |
| 0 | 128 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 129 | | value = DataFlowResource.DeserializeDataFlowResource(document.RootElement); |
| 0 | 130 | | return Response.FromValue(value, message.Response); |
| | 131 | | } |
| | 132 | | default: |
| 0 | 133 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 134 | | } |
| 0 | 135 | | } |
| | 136 | |
|
| | 137 | | internal HttpMessage CreateGetDataFlowRequest(string dataFlowName, string ifNoneMatch) |
| | 138 | | { |
| 0 | 139 | | var message = _pipeline.CreateMessage(); |
| 0 | 140 | | var request = message.Request; |
| 0 | 141 | | request.Method = RequestMethod.Get; |
| 0 | 142 | | var uri = new RawRequestUriBuilder(); |
| 0 | 143 | | uri.AppendRaw(endpoint, false); |
| 0 | 144 | | uri.AppendPath("/dataflows/", false); |
| 0 | 145 | | uri.AppendPath(dataFlowName, true); |
| 0 | 146 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 147 | | request.Uri = uri; |
| 0 | 148 | | if (ifNoneMatch != null) |
| | 149 | | { |
| 0 | 150 | | request.Headers.Add("If-None-Match", ifNoneMatch); |
| | 151 | | } |
| 0 | 152 | | return message; |
| | 153 | | } |
| | 154 | |
|
| | 155 | | /// <summary> Gets a data flow. </summary> |
| | 156 | | /// <param name="dataFlowName"> The data flow name. </param> |
| | 157 | | /// <param name="ifNoneMatch"> ETag of the data flow entity. Should only be specified for get. If the ETag match |
| | 158 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 159 | | /// <exception cref="ArgumentNullException"> <paramref name="dataFlowName"/> is null. </exception> |
| | 160 | | public async Task<Response<DataFlowResource>> GetDataFlowAsync(string dataFlowName, string ifNoneMatch = null, C |
| | 161 | | { |
| 0 | 162 | | if (dataFlowName == null) |
| | 163 | | { |
| 0 | 164 | | throw new ArgumentNullException(nameof(dataFlowName)); |
| | 165 | | } |
| | 166 | |
|
| 0 | 167 | | using var message = CreateGetDataFlowRequest(dataFlowName, ifNoneMatch); |
| 0 | 168 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 169 | | switch (message.Response.Status) |
| | 170 | | { |
| | 171 | | case 200: |
| | 172 | | { |
| | 173 | | DataFlowResource value = default; |
| 0 | 174 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 175 | | value = DataFlowResource.DeserializeDataFlowResource(document.RootElement); |
| 0 | 176 | | return Response.FromValue(value, message.Response); |
| | 177 | | } |
| | 178 | | default: |
| 0 | 179 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 180 | | } |
| 0 | 181 | | } |
| | 182 | |
|
| | 183 | | /// <summary> Gets a data flow. </summary> |
| | 184 | | /// <param name="dataFlowName"> The data flow name. </param> |
| | 185 | | /// <param name="ifNoneMatch"> ETag of the data flow entity. Should only be specified for get. If the ETag match |
| | 186 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 187 | | /// <exception cref="ArgumentNullException"> <paramref name="dataFlowName"/> is null. </exception> |
| | 188 | | public Response<DataFlowResource> GetDataFlow(string dataFlowName, string ifNoneMatch = null, CancellationToken |
| | 189 | | { |
| 0 | 190 | | if (dataFlowName == null) |
| | 191 | | { |
| 0 | 192 | | throw new ArgumentNullException(nameof(dataFlowName)); |
| | 193 | | } |
| | 194 | |
|
| 0 | 195 | | using var message = CreateGetDataFlowRequest(dataFlowName, ifNoneMatch); |
| 0 | 196 | | _pipeline.Send(message, cancellationToken); |
| 0 | 197 | | switch (message.Response.Status) |
| | 198 | | { |
| | 199 | | case 200: |
| | 200 | | { |
| | 201 | | DataFlowResource value = default; |
| 0 | 202 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 203 | | value = DataFlowResource.DeserializeDataFlowResource(document.RootElement); |
| 0 | 204 | | return Response.FromValue(value, message.Response); |
| | 205 | | } |
| | 206 | | default: |
| 0 | 207 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 208 | | } |
| 0 | 209 | | } |
| | 210 | |
|
| | 211 | | internal HttpMessage CreateDeleteDataFlowRequest(string dataFlowName) |
| | 212 | | { |
| 0 | 213 | | var message = _pipeline.CreateMessage(); |
| 0 | 214 | | var request = message.Request; |
| 0 | 215 | | request.Method = RequestMethod.Delete; |
| 0 | 216 | | var uri = new RawRequestUriBuilder(); |
| 0 | 217 | | uri.AppendRaw(endpoint, false); |
| 0 | 218 | | uri.AppendPath("/dataflows/", false); |
| 0 | 219 | | uri.AppendPath(dataFlowName, true); |
| 0 | 220 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 221 | | request.Uri = uri; |
| 0 | 222 | | return message; |
| | 223 | | } |
| | 224 | |
|
| | 225 | | /// <summary> Deletes a data flow. </summary> |
| | 226 | | /// <param name="dataFlowName"> The data flow name. </param> |
| | 227 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 228 | | /// <exception cref="ArgumentNullException"> <paramref name="dataFlowName"/> is null. </exception> |
| | 229 | | public async Task<Response> DeleteDataFlowAsync(string dataFlowName, CancellationToken cancellationToken = defau |
| | 230 | | { |
| 0 | 231 | | if (dataFlowName == null) |
| | 232 | | { |
| 0 | 233 | | throw new ArgumentNullException(nameof(dataFlowName)); |
| | 234 | | } |
| | 235 | |
|
| 0 | 236 | | using var message = CreateDeleteDataFlowRequest(dataFlowName); |
| 0 | 237 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 238 | | switch (message.Response.Status) |
| | 239 | | { |
| | 240 | | case 200: |
| | 241 | | case 204: |
| 0 | 242 | | return message.Response; |
| | 243 | | default: |
| 0 | 244 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 245 | | } |
| 0 | 246 | | } |
| | 247 | |
|
| | 248 | | /// <summary> Deletes a data flow. </summary> |
| | 249 | | /// <param name="dataFlowName"> The data flow name. </param> |
| | 250 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 251 | | /// <exception cref="ArgumentNullException"> <paramref name="dataFlowName"/> is null. </exception> |
| | 252 | | public Response DeleteDataFlow(string dataFlowName, CancellationToken cancellationToken = default) |
| | 253 | | { |
| 0 | 254 | | if (dataFlowName == null) |
| | 255 | | { |
| 0 | 256 | | throw new ArgumentNullException(nameof(dataFlowName)); |
| | 257 | | } |
| | 258 | |
|
| 0 | 259 | | using var message = CreateDeleteDataFlowRequest(dataFlowName); |
| 0 | 260 | | _pipeline.Send(message, cancellationToken); |
| 0 | 261 | | switch (message.Response.Status) |
| | 262 | | { |
| | 263 | | case 200: |
| | 264 | | case 204: |
| 0 | 265 | | return message.Response; |
| | 266 | | default: |
| 0 | 267 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 268 | | } |
| 0 | 269 | | } |
| | 270 | |
|
| | 271 | | internal HttpMessage CreateGetDataFlowsByWorkspaceRequest() |
| | 272 | | { |
| 0 | 273 | | var message = _pipeline.CreateMessage(); |
| 0 | 274 | | var request = message.Request; |
| 0 | 275 | | request.Method = RequestMethod.Get; |
| 0 | 276 | | var uri = new RawRequestUriBuilder(); |
| 0 | 277 | | uri.AppendRaw(endpoint, false); |
| 0 | 278 | | uri.AppendPath("/dataflows", false); |
| 0 | 279 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 280 | | request.Uri = uri; |
| 0 | 281 | | return message; |
| | 282 | | } |
| | 283 | |
|
| | 284 | | /// <summary> Lists data flows. </summary> |
| | 285 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 286 | | public async Task<Response<DataFlowListResponse>> GetDataFlowsByWorkspaceAsync(CancellationToken cancellationTok |
| | 287 | | { |
| 0 | 288 | | using var message = CreateGetDataFlowsByWorkspaceRequest(); |
| 0 | 289 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 290 | | switch (message.Response.Status) |
| | 291 | | { |
| | 292 | | case 200: |
| | 293 | | { |
| | 294 | | DataFlowListResponse value = default; |
| 0 | 295 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 296 | | value = DataFlowListResponse.DeserializeDataFlowListResponse(document.RootElement); |
| 0 | 297 | | return Response.FromValue(value, message.Response); |
| | 298 | | } |
| | 299 | | default: |
| 0 | 300 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 301 | | } |
| 0 | 302 | | } |
| | 303 | |
|
| | 304 | | /// <summary> Lists data flows. </summary> |
| | 305 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 306 | | public Response<DataFlowListResponse> GetDataFlowsByWorkspace(CancellationToken cancellationToken = default) |
| | 307 | | { |
| 0 | 308 | | using var message = CreateGetDataFlowsByWorkspaceRequest(); |
| 0 | 309 | | _pipeline.Send(message, cancellationToken); |
| 0 | 310 | | switch (message.Response.Status) |
| | 311 | | { |
| | 312 | | case 200: |
| | 313 | | { |
| | 314 | | DataFlowListResponse value = default; |
| 0 | 315 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 316 | | value = DataFlowListResponse.DeserializeDataFlowListResponse(document.RootElement); |
| 0 | 317 | | return Response.FromValue(value, message.Response); |
| | 318 | | } |
| | 319 | | default: |
| 0 | 320 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 321 | | } |
| 0 | 322 | | } |
| | 323 | |
|
| | 324 | | internal HttpMessage CreateGetDataFlowsByWorkspaceNextPageRequest(string nextLink) |
| | 325 | | { |
| 0 | 326 | | var message = _pipeline.CreateMessage(); |
| 0 | 327 | | var request = message.Request; |
| 0 | 328 | | request.Method = RequestMethod.Get; |
| 0 | 329 | | var uri = new RawRequestUriBuilder(); |
| 0 | 330 | | uri.AppendRaw(endpoint, false); |
| 0 | 331 | | uri.AppendRawNextLink(nextLink, false); |
| 0 | 332 | | request.Uri = uri; |
| 0 | 333 | | return message; |
| | 334 | | } |
| | 335 | |
|
| | 336 | | /// <summary> Lists data flows. </summary> |
| | 337 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 338 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 339 | | /// <exception cref="ArgumentNullException"> <paramref name="nextLink"/> is null. </exception> |
| | 340 | | public async Task<Response<DataFlowListResponse>> GetDataFlowsByWorkspaceNextPageAsync(string nextLink, Cancella |
| | 341 | | { |
| 0 | 342 | | if (nextLink == null) |
| | 343 | | { |
| 0 | 344 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 345 | | } |
| | 346 | |
|
| 0 | 347 | | using var message = CreateGetDataFlowsByWorkspaceNextPageRequest(nextLink); |
| 0 | 348 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 349 | | switch (message.Response.Status) |
| | 350 | | { |
| | 351 | | case 200: |
| | 352 | | { |
| | 353 | | DataFlowListResponse value = default; |
| 0 | 354 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 355 | | value = DataFlowListResponse.DeserializeDataFlowListResponse(document.RootElement); |
| 0 | 356 | | return Response.FromValue(value, message.Response); |
| | 357 | | } |
| | 358 | | default: |
| 0 | 359 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 360 | | } |
| 0 | 361 | | } |
| | 362 | |
|
| | 363 | | /// <summary> Lists data flows. </summary> |
| | 364 | | /// <param name="nextLink"> The URL to the next page of results. </param> |
| | 365 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 366 | | /// <exception cref="ArgumentNullException"> <paramref name="nextLink"/> is null. </exception> |
| | 367 | | public Response<DataFlowListResponse> GetDataFlowsByWorkspaceNextPage(string nextLink, CancellationToken cancell |
| | 368 | | { |
| 0 | 369 | | if (nextLink == null) |
| | 370 | | { |
| 0 | 371 | | throw new ArgumentNullException(nameof(nextLink)); |
| | 372 | | } |
| | 373 | |
|
| 0 | 374 | | using var message = CreateGetDataFlowsByWorkspaceNextPageRequest(nextLink); |
| 0 | 375 | | _pipeline.Send(message, cancellationToken); |
| 0 | 376 | | switch (message.Response.Status) |
| | 377 | | { |
| | 378 | | case 200: |
| | 379 | | { |
| | 380 | | DataFlowListResponse value = default; |
| 0 | 381 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 382 | | value = DataFlowListResponse.DeserializeDataFlowListResponse(document.RootElement); |
| 0 | 383 | | return Response.FromValue(value, message.Response); |
| | 384 | | } |
| | 385 | | default: |
| 0 | 386 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 387 | | } |
| 0 | 388 | | } |
| | 389 | | } |
| | 390 | | } |