| | 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.Threading; |
| | 10 | | using System.Threading.Tasks; |
| | 11 | | using Azure; |
| | 12 | | using Azure.Analytics.Synapse.Spark.Models; |
| | 13 | | using Azure.Core.Pipeline; |
| | 14 | |
|
| | 15 | | namespace Azure.Analytics.Synapse.Spark |
| 0 | 16 | | { |
| | 17 | | /// <summary> The SparkBatch service client. </summary> |
| 0 | 18 | | public partial class SparkBatchClient |
| | 19 | | { |
| | 20 | | private readonly ClientDiagnostics _clientDiagnostics; |
| | 21 | | private readonly HttpPipeline _pipeline; |
| 84 | 22 | | internal SparkBatchRestClient RestClient { get; } |
| | 23 | | /// <summary> Initializes a new instance of SparkBatchClient for mocking. </summary> |
| 12 | 24 | | protected SparkBatchClient() |
| 4 | 25 | | { |
| 12 | 26 | | } |
| 4 | 27 | | /// <summary> Initializes a new instance of SparkBatchClient. </summary> |
| 4 | 28 | | /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param> |
| | 29 | | /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param> |
| 4 | 30 | | /// <param name="endpoint"> The workspace development endpoint, for example https://myworkspace.dev.azuresynapse |
| | 31 | | /// <param name="sparkPoolName"> Name of the spark pool. </param> |
| | 32 | | /// <param name="livyApiVersion"> Valid api-version for the request. </param> |
| 8 | 33 | | internal SparkBatchClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string endpoint, string sp |
| | 34 | | { |
| 8 | 35 | | RestClient = new SparkBatchRestClient(clientDiagnostics, pipeline, endpoint, sparkPoolName, livyApiVersion); |
| 8 | 36 | | _clientDiagnostics = clientDiagnostics; |
| 8 | 37 | | _pipeline = pipeline; |
| 8 | 38 | | } |
| | 39 | |
|
| | 40 | | /// <summary> List all spark batch jobs which are running under a particular spark pool. </summary> |
| | 41 | | /// <param name="from"> Optional param specifying which index the list should begin from. </param> |
| | 42 | | /// <param name="size"> |
| | 43 | | /// Optional param specifying the size of the returned list. |
| | 44 | | /// |
| | 45 | | /// By default it is 20 and that is the maximum. |
| | 46 | | /// </param> |
| | 47 | | /// <param name="detailed"> Optional query param specifying whether detailed response is returned beyond plain l |
| | 48 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 49 | | public virtual async Task<Response<SparkBatchJobCollection>> GetSparkBatchJobsAsync(int? @from = null, int? size |
| | 50 | | { |
| 2 | 51 | | using var scope = _clientDiagnostics.CreateScope("SparkBatchClient.GetSparkBatchJobs"); |
| 2 | 52 | | scope.Start(); |
| | 53 | | try |
| | 54 | | { |
| 2 | 55 | | return await RestClient.GetSparkBatchJobsAsync(@from, size, detailed, cancellationToken).ConfigureAwait( |
| | 56 | | } |
| 0 | 57 | | catch (Exception e) |
| | 58 | | { |
| 0 | 59 | | scope.Failed(e); |
| 0 | 60 | | throw; |
| | 61 | | } |
| 2 | 62 | | } |
| | 63 | |
|
| | 64 | | /// <summary> List all spark batch jobs which are running under a particular spark pool. </summary> |
| | 65 | | /// <param name="from"> Optional param specifying which index the list should begin from. </param> |
| | 66 | | /// <param name="size"> |
| | 67 | | /// Optional param specifying the size of the returned list. |
| | 68 | | /// |
| | 69 | | /// By default it is 20 and that is the maximum. |
| | 70 | | /// </param> |
| | 71 | | /// <param name="detailed"> Optional query param specifying whether detailed response is returned beyond plain l |
| | 72 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 73 | | public virtual Response<SparkBatchJobCollection> GetSparkBatchJobs(int? @from = null, int? size = null, bool? de |
| | 74 | | { |
| 2 | 75 | | using var scope = _clientDiagnostics.CreateScope("SparkBatchClient.GetSparkBatchJobs"); |
| 2 | 76 | | scope.Start(); |
| | 77 | | try |
| | 78 | | { |
| 2 | 79 | | return RestClient.GetSparkBatchJobs(@from, size, detailed, cancellationToken); |
| | 80 | | } |
| 0 | 81 | | catch (Exception e) |
| | 82 | | { |
| 0 | 83 | | scope.Failed(e); |
| 0 | 84 | | throw; |
| | 85 | | } |
| 2 | 86 | | } |
| | 87 | |
|
| | 88 | | /// <summary> Create new spark batch job. </summary> |
| | 89 | | /// <param name="sparkBatchJobOptions"> Livy compatible batch job request payload. </param> |
| | 90 | | /// <param name="detailed"> Optional query param specifying whether detailed response is returned beyond plain l |
| | 91 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 92 | | public virtual async Task<Response<SparkBatchJob>> CreateSparkBatchJobAsync(SparkBatchJobOptions sparkBatchJobOp |
| | 93 | | { |
| 0 | 94 | | using var scope = _clientDiagnostics.CreateScope("SparkBatchClient.CreateSparkBatchJob"); |
| 0 | 95 | | scope.Start(); |
| | 96 | | try |
| | 97 | | { |
| 0 | 98 | | return await RestClient.CreateSparkBatchJobAsync(sparkBatchJobOptions, detailed, cancellationToken).Conf |
| | 99 | | } |
| 0 | 100 | | catch (Exception e) |
| | 101 | | { |
| 0 | 102 | | scope.Failed(e); |
| 0 | 103 | | throw; |
| | 104 | | } |
| 0 | 105 | | } |
| | 106 | |
|
| | 107 | | /// <summary> Create new spark batch job. </summary> |
| | 108 | | /// <param name="sparkBatchJobOptions"> Livy compatible batch job request payload. </param> |
| | 109 | | /// <param name="detailed"> Optional query param specifying whether detailed response is returned beyond plain l |
| | 110 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 111 | | public virtual Response<SparkBatchJob> CreateSparkBatchJob(SparkBatchJobOptions sparkBatchJobOptions, bool? deta |
| | 112 | | { |
| 0 | 113 | | using var scope = _clientDiagnostics.CreateScope("SparkBatchClient.CreateSparkBatchJob"); |
| 0 | 114 | | scope.Start(); |
| | 115 | | try |
| | 116 | | { |
| 0 | 117 | | return RestClient.CreateSparkBatchJob(sparkBatchJobOptions, detailed, cancellationToken); |
| | 118 | | } |
| 0 | 119 | | catch (Exception e) |
| | 120 | | { |
| 0 | 121 | | scope.Failed(e); |
| 0 | 122 | | throw; |
| | 123 | | } |
| 0 | 124 | | } |
| | 125 | |
|
| | 126 | | /// <summary> Gets a single spark batch job. </summary> |
| | 127 | | /// <param name="batchId"> Identifier for the batch job. </param> |
| | 128 | | /// <param name="detailed"> Optional query param specifying whether detailed response is returned beyond plain l |
| | 129 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 130 | | public virtual async Task<Response<SparkBatchJob>> GetSparkBatchJobAsync(int batchId, bool? detailed = null, Can |
| | 131 | | { |
| 40 | 132 | | using var scope = _clientDiagnostics.CreateScope("SparkBatchClient.GetSparkBatchJob"); |
| 40 | 133 | | scope.Start(); |
| | 134 | | try |
| | 135 | | { |
| 40 | 136 | | return await RestClient.GetSparkBatchJobAsync(batchId, detailed, cancellationToken).ConfigureAwait(false |
| | 137 | | } |
| 0 | 138 | | catch (Exception e) |
| | 139 | | { |
| 0 | 140 | | scope.Failed(e); |
| 0 | 141 | | throw; |
| | 142 | | } |
| 40 | 143 | | } |
| | 144 | |
|
| | 145 | | /// <summary> Gets a single spark batch job. </summary> |
| | 146 | | /// <param name="batchId"> Identifier for the batch job. </param> |
| | 147 | | /// <param name="detailed"> Optional query param specifying whether detailed response is returned beyond plain l |
| | 148 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 149 | | public virtual Response<SparkBatchJob> GetSparkBatchJob(int batchId, bool? detailed = null, CancellationToken ca |
| | 150 | | { |
| 40 | 151 | | using var scope = _clientDiagnostics.CreateScope("SparkBatchClient.GetSparkBatchJob"); |
| 40 | 152 | | scope.Start(); |
| | 153 | | try |
| | 154 | | { |
| 40 | 155 | | return RestClient.GetSparkBatchJob(batchId, detailed, cancellationToken); |
| | 156 | | } |
| 0 | 157 | | catch (Exception e) |
| | 158 | | { |
| 0 | 159 | | scope.Failed(e); |
| 0 | 160 | | throw; |
| | 161 | | } |
| 40 | 162 | | } |
| | 163 | |
|
| | 164 | | /// <summary> Cancels a running spark batch job. </summary> |
| | 165 | | /// <param name="batchId"> Identifier for the batch job. </param> |
| | 166 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 167 | | public virtual async Task<Response> CancelSparkBatchJobAsync(int batchId, CancellationToken cancellationToken = |
| | 168 | | { |
| 0 | 169 | | using var scope = _clientDiagnostics.CreateScope("SparkBatchClient.CancelSparkBatchJob"); |
| 0 | 170 | | scope.Start(); |
| | 171 | | try |
| | 172 | | { |
| 0 | 173 | | return await RestClient.CancelSparkBatchJobAsync(batchId, cancellationToken).ConfigureAwait(false); |
| | 174 | | } |
| 0 | 175 | | catch (Exception e) |
| | 176 | | { |
| 0 | 177 | | scope.Failed(e); |
| 0 | 178 | | throw; |
| | 179 | | } |
| 0 | 180 | | } |
| | 181 | |
|
| | 182 | | /// <summary> Cancels a running spark batch job. </summary> |
| | 183 | | /// <param name="batchId"> Identifier for the batch job. </param> |
| | 184 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 185 | | public virtual Response CancelSparkBatchJob(int batchId, CancellationToken cancellationToken = default) |
| | 186 | | { |
| 0 | 187 | | using var scope = _clientDiagnostics.CreateScope("SparkBatchClient.CancelSparkBatchJob"); |
| 0 | 188 | | scope.Start(); |
| | 189 | | try |
| | 190 | | { |
| 0 | 191 | | return RestClient.CancelSparkBatchJob(batchId, cancellationToken); |
| | 192 | | } |
| 0 | 193 | | catch (Exception e) |
| | 194 | | { |
| 0 | 195 | | scope.Failed(e); |
| 0 | 196 | | throw; |
| | 197 | | } |
| 0 | 198 | | } |
| | 199 | | } |
| | 200 | | } |