< Summary

Class:Azure.Analytics.Synapse.Spark.SparkSessionClient
Assembly:Azure.Analytics.Synapse.Spark
File(s):C:\Git\azure-sdk-for-net\sdk\synapse\Azure.Analytics.Synapse.Spark\src\Customization\SparkSessionClient.cs
C:\Git\azure-sdk-for-net\sdk\synapse\Azure.Analytics.Synapse.Spark\src\Generated\SparkSessionClient.cs
Covered lines:34
Uncovered lines:114
Coverable lines:148
Total lines:418
Line coverage:22.9% (34 of 148)
Covered branches:0
Total branches:0

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%100%
.ctor(...)-100%100%
.ctor(...)-0%100%
get_RestClient()-100%100%
.ctor()-100%100%
.ctor(...)-100%100%
.ctor(...)-100%100%
GetSparkSessionsAsync()-57.14%100%
GetSparkSessions(...)-57.14%100%
CreateSparkSessionAsync()-0%100%
CreateSparkSession(...)-0%100%
GetSparkSessionAsync()-57.14%100%
GetSparkSession(...)-57.14%100%
CancelSparkSessionAsync()-0%100%
CancelSparkSession(...)-0%100%
ResetSparkSessionTimeoutAsync()-0%100%
ResetSparkSessionTimeout(...)-0%100%
GetSparkStatementsAsync()-0%100%
GetSparkStatements(...)-0%100%
CreateSparkStatementAsync()-0%100%
CreateSparkStatement(...)-0%100%
GetSparkStatementAsync()-0%100%
GetSparkStatement(...)-0%100%
CancelSparkStatementAsync()-0%100%
CancelSparkStatement(...)-0%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\synapse\Azure.Analytics.Synapse.Spark\src\Customization\SparkSessionClient.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using Azure.Core;
 6using Azure.Core.Pipeline;
 7
 8namespace Azure.Analytics.Synapse.Spark
 9{
 10    public partial class SparkSessionClient
 11    {
 12        /// <summary>
 13        /// Initializes a new instance of the <see cref="SparkSessionClient"/>.
 14        /// </summary>
 15        public SparkSessionClient(Uri endpoint, string sparkPoolName, TokenCredential credential)
 016            : this(endpoint, sparkPoolName, credential, SparkClientOptions.Default)
 17        {
 018        }
 19
 20        /// <summary>
 21        /// Initializes a new instance of the <see cref="SparkSessionClient"/>.
 22        /// </summary>
 23        public SparkSessionClient(Uri endpoint, string sparkPoolName, TokenCredential credential, SparkClientOptions opt
 424            : this(new ClientDiagnostics(options),
 425                  SynapseClientPipeline.Build(options, credential),
 426                  endpoint.ToString(),
 427                  sparkPoolName,
 428                  options.VersionString)
 29        {
 430        }
 31    }
 32}

C:\Git\azure-sdk-for-net\sdk\synapse\Azure.Analytics.Synapse.Spark\src\Generated\SparkSessionClient.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4// <auto-generated/>
 5
 6#nullable disable
 7
 8using System;
 9using System.Threading;
 10using System.Threading.Tasks;
 11using Azure;
 12using Azure.Analytics.Synapse.Spark.Models;
 13using Azure.Core.Pipeline;
 14
 15namespace Azure.Analytics.Synapse.Spark
 016{
 17    /// <summary> The SparkSession service client. </summary>
 018    public partial class SparkSessionClient
 19    {
 20        private readonly ClientDiagnostics _clientDiagnostics;
 21        private readonly HttpPipeline _pipeline;
 8422        internal SparkSessionRestClient RestClient { get; }
 23        /// <summary> Initializes a new instance of SparkSessionClient for mocking. </summary>
 1224        protected SparkSessionClient()
 425        {
 1226        }
 427        /// <summary> Initializes a new instance of SparkSessionClient. </summary>
 428        /// <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>
 430        /// <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>
 833        internal SparkSessionClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string endpoint, string 
 34        {
 835            RestClient = new SparkSessionRestClient(clientDiagnostics, pipeline, endpoint, sparkPoolName, livyApiVersion
 836            _clientDiagnostics = clientDiagnostics;
 837            _pipeline = pipeline;
 838        }
 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        {
 251            using var scope = _clientDiagnostics.CreateScope("SparkSessionClient.GetSparkSessions");
 252            scope.Start();
 53            try
 54            {
 255                return await RestClient.GetSparkSessionsAsync(@from, size, detailed, cancellationToken).ConfigureAwait(f
 56            }
 057            catch (Exception e)
 58            {
 059                scope.Failed(e);
 060                throw;
 61            }
 262        }
 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        {
 275            using var scope = _clientDiagnostics.CreateScope("SparkSessionClient.GetSparkSessions");
 276            scope.Start();
 77            try
 78            {
 279                return RestClient.GetSparkSessions(@from, size, detailed, cancellationToken);
 80            }
 081            catch (Exception e)
 82            {
 083                scope.Failed(e);
 084                throw;
 85            }
 286        }
 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        {
 094            using var scope = _clientDiagnostics.CreateScope("SparkSessionClient.CreateSparkSession");
 095            scope.Start();
 96            try
 97            {
 098                return await RestClient.CreateSparkSessionAsync(sparkSessionOptions, detailed, cancellationToken).Config
 99            }
 0100            catch (Exception e)
 101            {
 0102                scope.Failed(e);
 0103                throw;
 104            }
 0105        }
 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        {
 0113            using var scope = _clientDiagnostics.CreateScope("SparkSessionClient.CreateSparkSession");
 0114            scope.Start();
 115            try
 116            {
 0117                return RestClient.CreateSparkSession(sparkSessionOptions, detailed, cancellationToken);
 118            }
 0119            catch (Exception e)
 120            {
 0121                scope.Failed(e);
 0122                throw;
 123            }
 0124        }
 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        {
 40132            using var scope = _clientDiagnostics.CreateScope("SparkSessionClient.GetSparkSession");
 40133            scope.Start();
 134            try
 135            {
 40136                return await RestClient.GetSparkSessionAsync(sessionId, detailed, cancellationToken).ConfigureAwait(fals
 137            }
 0138            catch (Exception e)
 139            {
 0140                scope.Failed(e);
 0141                throw;
 142            }
 40143        }
 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        {
 40151            using var scope = _clientDiagnostics.CreateScope("SparkSessionClient.GetSparkSession");
 40152            scope.Start();
 153            try
 154            {
 40155                return RestClient.GetSparkSession(sessionId, detailed, cancellationToken);
 156            }
 0157            catch (Exception e)
 158            {
 0159                scope.Failed(e);
 0160                throw;
 161            }
 40162        }
 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        {
 0169            using var scope = _clientDiagnostics.CreateScope("SparkSessionClient.CancelSparkSession");
 0170            scope.Start();
 171            try
 172            {
 0173                return await RestClient.CancelSparkSessionAsync(sessionId, cancellationToken).ConfigureAwait(false);
 174            }
 0175            catch (Exception e)
 176            {
 0177                scope.Failed(e);
 0178                throw;
 179            }
 0180        }
 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        {
 0187            using var scope = _clientDiagnostics.CreateScope("SparkSessionClient.CancelSparkSession");
 0188            scope.Start();
 189            try
 190            {
 0191                return RestClient.CancelSparkSession(sessionId, cancellationToken);
 192            }
 0193            catch (Exception e)
 194            {
 0195                scope.Failed(e);
 0196                throw;
 197            }
 0198        }
 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        {
 0205            using var scope = _clientDiagnostics.CreateScope("SparkSessionClient.ResetSparkSessionTimeout");
 0206            scope.Start();
 207            try
 208            {
 0209                return await RestClient.ResetSparkSessionTimeoutAsync(sessionId, cancellationToken).ConfigureAwait(false
 210            }
 0211            catch (Exception e)
 212            {
 0213                scope.Failed(e);
 0214                throw;
 215            }
 0216        }
 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        {
 0223            using var scope = _clientDiagnostics.CreateScope("SparkSessionClient.ResetSparkSessionTimeout");
 0224            scope.Start();
 225            try
 226            {
 0227                return RestClient.ResetSparkSessionTimeout(sessionId, cancellationToken);
 228            }
 0229            catch (Exception e)
 230            {
 0231                scope.Failed(e);
 0232                throw;
 233            }
 0234        }
 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        {
 0241            using var scope = _clientDiagnostics.CreateScope("SparkSessionClient.GetSparkStatements");
 0242            scope.Start();
 243            try
 244            {
 0245                return await RestClient.GetSparkStatementsAsync(sessionId, cancellationToken).ConfigureAwait(false);
 246            }
 0247            catch (Exception e)
 248            {
 0249                scope.Failed(e);
 0250                throw;
 251            }
 0252        }
 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        {
 0259            using var scope = _clientDiagnostics.CreateScope("SparkSessionClient.GetSparkStatements");
 0260            scope.Start();
 261            try
 262            {
 0263                return RestClient.GetSparkStatements(sessionId, cancellationToken);
 264            }
 0265            catch (Exception e)
 266            {
 0267                scope.Failed(e);
 0268                throw;
 269            }
 0270        }
 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        {
 0278            using var scope = _clientDiagnostics.CreateScope("SparkSessionClient.CreateSparkStatement");
 0279            scope.Start();
 280            try
 281            {
 0282                return await RestClient.CreateSparkStatementAsync(sessionId, sparkStatementOptions, cancellationToken).C
 283            }
 0284            catch (Exception e)
 285            {
 0286                scope.Failed(e);
 0287                throw;
 288            }
 0289        }
 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        {
 0297            using var scope = _clientDiagnostics.CreateScope("SparkSessionClient.CreateSparkStatement");
 0298            scope.Start();
 299            try
 300            {
 0301                return RestClient.CreateSparkStatement(sessionId, sparkStatementOptions, cancellationToken);
 302            }
 0303            catch (Exception e)
 304            {
 0305                scope.Failed(e);
 0306                throw;
 307            }
 0308        }
 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        {
 0316            using var scope = _clientDiagnostics.CreateScope("SparkSessionClient.GetSparkStatement");
 0317            scope.Start();
 318            try
 319            {
 0320                return await RestClient.GetSparkStatementAsync(sessionId, statementId, cancellationToken).ConfigureAwait
 321            }
 0322            catch (Exception e)
 323            {
 0324                scope.Failed(e);
 0325                throw;
 326            }
 0327        }
 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        {
 0335            using var scope = _clientDiagnostics.CreateScope("SparkSessionClient.GetSparkStatement");
 0336            scope.Start();
 337            try
 338            {
 0339                return RestClient.GetSparkStatement(sessionId, statementId, cancellationToken);
 340            }
 0341            catch (Exception e)
 342            {
 0343                scope.Failed(e);
 0344                throw;
 345            }
 0346        }
 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        {
 0354            using var scope = _clientDiagnostics.CreateScope("SparkSessionClient.CancelSparkStatement");
 0355            scope.Start();
 356            try
 357            {
 0358                return await RestClient.CancelSparkStatementAsync(sessionId, statementId, cancellationToken).ConfigureAw
 359            }
 0360            catch (Exception e)
 361            {
 0362                scope.Failed(e);
 0363                throw;
 364            }
 0365        }
 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        {
 0373            using var scope = _clientDiagnostics.CreateScope("SparkSessionClient.CancelSparkStatement");
 0374            scope.Start();
 375            try
 376            {
 0377                return RestClient.CancelSparkStatement(sessionId, statementId, cancellationToken);
 378            }
 0379            catch (Exception e)
 380            {
 0381                scope.Failed(e);
 0382                throw;
 383            }
 0384        }
 385    }
 386}