public async Task TestGetSparkSession()
        {
            SparkSessionCollection sparkSessions = (await SparkSessionClient.GetSparkSessionsAsync()).Value;

            foreach (SparkSession expectedSparkSession in sparkSessions.Sessions)
            {
                SparkSession actualSparkSession = await SparkSessionClient.GetSparkSessionAsync(expectedSparkSession.Id);

                ValidateSparkSession(expectedSparkSession, actualSparkSession);
            }
        }
        public async Task <Response <SparkSessionCollection> > GetSparkSessionsAsync(int? @from = null, int?size = null, bool?detailed = null, CancellationToken cancellationToken = default)
        {
            using var message = CreateGetSparkSessionsRequest(@from, size, detailed);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);

            switch (message.Response.Status)
            {
            case 200:
            {
                SparkSessionCollection value = default;
                using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);

                value = SparkSessionCollection.DeserializeSparkSessionCollection(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
        public static async Task <List <SparkSession> > ListSparkSessionsAsync(SparkSessionClient client, bool detailed = true)
        {
            List <SparkSession> sessions = new List <SparkSession>();
            int from = 0;
            int currentPageSize;
            int pageSize = 20;

            do
            {
                SparkSessionCollection page = (await client.GetSparkSessionsAsync(detailed: detailed, from: from, size: pageSize)).Value;
                currentPageSize = page.Total;
                from           += currentPageSize;
                sessions.AddRange(page.Sessions);
            } while (currentPageSize == pageSize);

            return(sessions);
        }