< Summary

Class:Azure.ResourceManager.DigitalTwins.DigitalTwinsEndpointRestOperations
Assembly:Azure.ResourceManager.DigitalTwins
File(s):C:\Git\azure-sdk-for-net\sdk\digitaltwins\Azure.ResourceManager.DigitalTwins\src\Generated\DigitalTwinsEndpointRestOperations.cs
Covered lines:0
Uncovered lines:219
Coverable lines:219
Total lines:500
Line coverage:0% (0 of 219)
Covered branches:0
Total branches:90
Branch coverage:0% (0 of 90)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%0%
CreateListRequest(...)-0%100%
ListAsync()-0%0%
List(...)-0%0%
CreateGetRequest(...)-0%100%
GetAsync()-0%0%
Get(...)-0%0%
CreateCreateOrUpdateRequest(...)-0%100%
CreateOrUpdateAsync()-0%0%
CreateOrUpdate(...)-0%0%
CreateDeleteRequest(...)-0%100%
DeleteAsync()-0%0%
Delete(...)-0%0%
CreateListNextPageRequest(...)-0%100%
ListNextPageAsync()-0%0%
ListNextPage(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\digitaltwins\Azure.ResourceManager.DigitalTwins\src\Generated\DigitalTwinsEndpointRestOperations.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.Core;
 14using Azure.Core.Pipeline;
 15using Azure.ResourceManager.DigitalTwins.Models;
 16
 17namespace Azure.ResourceManager.DigitalTwins
 18{
 19    internal partial class DigitalTwinsEndpointRestOperations
 20    {
 21        private string subscriptionId;
 22        private Uri endpoint;
 23        private string apiVersion;
 24        private ClientDiagnostics _clientDiagnostics;
 25        private HttpPipeline _pipeline;
 26
 27        /// <summary> Initializes a new instance of DigitalTwinsEndpointRestOperations. </summary>
 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>
 30        /// <param name="subscriptionId"> The subscription identifier. </param>
 31        /// <param name="endpoint"> server parameter. </param>
 32        /// <param name="apiVersion"> Api Version. </param>
 33        /// <exception cref="ArgumentNullException"> <paramref name="subscriptionId"/> or <paramref name="apiVersion"/> 
 034        public DigitalTwinsEndpointRestOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string sub
 35        {
 036            if (subscriptionId == null)
 37            {
 038                throw new ArgumentNullException(nameof(subscriptionId));
 39            }
 040            endpoint ??= new Uri("https://management.azure.com");
 041            if (apiVersion == null)
 42            {
 043                throw new ArgumentNullException(nameof(apiVersion));
 44            }
 45
 046            this.subscriptionId = subscriptionId;
 047            this.endpoint = endpoint;
 048            this.apiVersion = apiVersion;
 049            _clientDiagnostics = clientDiagnostics;
 050            _pipeline = pipeline;
 051        }
 52
 53        internal HttpMessage CreateListRequest(string resourceGroupName, string resourceName)
 54        {
 055            var message = _pipeline.CreateMessage();
 056            var request = message.Request;
 057            request.Method = RequestMethod.Get;
 058            var uri = new RawRequestUriBuilder();
 059            uri.Reset(endpoint);
 060            uri.AppendPath("/subscriptions/", false);
 061            uri.AppendPath(subscriptionId, true);
 062            uri.AppendPath("/resourceGroups/", false);
 063            uri.AppendPath(resourceGroupName, true);
 064            uri.AppendPath("/providers/Microsoft.DigitalTwins/digitalTwinsInstances/", false);
 065            uri.AppendPath(resourceName, true);
 066            uri.AppendPath("/endpoints", false);
 067            uri.AppendQuery("api-version", apiVersion, true);
 068            request.Uri = uri;
 069            return message;
 70        }
 71
 72        /// <summary> Get DigitalTwinsInstance Endpoints. </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<DigitalTwinsEndpointResourceListResult>> ListAsync(string resourceGroupName, string r
 78        {
 079            if (resourceGroupName == null)
 80            {
 081                throw new ArgumentNullException(nameof(resourceGroupName));
 82            }
 083            if (resourceName == null)
 84            {
 085                throw new ArgumentNullException(nameof(resourceName));
 86            }
 87
 088            using var message = CreateListRequest(resourceGroupName, resourceName);
 089            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 090            switch (message.Response.Status)
 91            {
 92                case 200:
 93                    {
 94                        DigitalTwinsEndpointResourceListResult value = default;
 095                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 096                        value = DigitalTwinsEndpointResourceListResult.DeserializeDigitalTwinsEndpointResourceListResult
 097                        return Response.FromValue(value, message.Response);
 98                    }
 99                default:
 0100                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 101            }
 0102        }
 103
 104        /// <summary> Get DigitalTwinsInstance Endpoints. </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<DigitalTwinsEndpointResourceListResult> List(string resourceGroupName, string resourceName, Canc
 110        {
 0111            if (resourceGroupName == null)
 112            {
 0113                throw new ArgumentNullException(nameof(resourceGroupName));
 114            }
 0115            if (resourceName == null)
 116            {
 0117                throw new ArgumentNullException(nameof(resourceName));
 118            }
 119
 0120            using var message = CreateListRequest(resourceGroupName, resourceName);
 0121            _pipeline.Send(message, cancellationToken);
 0122            switch (message.Response.Status)
 123            {
 124                case 200:
 125                    {
 126                        DigitalTwinsEndpointResourceListResult value = default;
 0127                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0128                        value = DigitalTwinsEndpointResourceListResult.DeserializeDigitalTwinsEndpointResourceListResult
 0129                        return Response.FromValue(value, message.Response);
 130                    }
 131                default:
 0132                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 133            }
 0134        }
 135
 136        internal HttpMessage CreateGetRequest(string resourceGroupName, string resourceName, string endpointName)
 137        {
 0138            var message = _pipeline.CreateMessage();
 0139            var request = message.Request;
 0140            request.Method = RequestMethod.Get;
 0141            var uri = new RawRequestUriBuilder();
 0142            uri.Reset(endpoint);
 0143            uri.AppendPath("/subscriptions/", false);
 0144            uri.AppendPath(subscriptionId, true);
 0145            uri.AppendPath("/resourceGroups/", false);
 0146            uri.AppendPath(resourceGroupName, true);
 0147            uri.AppendPath("/providers/Microsoft.DigitalTwins/digitalTwinsInstances/", false);
 0148            uri.AppendPath(resourceName, true);
 0149            uri.AppendPath("/endpoints/", false);
 0150            uri.AppendPath(endpointName, true);
 0151            uri.AppendQuery("api-version", apiVersion, true);
 0152            request.Uri = uri;
 0153            return message;
 154        }
 155
 156        /// <summary> Get DigitalTwinsInstances Endpoint. </summary>
 157        /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa
 158        /// <param name="resourceName"> The name of the DigitalTwinsInstance. </param>
 159        /// <param name="endpointName"> Name of Endpoint Resource. </param>
 160        /// <param name="cancellationToken"> The cancellation token to use. </param>
 161        /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/>, <paramref name="resourceName"
 162        public async Task<Response<DigitalTwinsEndpointResource>> GetAsync(string resourceGroupName, string resourceName
 163        {
 0164            if (resourceGroupName == null)
 165            {
 0166                throw new ArgumentNullException(nameof(resourceGroupName));
 167            }
 0168            if (resourceName == null)
 169            {
 0170                throw new ArgumentNullException(nameof(resourceName));
 171            }
 0172            if (endpointName == null)
 173            {
 0174                throw new ArgumentNullException(nameof(endpointName));
 175            }
 176
 0177            using var message = CreateGetRequest(resourceGroupName, resourceName, endpointName);
 0178            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0179            switch (message.Response.Status)
 180            {
 181                case 200:
 182                    {
 183                        DigitalTwinsEndpointResource value = default;
 0184                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0185                        value = DigitalTwinsEndpointResource.DeserializeDigitalTwinsEndpointResource(document.RootElemen
 0186                        return Response.FromValue(value, message.Response);
 187                    }
 188                default:
 0189                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 190            }
 0191        }
 192
 193        /// <summary> Get DigitalTwinsInstances Endpoint. </summary>
 194        /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa
 195        /// <param name="resourceName"> The name of the DigitalTwinsInstance. </param>
 196        /// <param name="endpointName"> Name of Endpoint Resource. </param>
 197        /// <param name="cancellationToken"> The cancellation token to use. </param>
 198        /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/>, <paramref name="resourceName"
 199        public Response<DigitalTwinsEndpointResource> Get(string resourceGroupName, string resourceName, string endpoint
 200        {
 0201            if (resourceGroupName == null)
 202            {
 0203                throw new ArgumentNullException(nameof(resourceGroupName));
 204            }
 0205            if (resourceName == null)
 206            {
 0207                throw new ArgumentNullException(nameof(resourceName));
 208            }
 0209            if (endpointName == null)
 210            {
 0211                throw new ArgumentNullException(nameof(endpointName));
 212            }
 213
 0214            using var message = CreateGetRequest(resourceGroupName, resourceName, endpointName);
 0215            _pipeline.Send(message, cancellationToken);
 0216            switch (message.Response.Status)
 217            {
 218                case 200:
 219                    {
 220                        DigitalTwinsEndpointResource value = default;
 0221                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0222                        value = DigitalTwinsEndpointResource.DeserializeDigitalTwinsEndpointResource(document.RootElemen
 0223                        return Response.FromValue(value, message.Response);
 224                    }
 225                default:
 0226                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 227            }
 0228        }
 229
 230        internal HttpMessage CreateCreateOrUpdateRequest(string resourceGroupName, string resourceName, string endpointN
 231        {
 0232            var message = _pipeline.CreateMessage();
 0233            var request = message.Request;
 0234            request.Method = RequestMethod.Put;
 0235            var uri = new RawRequestUriBuilder();
 0236            uri.Reset(endpoint);
 0237            uri.AppendPath("/subscriptions/", false);
 0238            uri.AppendPath(subscriptionId, true);
 0239            uri.AppendPath("/resourceGroups/", false);
 0240            uri.AppendPath(resourceGroupName, true);
 0241            uri.AppendPath("/providers/Microsoft.DigitalTwins/digitalTwinsInstances/", false);
 0242            uri.AppendPath(resourceName, true);
 0243            uri.AppendPath("/endpoints/", false);
 0244            uri.AppendPath(endpointName, true);
 0245            uri.AppendQuery("api-version", apiVersion, true);
 0246            request.Uri = uri;
 0247            request.Headers.Add("Content-Type", "application/json");
 0248            var model = new DigitalTwinsEndpointResource()
 0249            {
 0250                Properties = properties
 0251            };
 0252            var content = new Utf8JsonRequestContent();
 0253            content.JsonWriter.WriteObjectValue(model);
 0254            request.Content = content;
 0255            return message;
 256        }
 257
 258        /// <summary> Create or update DigitalTwinsInstance endpoint. </summary>
 259        /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa
 260        /// <param name="resourceName"> The name of the DigitalTwinsInstance. </param>
 261        /// <param name="endpointName"> Name of Endpoint Resource. </param>
 262        /// <param name="properties"> DigitalTwinsInstance endpoint resource properties. </param>
 263        /// <param name="cancellationToken"> The cancellation token to use. </param>
 264        /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/>, <paramref name="resourceName"
 265        public async Task<Response> CreateOrUpdateAsync(string resourceGroupName, string resourceName, string endpointNa
 266        {
 0267            if (resourceGroupName == null)
 268            {
 0269                throw new ArgumentNullException(nameof(resourceGroupName));
 270            }
 0271            if (resourceName == null)
 272            {
 0273                throw new ArgumentNullException(nameof(resourceName));
 274            }
 0275            if (endpointName == null)
 276            {
 0277                throw new ArgumentNullException(nameof(endpointName));
 278            }
 279
 0280            using var message = CreateCreateOrUpdateRequest(resourceGroupName, resourceName, endpointName, properties);
 0281            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0282            switch (message.Response.Status)
 283            {
 284                case 200:
 285                case 201:
 0286                    return message.Response;
 287                default:
 0288                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 289            }
 0290        }
 291
 292        /// <summary> Create or update DigitalTwinsInstance endpoint. </summary>
 293        /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa
 294        /// <param name="resourceName"> The name of the DigitalTwinsInstance. </param>
 295        /// <param name="endpointName"> Name of Endpoint Resource. </param>
 296        /// <param name="properties"> DigitalTwinsInstance endpoint resource properties. </param>
 297        /// <param name="cancellationToken"> The cancellation token to use. </param>
 298        /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/>, <paramref name="resourceName"
 299        public Response CreateOrUpdate(string resourceGroupName, string resourceName, string endpointName, DigitalTwinsE
 300        {
 0301            if (resourceGroupName == null)
 302            {
 0303                throw new ArgumentNullException(nameof(resourceGroupName));
 304            }
 0305            if (resourceName == null)
 306            {
 0307                throw new ArgumentNullException(nameof(resourceName));
 308            }
 0309            if (endpointName == null)
 310            {
 0311                throw new ArgumentNullException(nameof(endpointName));
 312            }
 313
 0314            using var message = CreateCreateOrUpdateRequest(resourceGroupName, resourceName, endpointName, properties);
 0315            _pipeline.Send(message, cancellationToken);
 0316            switch (message.Response.Status)
 317            {
 318                case 200:
 319                case 201:
 0320                    return message.Response;
 321                default:
 0322                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 323            }
 0324        }
 325
 326        internal HttpMessage CreateDeleteRequest(string resourceGroupName, string resourceName, string endpointName)
 327        {
 0328            var message = _pipeline.CreateMessage();
 0329            var request = message.Request;
 0330            request.Method = RequestMethod.Delete;
 0331            var uri = new RawRequestUriBuilder();
 0332            uri.Reset(endpoint);
 0333            uri.AppendPath("/subscriptions/", false);
 0334            uri.AppendPath(subscriptionId, true);
 0335            uri.AppendPath("/resourceGroups/", false);
 0336            uri.AppendPath(resourceGroupName, true);
 0337            uri.AppendPath("/providers/Microsoft.DigitalTwins/digitalTwinsInstances/", false);
 0338            uri.AppendPath(resourceName, true);
 0339            uri.AppendPath("/endpoints/", false);
 0340            uri.AppendPath(endpointName, true);
 0341            uri.AppendQuery("api-version", apiVersion, true);
 0342            request.Uri = uri;
 0343            return message;
 344        }
 345
 346        /// <summary> Delete a DigitalTwinsInstance endpoint. </summary>
 347        /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa
 348        /// <param name="resourceName"> The name of the DigitalTwinsInstance. </param>
 349        /// <param name="endpointName"> Name of Endpoint Resource. </param>
 350        /// <param name="cancellationToken"> The cancellation token to use. </param>
 351        /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/>, <paramref name="resourceName"
 352        public async Task<Response> DeleteAsync(string resourceGroupName, string resourceName, string endpointName, Canc
 353        {
 0354            if (resourceGroupName == null)
 355            {
 0356                throw new ArgumentNullException(nameof(resourceGroupName));
 357            }
 0358            if (resourceName == null)
 359            {
 0360                throw new ArgumentNullException(nameof(resourceName));
 361            }
 0362            if (endpointName == null)
 363            {
 0364                throw new ArgumentNullException(nameof(endpointName));
 365            }
 366
 0367            using var message = CreateDeleteRequest(resourceGroupName, resourceName, endpointName);
 0368            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0369            switch (message.Response.Status)
 370            {
 371                case 200:
 372                case 202:
 373                case 204:
 0374                    return message.Response;
 375                default:
 0376                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 377            }
 0378        }
 379
 380        /// <summary> Delete a DigitalTwinsInstance endpoint. </summary>
 381        /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa
 382        /// <param name="resourceName"> The name of the DigitalTwinsInstance. </param>
 383        /// <param name="endpointName"> Name of Endpoint Resource. </param>
 384        /// <param name="cancellationToken"> The cancellation token to use. </param>
 385        /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/>, <paramref name="resourceName"
 386        public Response Delete(string resourceGroupName, string resourceName, string endpointName, CancellationToken can
 387        {
 0388            if (resourceGroupName == null)
 389            {
 0390                throw new ArgumentNullException(nameof(resourceGroupName));
 391            }
 0392            if (resourceName == null)
 393            {
 0394                throw new ArgumentNullException(nameof(resourceName));
 395            }
 0396            if (endpointName == null)
 397            {
 0398                throw new ArgumentNullException(nameof(endpointName));
 399            }
 400
 0401            using var message = CreateDeleteRequest(resourceGroupName, resourceName, endpointName);
 0402            _pipeline.Send(message, cancellationToken);
 0403            switch (message.Response.Status)
 404            {
 405                case 200:
 406                case 202:
 407                case 204:
 0408                    return message.Response;
 409                default:
 0410                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 411            }
 0412        }
 413
 414        internal HttpMessage CreateListNextPageRequest(string nextLink, string resourceGroupName, string resourceName)
 415        {
 0416            var message = _pipeline.CreateMessage();
 0417            var request = message.Request;
 0418            request.Method = RequestMethod.Get;
 0419            var uri = new RawRequestUriBuilder();
 0420            uri.Reset(endpoint);
 0421            uri.AppendRawNextLink(nextLink, false);
 0422            request.Uri = uri;
 0423            return message;
 424        }
 425
 426        /// <summary> Get DigitalTwinsInstance Endpoints. </summary>
 427        /// <param name="nextLink"> The URL to the next page of results. </param>
 428        /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa
 429        /// <param name="resourceName"> The name of the DigitalTwinsInstance. </param>
 430        /// <param name="cancellationToken"> The cancellation token to use. </param>
 431        /// <exception cref="ArgumentNullException"> <paramref name="nextLink"/>, <paramref name="resourceGroupName"/>, 
 432        public async Task<Response<DigitalTwinsEndpointResourceListResult>> ListNextPageAsync(string nextLink, string re
 433        {
 0434            if (nextLink == null)
 435            {
 0436                throw new ArgumentNullException(nameof(nextLink));
 437            }
 0438            if (resourceGroupName == null)
 439            {
 0440                throw new ArgumentNullException(nameof(resourceGroupName));
 441            }
 0442            if (resourceName == null)
 443            {
 0444                throw new ArgumentNullException(nameof(resourceName));
 445            }
 446
 0447            using var message = CreateListNextPageRequest(nextLink, resourceGroupName, resourceName);
 0448            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 0449            switch (message.Response.Status)
 450            {
 451                case 200:
 452                    {
 453                        DigitalTwinsEndpointResourceListResult value = default;
 0454                        using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc
 0455                        value = DigitalTwinsEndpointResourceListResult.DeserializeDigitalTwinsEndpointResourceListResult
 0456                        return Response.FromValue(value, message.Response);
 457                    }
 458                default:
 0459                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa
 460            }
 0461        }
 462
 463        /// <summary> Get DigitalTwinsInstance Endpoints. </summary>
 464        /// <param name="nextLink"> The URL to the next page of results. </param>
 465        /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa
 466        /// <param name="resourceName"> The name of the DigitalTwinsInstance. </param>
 467        /// <param name="cancellationToken"> The cancellation token to use. </param>
 468        /// <exception cref="ArgumentNullException"> <paramref name="nextLink"/>, <paramref name="resourceGroupName"/>, 
 469        public Response<DigitalTwinsEndpointResourceListResult> ListNextPage(string nextLink, string resourceGroupName, 
 470        {
 0471            if (nextLink == null)
 472            {
 0473                throw new ArgumentNullException(nameof(nextLink));
 474            }
 0475            if (resourceGroupName == null)
 476            {
 0477                throw new ArgumentNullException(nameof(resourceGroupName));
 478            }
 0479            if (resourceName == null)
 480            {
 0481                throw new ArgumentNullException(nameof(resourceName));
 482            }
 483
 0484            using var message = CreateListNextPageRequest(nextLink, resourceGroupName, resourceName);
 0485            _pipeline.Send(message, cancellationToken);
 0486            switch (message.Response.Status)
 487            {
 488                case 200:
 489                    {
 490                        DigitalTwinsEndpointResourceListResult value = default;
 0491                        using var document = JsonDocument.Parse(message.Response.ContentStream);
 0492                        value = DigitalTwinsEndpointResourceListResult.DeserializeDigitalTwinsEndpointResourceListResult
 0493                        return Response.FromValue(value, message.Response);
 494                    }
 495                default:
 0496                    throw _clientDiagnostics.CreateRequestFailedException(message.Response);
 497            }
 0498        }
 499    }
 500}