< Summary

Class:Azure.ResourceManager.DigitalTwins.DigitalTwinsOperations
Assembly:Azure.ResourceManager.DigitalTwins
File(s):C:\Git\azure-sdk-for-net\sdk\digitaltwins\Azure.ResourceManager.DigitalTwins\src\Generated\DigitalTwinsOperations.cs
Covered lines:66
Uncovered lines:118
Coverable lines:184
Total lines:472
Line coverage:35.8% (66 of 184)
Covered branches:10
Total branches:32
Branch coverage:31.2% (10 of 32)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
get_RestClient()-100%100%
.ctor()-100%100%
.ctor(...)-100%100%
GetAsync()-57.14%100%
Get(...)-57.14%100%
CheckNameAvailabilityAsync()-57.14%100%
CheckNameAvailability(...)-57.14%100%
<ListAsync()-62.5%100%
<ListAsync()-0%100%
ListAsync(...)-100%100%
List(...)-100%100%
ListByResourceGroupAsync(...)-0%0%
<ListByResourceGroupAsync()-0%100%
<ListByResourceGroupAsync()-0%100%
ListByResourceGroup(...)-0%0%
StartCreateOrUpdateAsync()-57.14%50%
StartCreateOrUpdate(...)-57.14%50%
StartUpdateAsync()-0%0%
StartUpdate(...)-0%0%
StartDeleteAsync()-58.33%50%
StartDelete(...)-58.33%50%

File(s)

C:\Git\azure-sdk-for-net\sdk\digitaltwins\Azure.ResourceManager.DigitalTwins\src\Generated\DigitalTwinsOperations.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.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    /// <summary> The DigitalTwins service client. </summary>
 20    public partial class DigitalTwinsOperations
 21    {
 22        private readonly ClientDiagnostics _clientDiagnostics;
 23        private readonly HttpPipeline _pipeline;
 2824        internal DigitalTwinsRestOperations RestClient { get; }
 25        /// <summary> Initializes a new instance of DigitalTwinsOperations for mocking. </summary>
 2026        protected DigitalTwinsOperations()
 27        {
 2028        }
 29        /// <summary> Initializes a new instance of DigitalTwinsOperations. </summary>
 30        /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param>
 31        /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param>
 32        /// <param name="subscriptionId"> The subscription identifier. </param>
 33        /// <param name="endpoint"> server parameter. </param>
 34        /// <param name="apiVersion"> Api Version. </param>
 2035        internal DigitalTwinsOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionI
 36        {
 2037            RestClient = new DigitalTwinsRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint, apiVersio
 2038            _clientDiagnostics = clientDiagnostics;
 2039            _pipeline = pipeline;
 2040        }
 41
 42        /// <summary> Get DigitalTwinsInstances resource. </summary>
 43        /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa
 44        /// <param name="resourceName"> The name of the DigitalTwinsInstance. </param>
 45        /// <param name="cancellationToken"> The cancellation token to use. </param>
 46        public virtual async Task<Response<DigitalTwinsDescription>> GetAsync(string resourceGroupName, string resourceN
 47        {
 248            using var scope = _clientDiagnostics.CreateScope("DigitalTwinsOperations.Get");
 249            scope.Start();
 50            try
 51            {
 252                return await RestClient.GetAsync(resourceGroupName, resourceName, cancellationToken).ConfigureAwait(fals
 53            }
 054            catch (Exception e)
 55            {
 056                scope.Failed(e);
 057                throw;
 58            }
 259        }
 60
 61        /// <summary> Get DigitalTwinsInstances resource. </summary>
 62        /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa
 63        /// <param name="resourceName"> The name of the DigitalTwinsInstance. </param>
 64        /// <param name="cancellationToken"> The cancellation token to use. </param>
 65        public virtual Response<DigitalTwinsDescription> Get(string resourceGroupName, string resourceName, Cancellation
 66        {
 267            using var scope = _clientDiagnostics.CreateScope("DigitalTwinsOperations.Get");
 268            scope.Start();
 69            try
 70            {
 271                return RestClient.Get(resourceGroupName, resourceName, cancellationToken);
 72            }
 073            catch (Exception e)
 74            {
 075                scope.Failed(e);
 076                throw;
 77            }
 278        }
 79
 80        /// <summary> Check if a DigitalTwinsInstance name is available. </summary>
 81        /// <param name="location"> Location of DigitalTwinsInstance. </param>
 82        /// <param name="name"> Resource name. </param>
 83        /// <param name="cancellationToken"> The cancellation token to use. </param>
 84        public virtual async Task<Response<CheckNameResult>> CheckNameAvailabilityAsync(string location, string name, Ca
 85        {
 286            using var scope = _clientDiagnostics.CreateScope("DigitalTwinsOperations.CheckNameAvailability");
 287            scope.Start();
 88            try
 89            {
 290                return await RestClient.CheckNameAvailabilityAsync(location, name, cancellationToken).ConfigureAwait(fal
 91            }
 092            catch (Exception e)
 93            {
 094                scope.Failed(e);
 095                throw;
 96            }
 297        }
 98
 99        /// <summary> Check if a DigitalTwinsInstance name is available. </summary>
 100        /// <param name="location"> Location of DigitalTwinsInstance. </param>
 101        /// <param name="name"> Resource name. </param>
 102        /// <param name="cancellationToken"> The cancellation token to use. </param>
 103        public virtual Response<CheckNameResult> CheckNameAvailability(string location, string name, CancellationToken c
 104        {
 2105            using var scope = _clientDiagnostics.CreateScope("DigitalTwinsOperations.CheckNameAvailability");
 2106            scope.Start();
 107            try
 108            {
 2109                return RestClient.CheckNameAvailability(location, name, cancellationToken);
 110            }
 0111            catch (Exception e)
 112            {
 0113                scope.Failed(e);
 0114                throw;
 115            }
 2116        }
 117
 118        /// <summary> Get all the DigitalTwinsInstances in a subscription. </summary>
 119        /// <param name="cancellationToken"> The cancellation token to use. </param>
 120        public virtual AsyncPageable<DigitalTwinsDescription> ListAsync(CancellationToken cancellationToken = default)
 121        {
 122            async Task<Page<DigitalTwinsDescription>> FirstPageFunc(int? pageSizeHint)
 123            {
 2124                using var scope = _clientDiagnostics.CreateScope("DigitalTwinsOperations.List");
 2125                scope.Start();
 126                try
 127                {
 2128                    var response = await RestClient.ListAsync(cancellationToken).ConfigureAwait(false);
 2129                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 130                }
 0131                catch (Exception e)
 132                {
 0133                    scope.Failed(e);
 0134                    throw;
 135                }
 2136            }
 137            async Task<Page<DigitalTwinsDescription>> NextPageFunc(string nextLink, int? pageSizeHint)
 138            {
 0139                using var scope = _clientDiagnostics.CreateScope("DigitalTwinsOperations.List");
 0140                scope.Start();
 141                try
 142                {
 0143                    var response = await RestClient.ListNextPageAsync(nextLink, cancellationToken).ConfigureAwait(false)
 0144                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 145                }
 0146                catch (Exception e)
 147                {
 0148                    scope.Failed(e);
 0149                    throw;
 150                }
 0151            }
 2152            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
 153        }
 154
 155        /// <summary> Get all the DigitalTwinsInstances in a subscription. </summary>
 156        /// <param name="cancellationToken"> The cancellation token to use. </param>
 157        public virtual Pageable<DigitalTwinsDescription> List(CancellationToken cancellationToken = default)
 158        {
 159            Page<DigitalTwinsDescription> FirstPageFunc(int? pageSizeHint)
 160            {
 2161                using var scope = _clientDiagnostics.CreateScope("DigitalTwinsOperations.List");
 2162                scope.Start();
 163                try
 164                {
 2165                    var response = RestClient.List(cancellationToken);
 2166                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 167                }
 0168                catch (Exception e)
 169                {
 0170                    scope.Failed(e);
 0171                    throw;
 172                }
 2173            }
 174            Page<DigitalTwinsDescription> NextPageFunc(string nextLink, int? pageSizeHint)
 175            {
 0176                using var scope = _clientDiagnostics.CreateScope("DigitalTwinsOperations.List");
 0177                scope.Start();
 178                try
 179                {
 0180                    var response = RestClient.ListNextPage(nextLink, cancellationToken);
 0181                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 182                }
 0183                catch (Exception e)
 184                {
 0185                    scope.Failed(e);
 0186                    throw;
 187                }
 0188            }
 2189            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 190        }
 191
 192        /// <summary> Get all the DigitalTwinsInstances in a resource group. </summary>
 193        /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa
 194        /// <param name="cancellationToken"> The cancellation token to use. </param>
 195        /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/> is null. </exception>
 196        public virtual AsyncPageable<DigitalTwinsDescription> ListByResourceGroupAsync(string resourceGroupName, Cancell
 197        {
 0198            if (resourceGroupName == null)
 199            {
 0200                throw new ArgumentNullException(nameof(resourceGroupName));
 201            }
 202
 203            async Task<Page<DigitalTwinsDescription>> FirstPageFunc(int? pageSizeHint)
 204            {
 0205                using var scope = _clientDiagnostics.CreateScope("DigitalTwinsOperations.ListByResourceGroup");
 0206                scope.Start();
 207                try
 208                {
 0209                    var response = await RestClient.ListByResourceGroupAsync(resourceGroupName, cancellationToken).Confi
 0210                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 211                }
 0212                catch (Exception e)
 213                {
 0214                    scope.Failed(e);
 0215                    throw;
 216                }
 0217            }
 218            async Task<Page<DigitalTwinsDescription>> NextPageFunc(string nextLink, int? pageSizeHint)
 219            {
 0220                using var scope = _clientDiagnostics.CreateScope("DigitalTwinsOperations.ListByResourceGroup");
 0221                scope.Start();
 222                try
 223                {
 0224                    var response = await RestClient.ListByResourceGroupNextPageAsync(nextLink, resourceGroupName, cancel
 0225                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 226                }
 0227                catch (Exception e)
 228                {
 0229                    scope.Failed(e);
 0230                    throw;
 231                }
 0232            }
 0233            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
 234        }
 235
 236        /// <summary> Get all the DigitalTwinsInstances in a resource group. </summary>
 237        /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa
 238        /// <param name="cancellationToken"> The cancellation token to use. </param>
 239        /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/> is null. </exception>
 240        public virtual Pageable<DigitalTwinsDescription> ListByResourceGroup(string resourceGroupName, CancellationToken
 241        {
 0242            if (resourceGroupName == null)
 243            {
 0244                throw new ArgumentNullException(nameof(resourceGroupName));
 245            }
 246
 247            Page<DigitalTwinsDescription> FirstPageFunc(int? pageSizeHint)
 248            {
 0249                using var scope = _clientDiagnostics.CreateScope("DigitalTwinsOperations.ListByResourceGroup");
 0250                scope.Start();
 251                try
 252                {
 0253                    var response = RestClient.ListByResourceGroup(resourceGroupName, cancellationToken);
 0254                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 255                }
 0256                catch (Exception e)
 257                {
 0258                    scope.Failed(e);
 0259                    throw;
 260                }
 0261            }
 262            Page<DigitalTwinsDescription> NextPageFunc(string nextLink, int? pageSizeHint)
 263            {
 0264                using var scope = _clientDiagnostics.CreateScope("DigitalTwinsOperations.ListByResourceGroup");
 0265                scope.Start();
 266                try
 267                {
 0268                    var response = RestClient.ListByResourceGroupNextPage(nextLink, resourceGroupName, cancellationToken
 0269                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 270                }
 0271                catch (Exception e)
 272                {
 0273                    scope.Failed(e);
 0274                    throw;
 275                }
 0276            }
 0277            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 278        }
 279
 280        /// <summary> Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property is
 281        /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa
 282        /// <param name="resourceName"> The name of the DigitalTwinsInstance. </param>
 283        /// <param name="digitalTwinsCreate"> The DigitalTwinsInstance and security metadata. </param>
 284        /// <param name="cancellationToken"> The cancellation token to use. </param>
 285        /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/>, <paramref name="resourceName"
 286        public virtual async Task<DigitalTwinsCreateOrUpdateOperation> StartCreateOrUpdateAsync(string resourceGroupName
 287        {
 2288            if (resourceGroupName == null)
 289            {
 0290                throw new ArgumentNullException(nameof(resourceGroupName));
 291            }
 2292            if (resourceName == null)
 293            {
 0294                throw new ArgumentNullException(nameof(resourceName));
 295            }
 2296            if (digitalTwinsCreate == null)
 297            {
 0298                throw new ArgumentNullException(nameof(digitalTwinsCreate));
 299            }
 300
 2301            using var scope = _clientDiagnostics.CreateScope("DigitalTwinsOperations.StartCreateOrUpdate");
 2302            scope.Start();
 303            try
 304            {
 2305                var originalResponse = await RestClient.CreateOrUpdateAsync(resourceGroupName, resourceName, digitalTwin
 2306                return new DigitalTwinsCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateOrU
 307            }
 0308            catch (Exception e)
 309            {
 0310                scope.Failed(e);
 0311                throw;
 312            }
 2313        }
 314
 315        /// <summary> Create or update the metadata of a DigitalTwinsInstance. The usual pattern to modify a property is
 316        /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa
 317        /// <param name="resourceName"> The name of the DigitalTwinsInstance. </param>
 318        /// <param name="digitalTwinsCreate"> The DigitalTwinsInstance and security metadata. </param>
 319        /// <param name="cancellationToken"> The cancellation token to use. </param>
 320        /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/>, <paramref name="resourceName"
 321        public virtual DigitalTwinsCreateOrUpdateOperation StartCreateOrUpdate(string resourceGroupName, string resource
 322        {
 2323            if (resourceGroupName == null)
 324            {
 0325                throw new ArgumentNullException(nameof(resourceGroupName));
 326            }
 2327            if (resourceName == null)
 328            {
 0329                throw new ArgumentNullException(nameof(resourceName));
 330            }
 2331            if (digitalTwinsCreate == null)
 332            {
 0333                throw new ArgumentNullException(nameof(digitalTwinsCreate));
 334            }
 335
 2336            using var scope = _clientDiagnostics.CreateScope("DigitalTwinsOperations.StartCreateOrUpdate");
 2337            scope.Start();
 338            try
 339            {
 2340                var originalResponse = RestClient.CreateOrUpdate(resourceGroupName, resourceName, digitalTwinsCreate, ca
 2341                return new DigitalTwinsCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateOrU
 342            }
 0343            catch (Exception e)
 344            {
 0345                scope.Failed(e);
 0346                throw;
 347            }
 2348        }
 349
 350        /// <summary> Update metadata of DigitalTwinsInstance. </summary>
 351        /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa
 352        /// <param name="resourceName"> The name of the DigitalTwinsInstance. </param>
 353        /// <param name="tags"> Instance tags. </param>
 354        /// <param name="cancellationToken"> The cancellation token to use. </param>
 355        /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/> or <paramref name="resourceNam
 356        public virtual async Task<DigitalTwinsUpdateOperation> StartUpdateAsync(string resourceGroupName, string resourc
 357        {
 0358            if (resourceGroupName == null)
 359            {
 0360                throw new ArgumentNullException(nameof(resourceGroupName));
 361            }
 0362            if (resourceName == null)
 363            {
 0364                throw new ArgumentNullException(nameof(resourceName));
 365            }
 366
 0367            using var scope = _clientDiagnostics.CreateScope("DigitalTwinsOperations.StartUpdate");
 0368            scope.Start();
 369            try
 370            {
 0371                var originalResponse = await RestClient.UpdateAsync(resourceGroupName, resourceName, tags, cancellationT
 0372                return new DigitalTwinsUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateUpdateRequest(res
 373            }
 0374            catch (Exception e)
 375            {
 0376                scope.Failed(e);
 0377                throw;
 378            }
 0379        }
 380
 381        /// <summary> Update metadata of DigitalTwinsInstance. </summary>
 382        /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa
 383        /// <param name="resourceName"> The name of the DigitalTwinsInstance. </param>
 384        /// <param name="tags"> Instance tags. </param>
 385        /// <param name="cancellationToken"> The cancellation token to use. </param>
 386        /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/> or <paramref name="resourceNam
 387        public virtual DigitalTwinsUpdateOperation StartUpdate(string resourceGroupName, string resourceName, IDictionar
 388        {
 0389            if (resourceGroupName == null)
 390            {
 0391                throw new ArgumentNullException(nameof(resourceGroupName));
 392            }
 0393            if (resourceName == null)
 394            {
 0395                throw new ArgumentNullException(nameof(resourceName));
 396            }
 397
 0398            using var scope = _clientDiagnostics.CreateScope("DigitalTwinsOperations.StartUpdate");
 0399            scope.Start();
 400            try
 401            {
 0402                var originalResponse = RestClient.Update(resourceGroupName, resourceName, tags, cancellationToken);
 0403                return new DigitalTwinsUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateUpdateRequest(res
 404            }
 0405            catch (Exception e)
 406            {
 0407                scope.Failed(e);
 0408                throw;
 409            }
 0410        }
 411
 412        /// <summary> Delete a DigitalTwinsInstance. </summary>
 413        /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa
 414        /// <param name="resourceName"> The name of the DigitalTwinsInstance. </param>
 415        /// <param name="cancellationToken"> The cancellation token to use. </param>
 416        /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/> or <paramref name="resourceNam
 417        public virtual async Task<DigitalTwinsDeleteOperation> StartDeleteAsync(string resourceGroupName, string resourc
 418        {
 2419            if (resourceGroupName == null)
 420            {
 0421                throw new ArgumentNullException(nameof(resourceGroupName));
 422            }
 2423            if (resourceName == null)
 424            {
 0425                throw new ArgumentNullException(nameof(resourceName));
 426            }
 427
 2428            using var scope = _clientDiagnostics.CreateScope("DigitalTwinsOperations.StartDelete");
 2429            scope.Start();
 430            try
 431            {
 2432                var originalResponse = await RestClient.DeleteAsync(resourceGroupName, resourceName, cancellationToken).
 2433                return new DigitalTwinsDeleteOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteRequest(res
 434            }
 0435            catch (Exception e)
 436            {
 0437                scope.Failed(e);
 0438                throw;
 439            }
 2440        }
 441
 442        /// <summary> Delete a DigitalTwinsInstance. </summary>
 443        /// <param name="resourceGroupName"> The name of the resource group that contains the DigitalTwinsInstance. </pa
 444        /// <param name="resourceName"> The name of the DigitalTwinsInstance. </param>
 445        /// <param name="cancellationToken"> The cancellation token to use. </param>
 446        /// <exception cref="ArgumentNullException"> <paramref name="resourceGroupName"/> or <paramref name="resourceNam
 447        public virtual DigitalTwinsDeleteOperation StartDelete(string resourceGroupName, string resourceName, Cancellati
 448        {
 2449            if (resourceGroupName == null)
 450            {
 0451                throw new ArgumentNullException(nameof(resourceGroupName));
 452            }
 2453            if (resourceName == null)
 454            {
 0455                throw new ArgumentNullException(nameof(resourceName));
 456            }
 457
 2458            using var scope = _clientDiagnostics.CreateScope("DigitalTwinsOperations.StartDelete");
 2459            scope.Start();
 460            try
 461            {
 2462                var originalResponse = RestClient.Delete(resourceGroupName, resourceName, cancellationToken);
 2463                return new DigitalTwinsDeleteOperation(_clientDiagnostics, _pipeline, RestClient.CreateDeleteRequest(res
 464            }
 0465            catch (Exception e)
 466            {
 0467                scope.Failed(e);
 0468                throw;
 469            }
 2470        }
 471    }
 472}