< Summary

Class:Azure.Analytics.Synapse.Artifacts.SqlScriptRestClient
Assembly:Azure.Analytics.Synapse.Artifacts
File(s):C:\Git\azure-sdk-for-net\sdk\synapse\Azure.Analytics.Synapse.Artifacts\src\Generated\SqlScriptRestClient.cs
Covered lines:0
Uncovered lines:163
Coverable lines:163
Total lines:394
Line coverage:0% (0 of 163)
Covered branches:0
Total branches:56
Branch coverage:0% (0 of 56)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%0%
CreateGetSqlScriptsByWorkspaceRequest()-0%100%
GetSqlScriptsByWorkspaceAsync()-0%0%
GetSqlScriptsByWorkspace(...)-0%0%
CreateCreateOrUpdateSqlScriptRequest(...)-0%0%
CreateOrUpdateSqlScriptAsync()-0%0%
CreateOrUpdateSqlScript(...)-0%0%
CreateGetSqlScriptRequest(...)-0%0%
GetSqlScriptAsync()-0%0%
GetSqlScript(...)-0%0%
CreateDeleteSqlScriptRequest(...)-0%100%
DeleteSqlScriptAsync()-0%0%
DeleteSqlScript(...)-0%0%
CreateGetSqlScriptsByWorkspaceNextPageRequest(...)-0%100%
GetSqlScriptsByWorkspaceNextPageAsync()-0%0%
GetSqlScriptsByWorkspaceNextPage(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\synapse\Azure.Analytics.Synapse.Artifacts\src\Generated\SqlScriptRestClient.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.Text.Json;
 10using System.Threading;
 11using System.Threading.Tasks;
 12using Azure;
 13using Azure.Analytics.Synapse.Artifacts.Models;
 14using Azure.Core;
 15using Azure.Core.Pipeline;
 16
 17namespace Azure.Analytics.Synapse.Artifacts
 18{
 19    internal partial class SqlScriptRestClient
 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 SqlScriptRestClient. </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
 032        public SqlScriptRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string endpoint, string a
 33        {
 034            if (endpoint == null)
 35            {
 036                throw new ArgumentNullException(nameof(endpoint));
 37            }
 038            if (apiVersion == null)
 39            {
 040                throw new ArgumentNullException(nameof(apiVersion));
 41            }
 42
 043            this.endpoint = endpoint;
 044            this.apiVersion = apiVersion;
 045            _clientDiagnostics = clientDiagnostics;
 046            _pipeline = pipeline;
 047        }
 48
 49        internal HttpMessage CreateGetSqlScriptsByWorkspaceRequest()
 50        {
 051            var message = _pipeline.CreateMessage();
 052            var request = message.Request;
 053            request.Method = RequestMethod.Get;
 054            var uri = new RawRequestUriBuilder();
 055            uri.AppendRaw(endpoint, false);
 056            uri.AppendPath("/sqlScripts", false);
 057            uri.AppendQuery("api-version", apiVersion, true);
 058            request.Uri = uri;
 059            return message;
 60        }
 61
 62        /// <summary> Lists sql scripts. </summary>
 63        /// <param name="cancellationToken"> The cancellation token to use. </param>
 64        public async Task<Response<SqlScriptsListResponse>> GetSqlScriptsByWorkspaceAsync(CancellationToken cancellation
 65        {
 066            using var message = CreateGetSqlScriptsByWorkspaceRequest();
 067            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 068            switch (message.Response.Status)
 69            {
 70                case 200:
 71                    {
 72                        SqlScriptsListResponse value = default;
 073                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 074                        value = SqlScriptsListResponse.DeserializeSqlScriptsListResponse(document.RootElement);
 075                        return Response.FromValue(value, message.Response);
 76                    }
 77                default:
 078                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 79            }
 080        }
 81
 82        /// <summary> Lists sql scripts. </summary>
 83        /// <param name="cancellationToken"> The cancellation token to use. </param>
 84        public Response<SqlScriptsListResponse> GetSqlScriptsByWorkspace(CancellationToken cancellationToken = default)
 85        {
 086            using var message = CreateGetSqlScriptsByWorkspaceRequest();
 087            _pipeline.Send(message, cancellationToken);
 088            switch (message.Response.Status)
 89            {
 90                case 200:
 91                    {
 92                        SqlScriptsListResponse value = default;
 093                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 094                        value = SqlScriptsListResponse.DeserializeSqlScriptsListResponse(document.RootElement);
 095                        return Response.FromValue(value, message.Response);
 96                    }
 97                default:
 098                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 99            }
 0100        }
 101
 102        internal HttpMessage CreateCreateOrUpdateSqlScriptRequest(string sqlScriptName, SqlScriptResource sqlScript, str
 103        {
 0104            var message = _pipeline.CreateMessage();
 0105            var request = message.Request;
 0106            request.Method = RequestMethod.Put;
 0107            var uri = new RawRequestUriBuilder();
 0108            uri.AppendRaw(endpoint, false);
 0109            uri.AppendPath("/sqlScripts/", false);
 0110            uri.AppendPath(sqlScriptName, true);
 0111            uri.AppendQuery("api-version", apiVersion, true);
 0112            request.Uri = uri;
 0113            if (ifMatch != null)
 114            {
 0115                request.Headers.Add("If-Match", ifMatch);
 116            }
 0117            request.Headers.Add("Content-Type", "application/json");
 0118            var content = new Utf8JsonRequestContent();
 0119            content.JsonWriter.WriteObjectValue(sqlScript);
 0120            request.Content = content;
 0121            return message;
 122        }
 123
 124        /// <summary> Creates or updates a Sql Script. </summary>
 125        /// <param name="sqlScriptName"> The sql script name. </param>
 126        /// <param name="sqlScript"> Sql Script resource definition. </param>
 127        /// <param name="ifMatch"> ETag of the SQL script entity.  Should only be specified for update, for which it sho
 128        /// <param name="cancellationToken"> The cancellation token to use. </param>
 129        /// <exception cref="ArgumentNullException"> <paramref name="sqlScriptName"/> or <paramref name="sqlScript"/> is
 130        public async Task<Response<SqlScriptResource>> CreateOrUpdateSqlScriptAsync(string sqlScriptName, SqlScriptResou
 131        {
 0132            if (sqlScriptName == null)
 133            {
 0134                throw new ArgumentNullException(nameof(sqlScriptName));
 135            }
 0136            if (sqlScript == null)
 137            {
 0138                throw new ArgumentNullException(nameof(sqlScript));
 139            }
 140
 0141            using var message = CreateCreateOrUpdateSqlScriptRequest(sqlScriptName, sqlScript, ifMatch);
 0142            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0143            switch (message.Response.Status)
 144            {
 145                case 200:
 146                    {
 147                        SqlScriptResource value = default;
 0148                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0149                        value = SqlScriptResource.DeserializeSqlScriptResource(document.RootElement);
 0150                        return Response.FromValue(value, message.Response);
 151                    }
 152                default:
 0153                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 154            }
 0155        }
 156
 157        /// <summary> Creates or updates a Sql Script. </summary>
 158        /// <param name="sqlScriptName"> The sql script name. </param>
 159        /// <param name="sqlScript"> Sql Script resource definition. </param>
 160        /// <param name="ifMatch"> ETag of the SQL script entity.  Should only be specified for update, for which it sho
 161        /// <param name="cancellationToken"> The cancellation token to use. </param>
 162        /// <exception cref="ArgumentNullException"> <paramref name="sqlScriptName"/> or <paramref name="sqlScript"/> is
 163        public Response<SqlScriptResource> CreateOrUpdateSqlScript(string sqlScriptName, SqlScriptResource sqlScript, st
 164        {
 0165            if (sqlScriptName == null)
 166            {
 0167                throw new ArgumentNullException(nameof(sqlScriptName));
 168            }
 0169            if (sqlScript == null)
 170            {
 0171                throw new ArgumentNullException(nameof(sqlScript));
 172            }
 173
 0174            using var message = CreateCreateOrUpdateSqlScriptRequest(sqlScriptName, sqlScript, ifMatch);
 0175            _pipeline.Send(message, cancellationToken);
 0176            switch (message.Response.Status)
 177            {
 178                case 200:
 179                    {
 180                        SqlScriptResource value = default;
 0181                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0182                        value = SqlScriptResource.DeserializeSqlScriptResource(document.RootElement);
 0183                        return Response.FromValue(value, message.Response);
 184                    }
 185                default:
 0186                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 187            }
 0188        }
 189
 190        internal HttpMessage CreateGetSqlScriptRequest(string sqlScriptName, string ifNoneMatch)
 191        {
 0192            var message = _pipeline.CreateMessage();
 0193            var request = message.Request;
 0194            request.Method = RequestMethod.Get;
 0195            var uri = new RawRequestUriBuilder();
 0196            uri.AppendRaw(endpoint, false);
 0197            uri.AppendPath("/sqlScripts/", false);
 0198            uri.AppendPath(sqlScriptName, true);
 0199            uri.AppendQuery("api-version", apiVersion, true);
 0200            request.Uri = uri;
 0201            if (ifNoneMatch != null)
 202            {
 0203                request.Headers.Add("If-None-Match", ifNoneMatch);
 204            }
 0205            return message;
 206        }
 207
 208        /// <summary> Gets a sql script. </summary>
 209        /// <param name="sqlScriptName"> The sql script name. </param>
 210        /// <param name="ifNoneMatch"> ETag of the sql compute entity. Should only be specified for get. If the ETag mat
 211        /// <param name="cancellationToken"> The cancellation token to use. </param>
 212        /// <exception cref="ArgumentNullException"> <paramref name="sqlScriptName"/> is null. </exception>
 213        public async Task<Response<SqlScriptResource>> GetSqlScriptAsync(string sqlScriptName, string ifNoneMatch = null
 214        {
 0215            if (sqlScriptName == null)
 216            {
 0217                throw new ArgumentNullException(nameof(sqlScriptName));
 218            }
 219
 0220            using var message = CreateGetSqlScriptRequest(sqlScriptName, ifNoneMatch);
 0221            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0222            switch (message.Response.Status)
 223            {
 224                case 200:
 225                    {
 226                        SqlScriptResource value = default;
 0227                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0228                        value = SqlScriptResource.DeserializeSqlScriptResource(document.RootElement);
 0229                        return Response.FromValue(value, message.Response);
 230                    }
 231                case 304:
 0232                    return Response.FromValue<SqlScriptResource>(null, message.Response);
 233                default:
 0234                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 235            }
 0236        }
 237
 238        /// <summary> Gets a sql script. </summary>
 239        /// <param name="sqlScriptName"> The sql script name. </param>
 240        /// <param name="ifNoneMatch"> ETag of the sql compute entity. Should only be specified for get. If the ETag mat
 241        /// <param name="cancellationToken"> The cancellation token to use. </param>
 242        /// <exception cref="ArgumentNullException"> <paramref name="sqlScriptName"/> is null. </exception>
 243        public Response<SqlScriptResource> GetSqlScript(string sqlScriptName, string ifNoneMatch = null, CancellationTok
 244        {
 0245            if (sqlScriptName == null)
 246            {
 0247                throw new ArgumentNullException(nameof(sqlScriptName));
 248            }
 249
 0250            using var message = CreateGetSqlScriptRequest(sqlScriptName, ifNoneMatch);
 0251            _pipeline.Send(message, cancellationToken);
 0252            switch (message.Response.Status)
 253            {
 254                case 200:
 255                    {
 256                        SqlScriptResource value = default;
 0257                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0258                        value = SqlScriptResource.DeserializeSqlScriptResource(document.RootElement);
 0259                        return Response.FromValue(value, message.Response);
 260                    }
 261                case 304:
 0262                    return Response.FromValue<SqlScriptResource>(null, message.Response);
 263                default:
 0264                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 265            }
 0266        }
 267
 268        internal HttpMessage CreateDeleteSqlScriptRequest(string sqlScriptName)
 269        {
 0270            var message = _pipeline.CreateMessage();
 0271            var request = message.Request;
 0272            request.Method = RequestMethod.Delete;
 0273            var uri = new RawRequestUriBuilder();
 0274            uri.AppendRaw(endpoint, false);
 0275            uri.AppendPath("/sqlScripts/", false);
 0276            uri.AppendPath(sqlScriptName, true);
 0277            uri.AppendQuery("api-version", apiVersion, true);
 0278            request.Uri = uri;
 0279            return message;
 280        }
 281
 282        /// <summary> Deletes a Sql Script. </summary>
 283        /// <param name="sqlScriptName"> The sql script name. </param>
 284        /// <param name="cancellationToken"> The cancellation token to use. </param>
 285        /// <exception cref="ArgumentNullException"> <paramref name="sqlScriptName"/> is null. </exception>
 286        public async Task<Response> DeleteSqlScriptAsync(string sqlScriptName, CancellationToken cancellationToken = def
 287        {
 0288            if (sqlScriptName == null)
 289            {
 0290                throw new ArgumentNullException(nameof(sqlScriptName));
 291            }
 292
 0293            using var message = CreateDeleteSqlScriptRequest(sqlScriptName);
 0294            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0295            switch (message.Response.Status)
 296            {
 297                case 200:
 298                case 204:
 0299                    return message.Response;
 300                default:
 0301                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 302            }
 0303        }
 304
 305        /// <summary> Deletes a Sql Script. </summary>
 306        /// <param name="sqlScriptName"> The sql script name. </param>
 307        /// <param name="cancellationToken"> The cancellation token to use. </param>
 308        /// <exception cref="ArgumentNullException"> <paramref name="sqlScriptName"/> is null. </exception>
 309        public Response DeleteSqlScript(string sqlScriptName, CancellationToken cancellationToken = default)
 310        {
 0311            if (sqlScriptName == null)
 312            {
 0313                throw new ArgumentNullException(nameof(sqlScriptName));
 314            }
 315
 0316            using var message = CreateDeleteSqlScriptRequest(sqlScriptName);
 0317            _pipeline.Send(message, cancellationToken);
 0318            switch (message.Response.Status)
 319            {
 320                case 200:
 321                case 204:
 0322                    return message.Response;
 323                default:
 0324                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 325            }
 0326        }
 327
 328        internal HttpMessage CreateGetSqlScriptsByWorkspaceNextPageRequest(string nextLink)
 329        {
 0330            var message = _pipeline.CreateMessage();
 0331            var request = message.Request;
 0332            request.Method = RequestMethod.Get;
 0333            var uri = new RawRequestUriBuilder();
 0334            uri.AppendRaw(endpoint, false);
 0335            uri.AppendRawNextLink(nextLink, false);
 0336            request.Uri = uri;
 0337            return message;
 338        }
 339
 340        /// <summary> Lists sql scripts. </summary>
 341        /// <param name="nextLink"> The URL to the next page of results. </param>
 342        /// <param name="cancellationToken"> The cancellation token to use. </param>
 343        /// <exception cref="ArgumentNullException"> <paramref name="nextLink"/> is null. </exception>
 344        public async Task<Response<SqlScriptsListResponse>> GetSqlScriptsByWorkspaceNextPageAsync(string nextLink, Cance
 345        {
 0346            if (nextLink == null)
 347            {
 0348                throw new ArgumentNullException(nameof(nextLink));
 349            }
 350
 0351            using var message = CreateGetSqlScriptsByWorkspaceNextPageRequest(nextLink);
 0352            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0353            switch (message.Response.Status)
 354            {
 355                case 200:
 356                    {
 357                        SqlScriptsListResponse value = default;
 0358                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0359                        value = SqlScriptsListResponse.DeserializeSqlScriptsListResponse(document.RootElement);
 0360                        return Response.FromValue(value, message.Response);
 361                    }
 362                default:
 0363                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 364            }
 0365        }
 366
 367        /// <summary> Lists sql scripts. </summary>
 368        /// <param name="nextLink"> The URL to the next page of results. </param>
 369        /// <param name="cancellationToken"> The cancellation token to use. </param>
 370        /// <exception cref="ArgumentNullException"> <paramref name="nextLink"/> is null. </exception>
 371        public Response<SqlScriptsListResponse> GetSqlScriptsByWorkspaceNextPage(string nextLink, CancellationToken canc
 372        {
 0373            if (nextLink == null)
 374            {
 0375                throw new ArgumentNullException(nameof(nextLink));
 376            }
 377
 0378            using var message = CreateGetSqlScriptsByWorkspaceNextPageRequest(nextLink);
 0379            _pipeline.Send(message, cancellationToken);
 0380            switch (message.Response.Status)
 381            {
 382                case 200:
 383                    {
 384                        SqlScriptsListResponse value = default;
 0385                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0386                        value = SqlScriptsListResponse.DeserializeSqlScriptsListResponse(document.RootElement);
 0387                        return Response.FromValue(value, message.Response);
 388                    }
 389                default:
 0390                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 391            }
 0392        }
 393    }
 394}