< Summary

Class:Azure.ResourceManager.DigitalTwins.DigitalTwinsRestOperations
Assembly:Azure.ResourceManager.DigitalTwins
File(s):C:\Git\azure-sdk-for-net\sdk\digitaltwins\Azure.ResourceManager.DigitalTwins\src\Generated\DigitalTwinsRestOperations.cs
Covered lines:165
Uncovered lines:165
Coverable lines:330
Total lines:740
Line coverage:50% (165 of 330)
Covered branches:35
Total branches:112
Branch coverage:31.2% (35 of 112)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-83.33%50%
CreateGetRequest(...)-100%100%
GetAsync()-75%50%
Get(...)-75%50%
CreateCreateOrUpdateRequest(...)-100%100%
CreateOrUpdateAsync()-66.67%50%
CreateOrUpdate(...)-66.67%50%
CreateUpdateRequest(...)-0%0%
UpdateAsync()-0%0%
Update(...)-0%0%
CreateDeleteRequest(...)-100%100%
DeleteAsync()-70%50%
Delete(...)-70%50%
CreateListRequest()-100%100%
ListAsync()-87.5%50%
List(...)-87.5%50%
CreateListByResourceGroupRequest(...)-0%100%
ListByResourceGroupAsync()-0%0%
ListByResourceGroup(...)-0%0%
CreateCheckNameAvailabilityRequest(...)-100%100%
CheckNameAvailabilityAsync()-75%50%
CheckNameAvailability(...)-75%50%
CreateListNextPageRequest(...)-0%100%
ListNextPageAsync()-0%0%
ListNextPage(...)-0%0%
CreateListByResourceGroupNextPageRequest(...)-0%100%
ListByResourceGroupNextPageAsync()-0%0%
ListByResourceGroupNextPage(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\digitaltwins\Azure.ResourceManager.DigitalTwins\src\Generated\DigitalTwinsRestOperations.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.Collections.Generic;
 10using System.Text.Json;
 11using System.Threading;
 12using System.Threading.Tasks;
 13using Azure;
 14using Azure.Core;
 15using Azure.Core.Pipeline;
 16using Azure.ResourceManager.DigitalTwins.Models;
 17
 18namespace Azure.ResourceManager.DigitalTwins
 19{
 20    internal partial class DigitalTwinsRestOperations
 21    {
 22        private string subscriptionId;
 23        private Uri endpoint;
 24        private string apiVersion;
 25        private ClientDiagnostics _clientDiagnostics;
 26        private HttpPipeline _pipeline;
 27
 28        /// <summary> Initializes a new instance of DigitalTwinsRestOperations. </summary>
 29        /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param>
 30        /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param>
 31        /// <param name="subscriptionId"> The subscription identifier. </param>
 32        /// <param name="endpoint"> server parameter. </param>
 33        /// <param name="apiVersion"> Api Version. </param>
 34        /// <exception cref="ArgumentNullException"> <paramref name="subscriptionId"/> or <paramref name="apiVersion"/> 
 2035        public DigitalTwinsRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptio
 36        {
 2037            if (subscriptionId == null)
 38            {
 039                throw new ArgumentNullException(nameof(subscriptionId));
 40            }
 2041            endpoint ??= new Uri("https://management.azure.com");
 2042            if (apiVersion == null)
 43            {
 044                throw new ArgumentNullException(nameof(apiVersion));
 45            }
 46
 2047            this.subscriptionId = subscriptionId;
 2048            this.endpoint = endpoint;
 2049            this.apiVersion = apiVersion;
 2050            _clientDiagnostics = clientDiagnostics;
 2051            _pipeline = pipeline;
 2052        }
 53
 54        internal HttpMessage CreateGetRequest(string resourceGroupName, string resourceName)
 55        {
 456            var message = _pipeline.CreateMessage();
 457            var request = message.Request;
 458            request.Method = RequestMethod.Get;
 459            var uri = new RawRequestUriBuilder();
 460            uri.Reset(endpoint);
 461            uri.AppendPath("/subscriptions/", false);
 462            uri.AppendPath(subscriptionId, true);
 463            uri.AppendPath("/resourceGroups/", false);
 464            uri.AppendPath(resourceGroupName, true);
 465            uri.AppendPath("/providers/Microsoft.DigitalTwins/digitalTwinsInstances/", false);
 466            uri.AppendPath(resourceName, true);
 467            uri.AppendQuery("api-version", apiVersion, true);
 468            request.Uri = uri;
 469            return message;
 70        }
 71
 72        /// <summary> Get DigitalTwinsInstances resource. </summary>
 73        /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa
 74        /// <param name="resourceName"> The name of the DigitalTwinsInstance. </param>
 75        /// <param name="cancellationToken"> The cancellation token to use. </param>
 76        /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/> or <paramref name="resourceNam
 77        public async Task<Response<DigitalTwinsDescription>> GetAsync(string resourceGroupName, string resourceName, Can
 78        {
 279            if (resourceGroupName == null)
 80            {
 081                throw new ArgumentNullException(nameof(resourceGroupName));
 82            }
 283            if (resourceName == null)
 84            {
 085                throw new ArgumentNullException(nameof(resourceName));
 86            }
 87
 288            using var message = CreateGetRequest(resourceGroupName, resourceName);
 289            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 290            switch (message.Response.Status)
 91            {
 92                case 200:
 93                    {
 94                        DigitalTwinsDescription value = default;
 295                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 296                        value = DigitalTwinsDescription.DeserializeDigitalTwinsDescription(document.RootElement);
 297                        return Response.FromValue(value, message.Response);
 98                    }
 99                default:
 0100                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 101            }
 2102        }
 103
 104        /// <summary> Get DigitalTwinsInstances resource. </summary>
 105        /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa
 106        /// <param name="resourceName"> The name of the DigitalTwinsInstance. </param>
 107        /// <param name="cancellationToken"> The cancellation token to use. </param>
 108        /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/> or <paramref name="resourceNam
 109        public Response<DigitalTwinsDescription> Get(string resourceGroupName, string resourceName, CancellationToken ca
 110        {
 2111            if (resourceGroupName == null)
 112            {
 0113                throw new ArgumentNullException(nameof(resourceGroupName));
 114            }
 2115            if (resourceName == null)
 116            {
 0117                throw new ArgumentNullException(nameof(resourceName));
 118            }
 119
 2120            using var message = CreateGetRequest(resourceGroupName, resourceName);
 2121            _pipeline.Send(message, cancellationToken);
 2122            switch (message.Response.Status)
 123            {
 124                case 200:
 125                    {
 126                        DigitalTwinsDescription value = default;
 2127                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 2128                        value = DigitalTwinsDescription.DeserializeDigitalTwinsDescription(document.RootElement);
 2129                        return Response.FromValue(value, message.Response);
 130                    }
 131                default:
 0132                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 133            }
 2134        }
 135
 136        internal HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string resourceName, DigitalTwinsDesc
 137        {
 8138            var message = _pipeline.CreateMessage();
 8139            var request = message.Request;
 8140            request.Method = RequestMethod.Put;
 8141            var uri = new RawRequestUriBuilder();
 8142            uri.Reset(endpoint);
 8143            uri.AppendPath("/subscriptions/", false);
 8144            uri.AppendPath(subscriptionId, true);
 8145            uri.AppendPath("/resourceGroups/", false);
 8146            uri.AppendPath(resourceGroupName, true);
 8147            uri.AppendPath("/providers/Microsoft.DigitalTwins/digitalTwinsInstances/", false);
 8148            uri.AppendPath(resourceName, true);
 8149            uri.AppendQuery("api-version", apiVersion, true);
 8150            request.Uri = uri;
 8151            request.Headers.Add("Content-Type", "application/json");
 8152            var content = new Utf8JsonRequestContent();
 8153            content.JsonWriter.WriteObjectValue(digitalTwinsCreate);
 8154            request.Content = content;
 8155            return message;
 156        }
 157
 158        /// <summary> Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property is
 159        /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa
 160        /// <param name="resourceName"> The name of the DigitalTwinsInstance. </param>
 161        /// <param name="digitalTwinsCreate"> The DigitalTwinsInstance and security metadata. </param>
 162        /// <param name="cancellationToken"> The cancellation token to use. </param>
 163        /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/>, <paramref name="resourceName"
 164        public async Task<Response> CreateOrUpdateAsync(string resourceGroupName, string resourceName, DigitalTwinsDescr
 165        {
 2166            if (resourceGroupName == null)
 167            {
 0168                throw new ArgumentNullException(nameof(resourceGroupName));
 169            }
 2170            if (resourceName == null)
 171            {
 0172                throw new ArgumentNullException(nameof(resourceName));
 173            }
 2174            if (digitalTwinsCreate == null)
 175            {
 0176                throw new ArgumentNullException(nameof(digitalTwinsCreate));
 177            }
 178
 2179            using var message = CreateCreateOrUpdateRequest(resourceGroupName, resourceName, digitalTwinsCreate);
 2180            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 2181            switch (message.Response.Status)
 182            {
 183                case 200:
 184                case 201:
 2185                    return message.Response;
 186                default:
 0187                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 188            }
 2189        }
 190
 191        /// <summary> Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property is
 192        /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa
 193        /// <param name="resourceName"> The name of the DigitalTwinsInstance. </param>
 194        /// <param name="digitalTwinsCreate"> The DigitalTwinsInstance and security metadata. </param>
 195        /// <param name="cancellationToken"> The cancellation token to use. </param>
 196        /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/>, <paramref name="resourceName"
 197        public Response CreateOrUpdate(string resourceGroupName, string resourceName, DigitalTwinsDescription digitalTwi
 198        {
 2199            if (resourceGroupName == null)
 200            {
 0201                throw new ArgumentNullException(nameof(resourceGroupName));
 202            }
 2203            if (resourceName == null)
 204            {
 0205                throw new ArgumentNullException(nameof(resourceName));
 206            }
 2207            if (digitalTwinsCreate == null)
 208            {
 0209                throw new ArgumentNullException(nameof(digitalTwinsCreate));
 210            }
 211
 2212            using var message = CreateCreateOrUpdateRequest(resourceGroupName, resourceName, digitalTwinsCreate);
 2213            _pipeline.Send(message, cancellationToken);
 2214            switch (message.Response.Status)
 215            {
 216                case 200:
 217                case 201:
 2218                    return message.Response;
 219                default:
 0220                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 221            }
 2222        }
 223
 224        internal HttpMessage CreateUpdateRequest(string resourceGroupName, string resourceName, IDictionary<string, stri
 225        {
 0226            var message = _pipeline.CreateMessage();
 0227            var request = message.Request;
 0228            request.Method = RequestMethod.Patch;
 0229            var uri = new RawRequestUriBuilder();
 0230            uri.Reset(endpoint);
 0231            uri.AppendPath("/subscriptions/", false);
 0232            uri.AppendPath(subscriptionId, true);
 0233            uri.AppendPath("/resourceGroups/", false);
 0234            uri.AppendPath(resourceGroupName, true);
 0235            uri.AppendPath("/providers/Microsoft.DigitalTwins/digitalTwinsInstances/", false);
 0236            uri.AppendPath(resourceName, true);
 0237            uri.AppendQuery("api-version", apiVersion, true);
 0238            request.Uri = uri;
 0239            request.Headers.Add("Content-Type", "application/json");
 0240            DigitalTwinsPatchDescription digitalTwinsPatchDescription = new DigitalTwinsPatchDescription();
 0241            foreach (var value in tags)
 242            {
 0243                digitalTwinsPatchDescription.Tags.Add(value);
 244            }
 0245            var model = digitalTwinsPatchDescription;
 0246            var content = new Utf8JsonRequestContent();
 0247            content.JsonWriter.WriteObjectValue(model);
 0248            request.Content = content;
 0249            return message;
 250        }
 251
 252        /// <summary> Update metadata of DigitalTwinsInstance. </summary>
 253        /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa
 254        /// <param name="resourceName"> The name of the DigitalTwinsInstance. </param>
 255        /// <param name="tags"> Instance tags. </param>
 256        /// <param name="cancellationToken"> The cancellation token to use. </param>
 257        /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/> or <paramref name="resourceNam
 258        public async Task<Response> UpdateAsync(string resourceGroupName, string resourceName, IDictionary<string, strin
 259        {
 0260            if (resourceGroupName == null)
 261            {
 0262                throw new ArgumentNullException(nameof(resourceGroupName));
 263            }
 0264            if (resourceName == null)
 265            {
 0266                throw new ArgumentNullException(nameof(resourceName));
 267            }
 268
 0269            using var message = CreateUpdateRequest(resourceGroupName, resourceName, tags);
 0270            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0271            switch (message.Response.Status)
 272            {
 273                case 200:
 274                case 201:
 0275                    return message.Response;
 276                default:
 0277                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 278            }
 0279        }
 280
 281        /// <summary> Update metadata of DigitalTwinsInstance. </summary>
 282        /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa
 283        /// <param name="resourceName"> The name of the DigitalTwinsInstance. </param>
 284        /// <param name="tags"> Instance tags. </param>
 285        /// <param name="cancellationToken"> The cancellation token to use. </param>
 286        /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/> or <paramref name="resourceNam
 287        public Response Update(string resourceGroupName, string resourceName, IDictionary<string, string> tags = null, C
 288        {
 0289            if (resourceGroupName == null)
 290            {
 0291                throw new ArgumentNullException(nameof(resourceGroupName));
 292            }
 0293            if (resourceName == null)
 294            {
 0295                throw new ArgumentNullException(nameof(resourceName));
 296            }
 297
 0298            using var message = CreateUpdateRequest(resourceGroupName, resourceName, tags);
 0299            _pipeline.Send(message, cancellationToken);
 0300            switch (message.Response.Status)
 301            {
 302                case 200:
 303                case 201:
 0304                    return message.Response;
 305                default:
 0306                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 307            }
 0308        }
 309
 310        internal HttpMessage CreateDeleteRequest(string resourceGroupName, string resourceName)
 311        {
 8312            var message = _pipeline.CreateMessage();
 8313            var request = message.Request;
 8314            request.Method = RequestMethod.Delete;
 8315            var uri = new RawRequestUriBuilder();
 8316            uri.Reset(endpoint);
 8317            uri.AppendPath("/subscriptions/", false);
 8318            uri.AppendPath(subscriptionId, true);
 8319            uri.AppendPath("/resourceGroups/", false);
 8320            uri.AppendPath(resourceGroupName, true);
 8321            uri.AppendPath("/providers/Microsoft.DigitalTwins/digitalTwinsInstances/", false);
 8322            uri.AppendPath(resourceName, true);
 8323            uri.AppendQuery("api-version", apiVersion, true);
 8324            request.Uri = uri;
 8325            return message;
 326        }
 327
 328        /// <summary> Delete a DigitalTwinsInstance. </summary>
 329        /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa
 330        /// <param name="resourceName"> The name of the DigitalTwinsInstance. </param>
 331        /// <param name="cancellationToken"> The cancellation token to use. </param>
 332        /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/> or <paramref name="resourceNam
 333        public async Task<Response> DeleteAsync(string resourceGroupName, string resourceName, CancellationToken cancell
 334        {
 2335            if (resourceGroupName == null)
 336            {
 0337                throw new ArgumentNullException(nameof(resourceGroupName));
 338            }
 2339            if (resourceName == null)
 340            {
 0341                throw new ArgumentNullException(nameof(resourceName));
 342            }
 343
 2344            using var message = CreateDeleteRequest(resourceGroupName, resourceName);
 2345            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 2346            switch (message.Response.Status)
 347            {
 348                case 200:
 349                case 202:
 350                case 204:
 2351                    return message.Response;
 352                default:
 0353                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 354            }
 2355        }
 356
 357        /// <summary> Delete a DigitalTwinsInstance. </summary>
 358        /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa
 359        /// <param name="resourceName"> The name of the DigitalTwinsInstance. </param>
 360        /// <param name="cancellationToken"> The cancellation token to use. </param>
 361        /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/> or <paramref name="resourceNam
 362        public Response Delete(string resourceGroupName, string resourceName, CancellationToken cancellationToken = defa
 363        {
 2364            if (resourceGroupName == null)
 365            {
 0366                throw new ArgumentNullException(nameof(resourceGroupName));
 367            }
 2368            if (resourceName == null)
 369            {
 0370                throw new ArgumentNullException(nameof(resourceName));
 371            }
 372
 2373            using var message = CreateDeleteRequest(resourceGroupName, resourceName);
 2374            _pipeline.Send(message, cancellationToken);
 2375            switch (message.Response.Status)
 376            {
 377                case 200:
 378                case 202:
 379                case 204:
 2380                    return message.Response;
 381                default:
 0382                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 383            }
 2384        }
 385
 386        internal HttpMessage CreateListRequest()
 387        {
 4388            var message = _pipeline.CreateMessage();
 4389            var request = message.Request;
 4390            request.Method = RequestMethod.Get;
 4391            var uri = new RawRequestUriBuilder();
 4392            uri.Reset(endpoint);
 4393            uri.AppendPath("/subscriptions/", false);
 4394            uri.AppendPath(subscriptionId, true);
 4395            uri.AppendPath("/providers/Microsoft.DigitalTwins/digitalTwinsInstances", false);
 4396            uri.AppendQuery("api-version", apiVersion, true);
 4397            request.Uri = uri;
 4398            return message;
 399        }
 400
 401        /// <summary> Get all the DigitalTwinsInstances in a subscription. </summary>
 402        /// <param name="cancellationToken"> The cancellation token to use. </param>
 403        public async Task<Response<DigitalTwinsDescriptionListResult>> ListAsync(CancellationToken cancellationToken = d
 404        {
 2405            using var message = CreateListRequest();
 2406            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 2407            switch (message.Response.Status)
 408            {
 409                case 200:
 410                    {
 411                        DigitalTwinsDescriptionListResult value = default;
 2412                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 2413                        value = DigitalTwinsDescriptionListResult.DeserializeDigitalTwinsDescriptionListResult(document.
 2414                        return Response.FromValue(value, message.Response);
 415                    }
 416                default:
 0417                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 418            }
 2419        }
 420
 421        /// <summary> Get all the DigitalTwinsInstances in a subscription. </summary>
 422        /// <param name="cancellationToken"> The cancellation token to use. </param>
 423        public Response<DigitalTwinsDescriptionListResult> List(CancellationToken cancellationToken = default)
 424        {
 2425            using var message = CreateListRequest();
 2426            _pipeline.Send(message, cancellationToken);
 2427            switch (message.Response.Status)
 428            {
 429                case 200:
 430                    {
 431                        DigitalTwinsDescriptionListResult value = default;
 2432                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 2433                        value = DigitalTwinsDescriptionListResult.DeserializeDigitalTwinsDescriptionListResult(document.
 2434                        return Response.FromValue(value, message.Response);
 435                    }
 436                default:
 0437                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 438            }
 2439        }
 440
 441        internal HttpMessage CreateListByResourceGroupRequest(string resourceGroupName)
 442        {
 0443            var message = _pipeline.CreateMessage();
 0444            var request = message.Request;
 0445            request.Method = RequestMethod.Get;
 0446            var uri = new RawRequestUriBuilder();
 0447            uri.Reset(endpoint);
 0448            uri.AppendPath("/subscriptions/", false);
 0449            uri.AppendPath(subscriptionId, true);
 0450            uri.AppendPath("/resourceGroups/", false);
 0451            uri.AppendPath(resourceGroupName, true);
 0452            uri.AppendPath("/providers/Microsoft.DigitalTwins/digitalTwinsInstances", false);
 0453            uri.AppendQuery("api-version", apiVersion, true);
 0454            request.Uri = uri;
 0455            return message;
 456        }
 457
 458        /// <summary> Get all the DigitalTwinsInstances in a resource group. </summary>
 459        /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa
 460        /// <param name="cancellationToken"> The cancellation token to use. </param>
 461        /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/> is null. </exception>
 462        public async Task<Response<DigitalTwinsDescriptionListResult>> ListByResourceGroupAsync(string resourceGroupName
 463        {
 0464            if (resourceGroupName == null)
 465            {
 0466                throw new ArgumentNullException(nameof(resourceGroupName));
 467            }
 468
 0469            using var message = CreateListByResourceGroupRequest(resourceGroupName);
 0470            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0471            switch (message.Response.Status)
 472            {
 473                case 200:
 474                    {
 475                        DigitalTwinsDescriptionListResult value = default;
 0476                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0477                        value = DigitalTwinsDescriptionListResult.DeserializeDigitalTwinsDescriptionListResult(document.
 0478                        return Response.FromValue(value, message.Response);
 479                    }
 480                default:
 0481                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 482            }
 0483        }
 484
 485        /// <summary> Get all the DigitalTwinsInstances in a resource group. </summary>
 486        /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa
 487        /// <param name="cancellationToken"> The cancellation token to use. </param>
 488        /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/> is null. </exception>
 489        public Response<DigitalTwinsDescriptionListResult> ListByResourceGroup(string resourceGroupName, CancellationTok
 490        {
 0491            if (resourceGroupName == null)
 492            {
 0493                throw new ArgumentNullException(nameof(resourceGroupName));
 494            }
 495
 0496            using var message = CreateListByResourceGroupRequest(resourceGroupName);
 0497            _pipeline.Send(message, cancellationToken);
 0498            switch (message.Response.Status)
 499            {
 500                case 200:
 501                    {
 502                        DigitalTwinsDescriptionListResult value = default;
 0503                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0504                        value = DigitalTwinsDescriptionListResult.DeserializeDigitalTwinsDescriptionListResult(document.
 0505                        return Response.FromValue(value, message.Response);
 506                    }
 507                default:
 0508                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 509            }
 0510        }
 511
 512        internal HttpMessage CreateCheckNameAvailabilityRequest(string location, string name)
 513        {
 4514            var message = _pipeline.CreateMessage();
 4515            var request = message.Request;
 4516            request.Method = RequestMethod.Post;
 4517            var uri = new RawRequestUriBuilder();
 4518            uri.Reset(endpoint);
 4519            uri.AppendPath("/subscriptions/", false);
 4520            uri.AppendPath(subscriptionId, true);
 4521            uri.AppendPath("/providers/Microsoft.DigitalTwins/locations/", false);
 4522            uri.AppendPath(location, true);
 4523            uri.AppendPath("/checkNameAvailability", false);
 4524            uri.AppendQuery("api-version", apiVersion, true);
 4525            request.Uri = uri;
 4526            request.Headers.Add("Content-Type", "application/json");
 4527            var model = new CheckNameRequest(name);
 4528            var content = new Utf8JsonRequestContent();
 4529            content.JsonWriter.WriteObjectValue(model);
 4530            request.Content = content;
 4531            return message;
 532        }
 533
 534        /// <summary> Check if a DigitalTwinsInstance name is available. </summary>
 535        /// <param name="location"> Location of DigitalTwinsInstance. </param>
 536        /// <param name="name"> Resource name. </param>
 537        /// <param name="cancellationToken"> The cancellation token to use. </param>
 538        /// <exception cref="ArgumentNullException"> <paramref name="location"/> or <paramref name="name"/> is null. </e
 539        public async Task<Response<CheckNameResult>> CheckNameAvailabilityAsync(string location, string name, Cancellati
 540        {
 2541            if (location == null)
 542            {
 0543                throw new ArgumentNullException(nameof(location));
 544            }
 2545            if (name == null)
 546            {
 0547                throw new ArgumentNullException(nameof(name));
 548            }
 549
 2550            using var message = CreateCheckNameAvailabilityRequest(location, name);
 2551            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 2552            switch (message.Response.Status)
 553            {
 554                case 200:
 555                    {
 556                        CheckNameResult value = default;
 2557                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 2558                        value = CheckNameResult.DeserializeCheckNameResult(document.RootElement);
 2559                        return Response.FromValue(value, message.Response);
 560                    }
 561                default:
 0562                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 563            }
 2564        }
 565
 566        /// <summary> Check if a DigitalTwinsInstance name is available. </summary>
 567        /// <param name="location"> Location of DigitalTwinsInstance. </param>
 568        /// <param name="name"> Resource name. </param>
 569        /// <param name="cancellationToken"> The cancellation token to use. </param>
 570        /// <exception cref="ArgumentNullException"> <paramref name="location"/> or <paramref name="name"/> is null. </e
 571        public Response<CheckNameResult> CheckNameAvailability(string location, string name, CancellationToken cancellat
 572        {
 2573            if (location == null)
 574            {
 0575                throw new ArgumentNullException(nameof(location));
 576            }
 2577            if (name == null)
 578            {
 0579                throw new ArgumentNullException(nameof(name));
 580            }
 581
 2582            using var message = CreateCheckNameAvailabilityRequest(location, name);
 2583            _pipeline.Send(message, cancellationToken);
 2584            switch (message.Response.Status)
 585            {
 586                case 200:
 587                    {
 588                        CheckNameResult value = default;
 2589                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 2590                        value = CheckNameResult.DeserializeCheckNameResult(document.RootElement);
 2591                        return Response.FromValue(value, message.Response);
 592                    }
 593                default:
 0594                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 595            }
 2596        }
 597
 598        internal HttpMessage CreateListNextPageRequest(string nextLink)
 599        {
 0600            var message = _pipeline.CreateMessage();
 0601            var request = message.Request;
 0602            request.Method = RequestMethod.Get;
 0603            var uri = new RawRequestUriBuilder();
 0604            uri.Reset(endpoint);
 0605            uri.AppendRawNextLink(nextLink, false);
 0606            request.Uri = uri;
 0607            return message;
 608        }
 609
 610        /// <summary> Get all the DigitalTwinsInstances in a subscription. </summary>
 611        /// <param name="nextLink"> The URL to the next page of results. </param>
 612        /// <param name="cancellationToken"> The cancellation token to use. </param>
 613        /// <exception cref="ArgumentNullException"> <paramref name="nextLink"/> is null. </exception>
 614        public async Task<Response<DigitalTwinsDescriptionListResult>> ListNextPageAsync(string nextLink, CancellationTo
 615        {
 0616            if (nextLink == null)
 617            {
 0618                throw new ArgumentNullException(nameof(nextLink));
 619            }
 620
 0621            using var message = CreateListNextPageRequest(nextLink);
 0622            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0623            switch (message.Response.Status)
 624            {
 625                case 200:
 626                    {
 627                        DigitalTwinsDescriptionListResult value = default;
 0628                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0629                        value = DigitalTwinsDescriptionListResult.DeserializeDigitalTwinsDescriptionListResult(document.
 0630                        return Response.FromValue(value, message.Response);
 631                    }
 632                default:
 0633                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 634            }
 0635        }
 636
 637        /// <summary> Get all the DigitalTwinsInstances in a subscription. </summary>
 638        /// <param name="nextLink"> The URL to the next page of results. </param>
 639        /// <param name="cancellationToken"> The cancellation token to use. </param>
 640        /// <exception cref="ArgumentNullException"> <paramref name="nextLink"/> is null. </exception>
 641        public Response<DigitalTwinsDescriptionListResult> ListNextPage(string nextLink, CancellationToken cancellationT
 642        {
 0643            if (nextLink == null)
 644            {
 0645                throw new ArgumentNullException(nameof(nextLink));
 646            }
 647
 0648            using var message = CreateListNextPageRequest(nextLink);
 0649            _pipeline.Send(message, cancellationToken);
 0650            switch (message.Response.Status)
 651            {
 652                case 200:
 653                    {
 654                        DigitalTwinsDescriptionListResult value = default;
 0655                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0656                        value = DigitalTwinsDescriptionListResult.DeserializeDigitalTwinsDescriptionListResult(document.
 0657                        return Response.FromValue(value, message.Response);
 658                    }
 659                default:
 0660                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 661            }
 0662        }
 663
 664        internal HttpMessage CreateListByResourceGroupNextPageRequest(string nextLink, string resourceGroupName)
 665        {
 0666            var message = _pipeline.CreateMessage();
 0667            var request = message.Request;
 0668            request.Method = RequestMethod.Get;
 0669            var uri = new RawRequestUriBuilder();
 0670            uri.Reset(endpoint);
 0671            uri.AppendRawNextLink(nextLink, false);
 0672            request.Uri = uri;
 0673            return message;
 674        }
 675
 676        /// <summary> Get all the DigitalTwinsInstances in a resource group. </summary>
 677        /// <param name="nextLink"> The URL to the next page of results. </param>
 678        /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa
 679        /// <param name="cancellationToken"> The cancellation token to use. </param>
 680        /// <exception cref="ArgumentNullException"> <paramref name="nextLink"/> or <paramref name="resourceGroupName"/>
 681        public async Task<Response<DigitalTwinsDescriptionListResult>> ListByResourceGroupNextPageAsync(string nextLink,
 682        {
 0683            if (nextLink == null)
 684            {
 0685                throw new ArgumentNullException(nameof(nextLink));
 686            }
 0687            if (resourceGroupName == null)
 688            {
 0689                throw new ArgumentNullException(nameof(resourceGroupName));
 690            }
 691
 0692            using var message = CreateListByResourceGroupNextPageRequest(nextLink, resourceGroupName);
 0693            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0694            switch (message.Response.Status)
 695            {
 696                case 200:
 697                    {
 698                        DigitalTwinsDescriptionListResult value = default;
 0699                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0700                        value = DigitalTwinsDescriptionListResult.DeserializeDigitalTwinsDescriptionListResult(document.
 0701                        return Response.FromValue(value, message.Response);
 702                    }
 703                default:
 0704                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 705            }
 0706        }
 707
 708        /// <summary> Get all the DigitalTwinsInstances in a resource group. </summary>
 709        /// <param name="nextLink"> The URL to the next page of results. </param>
 710        /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa
 711        /// <param name="cancellationToken"> The cancellation token to use. </param>
 712        /// <exception cref="ArgumentNullException"> <paramref name="nextLink"/> or <paramref name="resourceGroupName"/>
 713        public Response<DigitalTwinsDescriptionListResult> ListByResourceGroupNextPage(string nextLink, string resourceG
 714        {
 0715            if (nextLink == null)
 716            {
 0717                throw new ArgumentNullException(nameof(nextLink));
 718            }
 0719            if (resourceGroupName == null)
 720            {
 0721                throw new ArgumentNullException(nameof(resourceGroupName));
 722            }
 723
 0724            using var message = CreateListByResourceGroupNextPageRequest(nextLink, resourceGroupName);
 0725            _pipeline.Send(message, cancellationToken);
 0726            switch (message.Response.Status)
 727            {
 728                case 200:
 729                    {
 730                        DigitalTwinsDescriptionListResult value = default;
 0731                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0732                        value = DigitalTwinsDescriptionListResult.DeserializeDigitalTwinsDescriptionListResult(document.
 0733                        return Response.FromValue(value, message.Response);
 734                    }
 735                default:
 0736                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 737            }
 0738        }
 739    }
 740}