| | 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 SparkSession service client. </summary> |
| 0 | 18 | | public partial class SparkSessionClient |
| | 19 | | { |
| | 20 | | private readonly ClientDiagnostics _clientDiagnostics; |
| | 21 | | private readonly HttpPipeline _pipeline; |
| 84 | 22 | | internal SparkSessionRestClient RestClient { get; } |
| | 23 | | /// <summary> Initializes a new instance of SparkSessionClient for mocking. </summary> |
| 12 | 24 | | protected SparkSessionClient() |
| 4 | 25 | | { |
| 12 | 26 | | } |
| 4 | 27 | | /// <summary> Initializes a new instance of SparkSessionClient. </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 SparkSessionClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string endpoint, string |
| | 34 | | { |
| 8 | 35 | | RestClient = new SparkSessionRestClient(clientDiagnostics, pipeline, endpoint, sparkPoolName, livyApiVersion |
| 8 | 36 | | _clientDiagnostics = clientDiagnostics; |
| 8 | 37 | | _pipeline = pipeline; |
| 8 | 38 | | } |
| | 39 | |
|
| | 40 | | /// <summary> List all spark sessions 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<SparkSessionCollection>> GetSparkSessionsAsync(int? @from = null, int? size = |
| | 50 | | { |
| 2 | 51 | | using var scope = _clientDiagnostics.CreateScope("SparkSessionClient.GetSparkSessions"); |
| 2 | 52 | | scope.Start(); |
| | 53 | | try |
| | 54 | | { |
| 2 | 55 | | return await RestClient.GetSparkSessionsAsync(@from, size, detailed, cancellationToken).ConfigureAwait(f |
| | 56 | | } |
| 0 | 57 | | catch (Exception e) |
| | 58 | | { |
| 0 | 59 | | scope.Failed(e); |
| 0 | 60 | | throw; |
| | 61 | | } |
| 2 | 62 | | } |
| | 63 | |
|
| | 64 | | /// <summary> List all spark sessions 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<SparkSessionCollection> GetSparkSessions(int? @from = null, int? size = null, bool? deta |
| | 74 | | { |
| 2 | 75 | | using var scope = _clientDiagnostics.CreateScope("SparkSessionClient.GetSparkSessions"); |
| 2 | 76 | | scope.Start(); |
| | 77 | | try |
| | 78 | | { |
| 2 | 79 | | return RestClient.GetSparkSessions(@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 session. </summary> |
| | 89 | | /// <param name="sparkSessionOptions"> 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<SparkSession>> CreateSparkSessionAsync(SparkSessionOptions sparkSessionOption |
| | 93 | | { |
| 0 | 94 | | using var scope = _clientDiagnostics.CreateScope("SparkSessionClient.CreateSparkSession"); |
| 0 | 95 | | scope.Start(); |
| | 96 | | try |
| | 97 | | { |
| 0 | 98 | | return await RestClient.CreateSparkSessionAsync(sparkSessionOptions, detailed, cancellationToken).Config |
| | 99 | | } |
| 0 | 100 | | catch (Exception e) |
| | 101 | | { |
| 0 | 102 | | scope.Failed(e); |
| 0 | 103 | | throw; |
| | 104 | | } |
| 0 | 105 | | } |
| | 106 | |
|
| | 107 | | /// <summary> Create new spark session. </summary> |
| | 108 | | /// <param name="sparkSessionOptions"> 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<SparkSession> CreateSparkSession(SparkSessionOptions sparkSessionOptions, bool? detailed |
| | 112 | | { |
| 0 | 113 | | using var scope = _clientDiagnostics.CreateScope("SparkSessionClient.CreateSparkSession"); |
| 0 | 114 | | scope.Start(); |
| | 115 | | try |
| | 116 | | { |
| 0 | 117 | | return RestClient.CreateSparkSession(sparkSessionOptions, 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 session. </summary> |
| | 127 | | /// <param name="sessionId"> Identifier for the session. </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<SparkSession>> GetSparkSessionAsync(int sessionId, bool? detailed = null, Can |
| | 131 | | { |
| 40 | 132 | | using var scope = _clientDiagnostics.CreateScope("SparkSessionClient.GetSparkSession"); |
| 40 | 133 | | scope.Start(); |
| | 134 | | try |
| | 135 | | { |
| 40 | 136 | | return await RestClient.GetSparkSessionAsync(sessionId, detailed, cancellationToken).ConfigureAwait(fals |
| | 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 session. </summary> |
| | 146 | | /// <param name="sessionId"> Identifier for the session. </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<SparkSession> GetSparkSession(int sessionId, bool? detailed = null, CancellationToken ca |
| | 150 | | { |
| 40 | 151 | | using var scope = _clientDiagnostics.CreateScope("SparkSessionClient.GetSparkSession"); |
| 40 | 152 | | scope.Start(); |
| | 153 | | try |
| | 154 | | { |
| 40 | 155 | | return RestClient.GetSparkSession(sessionId, 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 session. </summary> |
| | 165 | | /// <param name="sessionId"> Identifier for the session. </param> |
| | 166 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 167 | | public virtual async Task<Response> CancelSparkSessionAsync(int sessionId, CancellationToken cancellationToken = |
| | 168 | | { |
| 0 | 169 | | using var scope = _clientDiagnostics.CreateScope("SparkSessionClient.CancelSparkSession"); |
| 0 | 170 | | scope.Start(); |
| | 171 | | try |
| | 172 | | { |
| 0 | 173 | | return await RestClient.CancelSparkSessionAsync(sessionId, 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 session. </summary> |
| | 183 | | /// <param name="sessionId"> Identifier for the session. </param> |
| | 184 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 185 | | public virtual Response CancelSparkSession(int sessionId, CancellationToken cancellationToken = default) |
| | 186 | | { |
| 0 | 187 | | using var scope = _clientDiagnostics.CreateScope("SparkSessionClient.CancelSparkSession"); |
| 0 | 188 | | scope.Start(); |
| | 189 | | try |
| | 190 | | { |
| 0 | 191 | | return RestClient.CancelSparkSession(sessionId, cancellationToken); |
| | 192 | | } |
| 0 | 193 | | catch (Exception e) |
| | 194 | | { |
| 0 | 195 | | scope.Failed(e); |
| 0 | 196 | | throw; |
| | 197 | | } |
| 0 | 198 | | } |
| | 199 | |
|
| | 200 | | /// <summary> Sends a keep alive call to the current session to reset the session timeout. </summary> |
| | 201 | | /// <param name="sessionId"> Identifier for the session. </param> |
| | 202 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 203 | | public virtual async Task<Response> ResetSparkSessionTimeoutAsync(int sessionId, CancellationToken cancellationT |
| | 204 | | { |
| 0 | 205 | | using var scope = _clientDiagnostics.CreateScope("SparkSessionClient.ResetSparkSessionTimeout"); |
| 0 | 206 | | scope.Start(); |
| | 207 | | try |
| | 208 | | { |
| 0 | 209 | | return await RestClient.ResetSparkSessionTimeoutAsync(sessionId, cancellationToken).ConfigureAwait(false |
| | 210 | | } |
| 0 | 211 | | catch (Exception e) |
| | 212 | | { |
| 0 | 213 | | scope.Failed(e); |
| 0 | 214 | | throw; |
| | 215 | | } |
| 0 | 216 | | } |
| | 217 | |
|
| | 218 | | /// <summary> Sends a keep alive call to the current session to reset the session timeout. </summary> |
| | 219 | | /// <param name="sessionId"> Identifier for the session. </param> |
| | 220 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 221 | | public virtual Response ResetSparkSessionTimeout(int sessionId, CancellationToken cancellationToken = default) |
| | 222 | | { |
| 0 | 223 | | using var scope = _clientDiagnostics.CreateScope("SparkSessionClient.ResetSparkSessionTimeout"); |
| 0 | 224 | | scope.Start(); |
| | 225 | | try |
| | 226 | | { |
| 0 | 227 | | return RestClient.ResetSparkSessionTimeout(sessionId, cancellationToken); |
| | 228 | | } |
| 0 | 229 | | catch (Exception e) |
| | 230 | | { |
| 0 | 231 | | scope.Failed(e); |
| 0 | 232 | | throw; |
| | 233 | | } |
| 0 | 234 | | } |
| | 235 | |
|
| | 236 | | /// <summary> Gets a list of statements within a spark session. </summary> |
| | 237 | | /// <param name="sessionId"> Identifier for the session. </param> |
| | 238 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 239 | | public virtual async Task<Response<SparkStatementCollection>> GetSparkStatementsAsync(int sessionId, Cancellatio |
| | 240 | | { |
| 0 | 241 | | using var scope = _clientDiagnostics.CreateScope("SparkSessionClient.GetSparkStatements"); |
| 0 | 242 | | scope.Start(); |
| | 243 | | try |
| | 244 | | { |
| 0 | 245 | | return await RestClient.GetSparkStatementsAsync(sessionId, cancellationToken).ConfigureAwait(false); |
| | 246 | | } |
| 0 | 247 | | catch (Exception e) |
| | 248 | | { |
| 0 | 249 | | scope.Failed(e); |
| 0 | 250 | | throw; |
| | 251 | | } |
| 0 | 252 | | } |
| | 253 | |
|
| | 254 | | /// <summary> Gets a list of statements within a spark session. </summary> |
| | 255 | | /// <param name="sessionId"> Identifier for the session. </param> |
| | 256 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 257 | | public virtual Response<SparkStatementCollection> GetSparkStatements(int sessionId, CancellationToken cancellati |
| | 258 | | { |
| 0 | 259 | | using var scope = _clientDiagnostics.CreateScope("SparkSessionClient.GetSparkStatements"); |
| 0 | 260 | | scope.Start(); |
| | 261 | | try |
| | 262 | | { |
| 0 | 263 | | return RestClient.GetSparkStatements(sessionId, cancellationToken); |
| | 264 | | } |
| 0 | 265 | | catch (Exception e) |
| | 266 | | { |
| 0 | 267 | | scope.Failed(e); |
| 0 | 268 | | throw; |
| | 269 | | } |
| 0 | 270 | | } |
| | 271 | |
|
| | 272 | | /// <summary> Create statement within a spark session. </summary> |
| | 273 | | /// <param name="sessionId"> Identifier for the session. </param> |
| | 274 | | /// <param name="sparkStatementOptions"> Livy compatible batch job request payload. </param> |
| | 275 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 276 | | public virtual async Task<Response<SparkStatement>> CreateSparkStatementAsync(int sessionId, SparkStatementOptio |
| | 277 | | { |
| 0 | 278 | | using var scope = _clientDiagnostics.CreateScope("SparkSessionClient.CreateSparkStatement"); |
| 0 | 279 | | scope.Start(); |
| | 280 | | try |
| | 281 | | { |
| 0 | 282 | | return await RestClient.CreateSparkStatementAsync(sessionId, sparkStatementOptions, cancellationToken).C |
| | 283 | | } |
| 0 | 284 | | catch (Exception e) |
| | 285 | | { |
| 0 | 286 | | scope.Failed(e); |
| 0 | 287 | | throw; |
| | 288 | | } |
| 0 | 289 | | } |
| | 290 | |
|
| | 291 | | /// <summary> Create statement within a spark session. </summary> |
| | 292 | | /// <param name="sessionId"> Identifier for the session. </param> |
| | 293 | | /// <param name="sparkStatementOptions"> Livy compatible batch job request payload. </param> |
| | 294 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 295 | | public virtual Response<SparkStatement> CreateSparkStatement(int sessionId, SparkStatementOptions sparkStatement |
| | 296 | | { |
| 0 | 297 | | using var scope = _clientDiagnostics.CreateScope("SparkSessionClient.CreateSparkStatement"); |
| 0 | 298 | | scope.Start(); |
| | 299 | | try |
| | 300 | | { |
| 0 | 301 | | return RestClient.CreateSparkStatement(sessionId, sparkStatementOptions, cancellationToken); |
| | 302 | | } |
| 0 | 303 | | catch (Exception e) |
| | 304 | | { |
| 0 | 305 | | scope.Failed(e); |
| 0 | 306 | | throw; |
| | 307 | | } |
| 0 | 308 | | } |
| | 309 | |
|
| | 310 | | /// <summary> Gets a single statement within a spark session. </summary> |
| | 311 | | /// <param name="sessionId"> Identifier for the session. </param> |
| | 312 | | /// <param name="statementId"> Identifier for the statement. </param> |
| | 313 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 314 | | public virtual async Task<Response<SparkStatement>> GetSparkStatementAsync(int sessionId, int statementId, Cance |
| | 315 | | { |
| 0 | 316 | | using var scope = _clientDiagnostics.CreateScope("SparkSessionClient.GetSparkStatement"); |
| 0 | 317 | | scope.Start(); |
| | 318 | | try |
| | 319 | | { |
| 0 | 320 | | return await RestClient.GetSparkStatementAsync(sessionId, statementId, cancellationToken).ConfigureAwait |
| | 321 | | } |
| 0 | 322 | | catch (Exception e) |
| | 323 | | { |
| 0 | 324 | | scope.Failed(e); |
| 0 | 325 | | throw; |
| | 326 | | } |
| 0 | 327 | | } |
| | 328 | |
|
| | 329 | | /// <summary> Gets a single statement within a spark session. </summary> |
| | 330 | | /// <param name="sessionId"> Identifier for the session. </param> |
| | 331 | | /// <param name="statementId"> Identifier for the statement. </param> |
| | 332 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 333 | | public virtual Response<SparkStatement> GetSparkStatement(int sessionId, int statementId, CancellationToken canc |
| | 334 | | { |
| 0 | 335 | | using var scope = _clientDiagnostics.CreateScope("SparkSessionClient.GetSparkStatement"); |
| 0 | 336 | | scope.Start(); |
| | 337 | | try |
| | 338 | | { |
| 0 | 339 | | return RestClient.GetSparkStatement(sessionId, statementId, cancellationToken); |
| | 340 | | } |
| 0 | 341 | | catch (Exception e) |
| | 342 | | { |
| 0 | 343 | | scope.Failed(e); |
| 0 | 344 | | throw; |
| | 345 | | } |
| 0 | 346 | | } |
| | 347 | |
|
| | 348 | | /// <summary> Kill a statement within a session. </summary> |
| | 349 | | /// <param name="sessionId"> Identifier for the session. </param> |
| | 350 | | /// <param name="statementId"> Identifier for the statement. </param> |
| | 351 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 352 | | public virtual async Task<Response<SparkStatementCancellationResult>> CancelSparkStatementAsync(int sessionId, i |
| | 353 | | { |
| 0 | 354 | | using var scope = _clientDiagnostics.CreateScope("SparkSessionClient.CancelSparkStatement"); |
| 0 | 355 | | scope.Start(); |
| | 356 | | try |
| | 357 | | { |
| 0 | 358 | | return await RestClient.CancelSparkStatementAsync(sessionId, statementId, cancellationToken).ConfigureAw |
| | 359 | | } |
| 0 | 360 | | catch (Exception e) |
| | 361 | | { |
| 0 | 362 | | scope.Failed(e); |
| 0 | 363 | | throw; |
| | 364 | | } |
| 0 | 365 | | } |
| | 366 | |
|
| | 367 | | /// <summary> Kill a statement within a session. </summary> |
| | 368 | | /// <param name="sessionId"> Identifier for the session. </param> |
| | 369 | | /// <param name="statementId"> Identifier for the statement. </param> |
| | 370 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 371 | | public virtual Response<SparkStatementCancellationResult> CancelSparkStatement(int sessionId, int statementId, C |
| | 372 | | { |
| 0 | 373 | | using var scope = _clientDiagnostics.CreateScope("SparkSessionClient.CancelSparkStatement"); |
| 0 | 374 | | scope.Start(); |
| | 375 | | try |
| | 376 | | { |
| 0 | 377 | | return RestClient.CancelSparkStatement(sessionId, statementId, cancellationToken); |
| | 378 | | } |
| 0 | 379 | | catch (Exception e) |
| | 380 | | { |
| 0 | 381 | | scope.Failed(e); |
| 0 | 382 | | throw; |
| | 383 | | } |
| 0 | 384 | | } |
| | 385 | | } |
| | 386 | | } |