| | 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 TriggerRunRestClient |
| | 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 TriggerRunRestClient. </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 TriggerRunRestClient(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 CreateRerunTriggerInstanceRequest(string triggerName, string runId) |
| | 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("/triggers/", false); |
| 0 | 57 | | uri.AppendPath(triggerName, true); |
| 0 | 58 | | uri.AppendPath("/triggerRuns/", false); |
| 0 | 59 | | uri.AppendPath(runId, true); |
| 0 | 60 | | uri.AppendPath("/rerun", false); |
| 0 | 61 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 62 | | request.Uri = uri; |
| 0 | 63 | | return message; |
| | 64 | | } |
| | 65 | |
|
| | 66 | | /// <summary> Rerun single trigger instance by runId. </summary> |
| | 67 | | /// <param name="triggerName"> The trigger name. </param> |
| | 68 | | /// <param name="runId"> The pipeline run identifier. </param> |
| | 69 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 70 | | /// <exception cref="ArgumentNullException"> <paramref name="triggerName"/> or <paramref name="runId"/> is null. |
| | 71 | | public async Task<Response> RerunTriggerInstanceAsync(string triggerName, string runId, CancellationToken cancel |
| | 72 | | { |
| 0 | 73 | | if (triggerName == null) |
| | 74 | | { |
| 0 | 75 | | throw new ArgumentNullException(nameof(triggerName)); |
| | 76 | | } |
| 0 | 77 | | if (runId == null) |
| | 78 | | { |
| 0 | 79 | | throw new ArgumentNullException(nameof(runId)); |
| | 80 | | } |
| | 81 | |
|
| 0 | 82 | | using var message = CreateRerunTriggerInstanceRequest(triggerName, runId); |
| 0 | 83 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 84 | | switch (message.Response.Status) |
| | 85 | | { |
| | 86 | | case 200: |
| 0 | 87 | | return message.Response; |
| | 88 | | default: |
| 0 | 89 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 90 | | } |
| 0 | 91 | | } |
| | 92 | |
|
| | 93 | | /// <summary> Rerun single trigger instance by runId. </summary> |
| | 94 | | /// <param name="triggerName"> The trigger name. </param> |
| | 95 | | /// <param name="runId"> The pipeline run identifier. </param> |
| | 96 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 97 | | /// <exception cref="ArgumentNullException"> <paramref name="triggerName"/> or <paramref name="runId"/> is null. |
| | 98 | | public Response RerunTriggerInstance(string triggerName, string runId, CancellationToken cancellationToken = def |
| | 99 | | { |
| 0 | 100 | | if (triggerName == null) |
| | 101 | | { |
| 0 | 102 | | throw new ArgumentNullException(nameof(triggerName)); |
| | 103 | | } |
| 0 | 104 | | if (runId == null) |
| | 105 | | { |
| 0 | 106 | | throw new ArgumentNullException(nameof(runId)); |
| | 107 | | } |
| | 108 | |
|
| 0 | 109 | | using var message = CreateRerunTriggerInstanceRequest(triggerName, runId); |
| 0 | 110 | | _pipeline.Send(message, cancellationToken); |
| 0 | 111 | | switch (message.Response.Status) |
| | 112 | | { |
| | 113 | | case 200: |
| 0 | 114 | | return message.Response; |
| | 115 | | default: |
| 0 | 116 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 117 | | } |
| 0 | 118 | | } |
| | 119 | |
|
| | 120 | | internal HttpMessage CreateQueryTriggerRunsByWorkspaceRequest(RunFilterParameters filterParameters) |
| | 121 | | { |
| 0 | 122 | | var message = _pipeline.CreateMessage(); |
| 0 | 123 | | var request = message.Request; |
| 0 | 124 | | request.Method = RequestMethod.Post; |
| 0 | 125 | | var uri = new RawRequestUriBuilder(); |
| 0 | 126 | | uri.AppendRaw(endpoint, false); |
| 0 | 127 | | uri.AppendPath("/queryTriggerRuns", false); |
| 0 | 128 | | uri.AppendQuery("api-version", apiVersion, true); |
| 0 | 129 | | request.Uri = uri; |
| 0 | 130 | | request.Headers.Add("Content-Type", "application/json"); |
| 0 | 131 | | var content = new Utf8JsonRequestContent(); |
| 0 | 132 | | content.JsonWriter.WriteObjectValue(filterParameters); |
| 0 | 133 | | request.Content = content; |
| 0 | 134 | | return message; |
| | 135 | | } |
| | 136 | |
|
| | 137 | | /// <summary> Query trigger runs. </summary> |
| | 138 | | /// <param name="filterParameters"> Parameters to filter the pipeline run. </param> |
| | 139 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 140 | | /// <exception cref="ArgumentNullException"> <paramref name="filterParameters"/> is null. </exception> |
| | 141 | | public async Task<Response<TriggerRunsQueryResponse>> QueryTriggerRunsByWorkspaceAsync(RunFilterParameters filte |
| | 142 | | { |
| 0 | 143 | | if (filterParameters == null) |
| | 144 | | { |
| 0 | 145 | | throw new ArgumentNullException(nameof(filterParameters)); |
| | 146 | | } |
| | 147 | |
|
| 0 | 148 | | using var message = CreateQueryTriggerRunsByWorkspaceRequest(filterParameters); |
| 0 | 149 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 0 | 150 | | switch (message.Response.Status) |
| | 151 | | { |
| | 152 | | case 200: |
| | 153 | | { |
| | 154 | | TriggerRunsQueryResponse value = default; |
| 0 | 155 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 0 | 156 | | value = TriggerRunsQueryResponse.DeserializeTriggerRunsQueryResponse(document.RootElement); |
| 0 | 157 | | return Response.FromValue(value, message.Response); |
| | 158 | | } |
| | 159 | | default: |
| 0 | 160 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 161 | | } |
| 0 | 162 | | } |
| | 163 | |
|
| | 164 | | /// <summary> Query trigger runs. </summary> |
| | 165 | | /// <param name="filterParameters"> Parameters to filter the pipeline run. </param> |
| | 166 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 167 | | /// <exception cref="ArgumentNullException"> <paramref name="filterParameters"/> is null. </exception> |
| | 168 | | public Response<TriggerRunsQueryResponse> QueryTriggerRunsByWorkspace(RunFilterParameters filterParameters, Canc |
| | 169 | | { |
| 0 | 170 | | if (filterParameters == null) |
| | 171 | | { |
| 0 | 172 | | throw new ArgumentNullException(nameof(filterParameters)); |
| | 173 | | } |
| | 174 | |
|
| 0 | 175 | | using var message = CreateQueryTriggerRunsByWorkspaceRequest(filterParameters); |
| 0 | 176 | | _pipeline.Send(message, cancellationToken); |
| 0 | 177 | | switch (message.Response.Status) |
| | 178 | | { |
| | 179 | | case 200: |
| | 180 | | { |
| | 181 | | TriggerRunsQueryResponse value = default; |
| 0 | 182 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 0 | 183 | | value = TriggerRunsQueryResponse.DeserializeTriggerRunsQueryResponse(document.RootElement); |
| 0 | 184 | | return Response.FromValue(value, message.Response); |
| | 185 | | } |
| | 186 | | default: |
| 0 | 187 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 188 | | } |
| 0 | 189 | | } |
| | 190 | | } |
| | 191 | | } |