| | 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 PipelineRunRestClient |
| | 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 PipelineRunRestClient. </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 PipelineRunRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string endpoint, string |
| | 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 CreateQueryPipelineRunsByWorkspaceRequest(RunFilterParameters filterParameters) |
| | 50 | | { |
| 0 | 51 | | var message = _pipeline.CreateMessage(); |
| 0 | 52 | | var request = message.Request; |
| 0 | 53 | | request.Method = RequestMethod.Post; |
| 0 | 54 | | var uri = new RawRequestUriBuilder(); |
| 0 | 55 | | uri.AppendRaw(endpoint, false); |
| 0 | 56 | | uri.AppendPath("/queryPipelineRuns", false); |
| 0 | 57 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 58 | | request.Uri = uri; |
| 0 | 59 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 60 | | var content = new Utf8JsonRequestContent(); |
| 0 | 61 | | content.JsonWriter.WriteObjectValue(filterParameters); |
| 0 | 62 | | request.Content = content; |
| 0 | 63 | | return message; |
| | 64 | | } |
| | 65 | |
|
| | 66 | | /// <summary> Query pipeline runs in the workspace based on input filter conditions. </summary> |
| | 67 | | /// <param name="filterParameters"> Parameters to filter the pipeline run. </param> |
| | 68 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 69 | | /// <exception cref="ArgumentNullException"> <paramref name="filterParameters"/> is null. </exception> |
| | 70 | | public async Task<Response<PipelineRunsQueryResponse>> QueryPipelineRunsByWorkspaceAsync(RunFilterParameters fil |
| | 71 | | { |
| 0 | 72 | | if (filterParameters == null) |
| | 73 | | { |
| 0 | 74 | | throw new ArgumentNullException(nameof(filterParameters)); |
| | 75 | | } |
| | 76 | |
|
| 0 | 77 | | using var message = CreateQueryPipelineRunsByWorkspaceRequest(filterParameters); |
| 0 | 78 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 79 | | switch (message.Response.Status) |
| | 80 | | { |
| | 81 | | case 200: |
| | 82 | | { |
| | 83 | | PipelineRunsQueryResponse value = default; |
| 0 | 84 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 85 | | value = PipelineRunsQueryResponse.DeserializePipelineRunsQueryResponse(document.RootElement); |
| 0 | 86 | | return Response.FromValue(value, message.Response); |
| | 87 | | } |
| | 88 | | default: |
| 0 | 89 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 90 | | } |
| 0 | 91 | | } |
| | 92 | |
|
| | 93 | | /// <summary> Query pipeline runs in the workspace based on input filter conditions. </summary> |
| | 94 | | /// <param name="filterParameters"> Parameters to filter the pipeline run. </param> |
| | 95 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 96 | | /// <exception cref="ArgumentNullException"> <paramref name="filterParameters"/> is null. </exception> |
| | 97 | | public Response<PipelineRunsQueryResponse> QueryPipelineRunsByWorkspace(RunFilterParameters filterParameters, Ca |
| | 98 | | { |
| 0 | 99 | | if (filterParameters == null) |
| | 100 | | { |
| 0 | 101 | | throw new ArgumentNullException(nameof(filterParameters)); |
| | 102 | | } |
| | 103 | |
|
| 0 | 104 | | using var message = CreateQueryPipelineRunsByWorkspaceRequest(filterParameters); |
| 0 | 105 | | _pipeline.Send(message, cancellationToken); |
| 0 | 106 | | switch (message.Response.Status) |
| | 107 | | { |
| | 108 | | case 200: |
| | 109 | | { |
| | 110 | | PipelineRunsQueryResponse value = default; |
| 0 | 111 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 112 | | value = PipelineRunsQueryResponse.DeserializePipelineRunsQueryResponse(document.RootElement); |
| 0 | 113 | | return Response.FromValue(value, message.Response); |
| | 114 | | } |
| | 115 | | default: |
| 0 | 116 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 117 | | } |
| 0 | 118 | | } |
| | 119 | |
|
| | 120 | | internal HttpMessage CreateGetPipelineRunRequest(string runId) |
| | 121 | | { |
| 0 | 122 | | var message = _pipeline.CreateMessage(); |
| 0 | 123 | | var request = message.Request; |
| 0 | 124 | | request.Method = RequestMethod.Get; |
| 0 | 125 | | var uri = new RawRequestUriBuilder(); |
| 0 | 126 | | uri.AppendRaw(endpoint, false); |
| 0 | 127 | | uri.AppendPath("/pipelineruns/", false); |
| 0 | 128 | | uri.AppendPath(runId, true); |
| 0 | 129 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 130 | | request.Uri = uri; |
| 0 | 131 | | return message; |
| | 132 | | } |
| | 133 | |
|
| | 134 | | /// <summary> Get a pipeline run by its run ID. </summary> |
| | 135 | | /// <param name="runId"> The pipeline run identifier. </param> |
| | 136 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 137 | | /// <exception cref="ArgumentNullException"> <paramref name="runId"/> is null. </exception> |
| | 138 | | public async Task<Response<PipelineRun>> GetPipelineRunAsync(string runId, CancellationToken cancellationToken = |
| | 139 | | { |
| 0 | 140 | | if (runId == null) |
| | 141 | | { |
| 0 | 142 | | throw new ArgumentNullException(nameof(runId)); |
| | 143 | | } |
| | 144 | |
|
| 0 | 145 | | using var message = CreateGetPipelineRunRequest(runId); |
| 0 | 146 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 147 | | switch (message.Response.Status) |
| | 148 | | { |
| | 149 | | case 200: |
| | 150 | | { |
| | 151 | | PipelineRun value = default; |
| 0 | 152 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 153 | | value = PipelineRun.DeserializePipelineRun(document.RootElement); |
| 0 | 154 | | return Response.FromValue(value, message.Response); |
| | 155 | | } |
| | 156 | | default: |
| 0 | 157 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 158 | | } |
| 0 | 159 | | } |
| | 160 | |
|
| | 161 | | /// <summary> Get a pipeline run by its run ID. </summary> |
| | 162 | | /// <param name="runId"> The pipeline run identifier. </param> |
| | 163 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 164 | | /// <exception cref="ArgumentNullException"> <paramref name="runId"/> is null. </exception> |
| | 165 | | public Response<PipelineRun> GetPipelineRun(string runId, CancellationToken cancellationToken = default) |
| | 166 | | { |
| 0 | 167 | | if (runId == null) |
| | 168 | | { |
| 0 | 169 | | throw new ArgumentNullException(nameof(runId)); |
| | 170 | | } |
| | 171 | |
|
| 0 | 172 | | using var message = CreateGetPipelineRunRequest(runId); |
| 0 | 173 | | _pipeline.Send(message, cancellationToken); |
| 0 | 174 | | switch (message.Response.Status) |
| | 175 | | { |
| | 176 | | case 200: |
| | 177 | | { |
| | 178 | | PipelineRun value = default; |
| 0 | 179 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 180 | | value = PipelineRun.DeserializePipelineRun(document.RootElement); |
| 0 | 181 | | return Response.FromValue(value, message.Response); |
| | 182 | | } |
| | 183 | | default: |
| 0 | 184 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 185 | | } |
| 0 | 186 | | } |
| | 187 | |
|
| | 188 | | internal HttpMessage CreateQueryActivityRunsRequest(string pipelineName, string runId, RunFilterParameters filte |
| | 189 | | { |
| 0 | 190 | | var message = _pipeline.CreateMessage(); |
| 0 | 191 | | var request = message.Request; |
| 0 | 192 | | request.Method = RequestMethod.Post; |
| 0 | 193 | | var uri = new RawRequestUriBuilder(); |
| 0 | 194 | | uri.AppendRaw(endpoint, false); |
| 0 | 195 | | uri.AppendPath("/pipelines/", false); |
| 0 | 196 | | uri.AppendPath(pipelineName, true); |
| 0 | 197 | | uri.AppendPath("/pipelineruns/", false); |
| 0 | 198 | | uri.AppendPath(runId, true); |
| 0 | 199 | | uri.AppendPath("/queryActivityruns", false); |
| 0 | 200 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 201 | | request.Uri = uri; |
| 0 | 202 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 203 | | var content = new Utf8JsonRequestContent(); |
| 0 | 204 | | content.JsonWriter.WriteObjectValue(filterParameters); |
| 0 | 205 | | request.Content = content; |
| 0 | 206 | | return message; |
| | 207 | | } |
| | 208 | |
|
| | 209 | | /// <summary> Query activity runs based on input filter conditions. </summary> |
| | 210 | | /// <param name="pipelineName"> The pipeline name. </param> |
| | 211 | | /// <param name="runId"> The pipeline run identifier. </param> |
| | 212 | | /// <param name="filterParameters"> Parameters to filter the activity runs. </param> |
| | 213 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 214 | | /// <exception cref="ArgumentNullException"> <paramref name="pipelineName"/>, <paramref name="runId"/>, or <para |
| | 215 | | public async Task<Response<ActivityRunsQueryResponse>> QueryActivityRunsAsync(string pipelineName, string runId, |
| | 216 | | { |
| 0 | 217 | | if (pipelineName == null) |
| | 218 | | { |
| 0 | 219 | | throw new ArgumentNullException(nameof(pipelineName)); |
| | 220 | | } |
| 0 | 221 | | if (runId == null) |
| | 222 | | { |
| 0 | 223 | | throw new ArgumentNullException(nameof(runId)); |
| | 224 | | } |
| 0 | 225 | | if (filterParameters == null) |
| | 226 | | { |
| 0 | 227 | | throw new ArgumentNullException(nameof(filterParameters)); |
| | 228 | | } |
| | 229 | |
|
| 0 | 230 | | using var message = CreateQueryActivityRunsRequest(pipelineName, runId, filterParameters); |
| 0 | 231 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 232 | | switch (message.Response.Status) |
| | 233 | | { |
| | 234 | | case 200: |
| | 235 | | { |
| | 236 | | ActivityRunsQueryResponse value = default; |
| 0 | 237 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 238 | | value = ActivityRunsQueryResponse.DeserializeActivityRunsQueryResponse(document.RootElement); |
| 0 | 239 | | return Response.FromValue(value, message.Response); |
| | 240 | | } |
| | 241 | | default: |
| 0 | 242 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 243 | | } |
| 0 | 244 | | } |
| | 245 | |
|
| | 246 | | /// <summary> Query activity runs based on input filter conditions. </summary> |
| | 247 | | /// <param name="pipelineName"> The pipeline name. </param> |
| | 248 | | /// <param name="runId"> The pipeline run identifier. </param> |
| | 249 | | /// <param name="filterParameters"> Parameters to filter the activity runs. </param> |
| | 250 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 251 | | /// <exception cref="ArgumentNullException"> <paramref name="pipelineName"/>, <paramref name="runId"/>, or <para |
| | 252 | | public Response<ActivityRunsQueryResponse> QueryActivityRuns(string pipelineName, string runId, RunFilterParamet |
| | 253 | | { |
| 0 | 254 | | if (pipelineName == null) |
| | 255 | | { |
| 0 | 256 | | throw new ArgumentNullException(nameof(pipelineName)); |
| | 257 | | } |
| 0 | 258 | | if (runId == null) |
| | 259 | | { |
| 0 | 260 | | throw new ArgumentNullException(nameof(runId)); |
| | 261 | | } |
| 0 | 262 | | if (filterParameters == null) |
| | 263 | | { |
| 0 | 264 | | throw new ArgumentNullException(nameof(filterParameters)); |
| | 265 | | } |
| | 266 | |
|
| 0 | 267 | | using var message = CreateQueryActivityRunsRequest(pipelineName, runId, filterParameters); |
| 0 | 268 | | _pipeline.Send(message, cancellationToken); |
| 0 | 269 | | switch (message.Response.Status) |
| | 270 | | { |
| | 271 | | case 200: |
| | 272 | | { |
| | 273 | | ActivityRunsQueryResponse value = default; |
| 0 | 274 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 275 | | value = ActivityRunsQueryResponse.DeserializeActivityRunsQueryResponse(document.RootElement); |
| 0 | 276 | | return Response.FromValue(value, message.Response); |
| | 277 | | } |
| | 278 | | default: |
| 0 | 279 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 280 | | } |
| 0 | 281 | | } |
| | 282 | |
|
| | 283 | | internal HttpMessage CreateCancelPipelineRunRequest(string runId, bool? isRecursive) |
| | 284 | | { |
| 0 | 285 | | var message = _pipeline.CreateMessage(); |
| 0 | 286 | | var request = message.Request; |
| 0 | 287 | | request.Method = RequestMethod.Post; |
| 0 | 288 | | var uri = new RawRequestUriBuilder(); |
| 0 | 289 | | uri.AppendRaw(endpoint, false); |
| 0 | 290 | | uri.AppendPath("/pipelineruns/", false); |
| 0 | 291 | | uri.AppendPath(runId, true); |
| 0 | 292 | | uri.AppendPath("/cancel", false); |
| 0 | 293 | | if (isRecursive != null) |
| | 294 | | { |
| 0 | 295 | | uri.AppendQuery("isRecursive", isRecursive.Value, true); |
| | 296 | | } |
| 0 | 297 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 298 | | request.Uri = uri; |
| 0 | 299 | | return message; |
| | 300 | | } |
| | 301 | |
|
| | 302 | | /// <summary> Cancel a pipeline run by its run ID. </summary> |
| | 303 | | /// <param name="runId"> The pipeline run identifier. </param> |
| | 304 | | /// <param name="isRecursive"> If true, cancel all the Child pipelines that are triggered by the current pipelin |
| | 305 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 306 | | /// <exception cref="ArgumentNullException"> <paramref name="runId"/> is null. </exception> |
| | 307 | | public async Task<Response> CancelPipelineRunAsync(string runId, bool? isRecursive = null, CancellationToken can |
| | 308 | | { |
| 0 | 309 | | if (runId == null) |
| | 310 | | { |
| 0 | 311 | | throw new ArgumentNullException(nameof(runId)); |
| | 312 | | } |
| | 313 | |
|
| 0 | 314 | | using var message = CreateCancelPipelineRunRequest(runId, isRecursive); |
| 0 | 315 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 316 | | switch (message.Response.Status) |
| | 317 | | { |
| | 318 | | case 200: |
| 0 | 319 | | return message.Response; |
| | 320 | | default: |
| 0 | 321 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 322 | | } |
| 0 | 323 | | } |
| | 324 | |
|
| | 325 | | /// <summary> Cancel a pipeline run by its run ID. </summary> |
| | 326 | | /// <param name="runId"> The pipeline run identifier. </param> |
| | 327 | | /// <param name="isRecursive"> If true, cancel all the Child pipelines that are triggered by the current pipelin |
| | 328 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 329 | | /// <exception cref="ArgumentNullException"> <paramref name="runId"/> is null. </exception> |
| | 330 | | public Response CancelPipelineRun(string runId, bool? isRecursive = null, CancellationToken cancellationToken = |
| | 331 | | { |
| 0 | 332 | | if (runId == null) |
| | 333 | | { |
| 0 | 334 | | throw new ArgumentNullException(nameof(runId)); |
| | 335 | | } |
| | 336 | |
|
| 0 | 337 | | using var message = CreateCancelPipelineRunRequest(runId, isRecursive); |
| 0 | 338 | | _pipeline.Send(message, cancellationToken); |
| 0 | 339 | | switch (message.Response.Status) |
| | 340 | | { |
| | 341 | | case 200: |
| 0 | 342 | | return message.Response; |
| | 343 | | default: |
| 0 | 344 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 345 | | } |
| 0 | 346 | | } |
| | 347 | | } |
| | 348 | | } |