< Summary

Class:Azure.ResourceManager.Resources.ResourceLinksOperations
Assembly:Azure.ResourceManager.Resources
File(s):C:\Git\azure-sdk-for-net\sdk\resources\Azure.ResourceManager.Resources\src\Generated\ResourceLinksOperations.cs
Covered lines:64
Uncovered lines:58
Coverable lines:122
Total lines:312
Line coverage:52.4% (64 of 122)
Covered branches:2
Total branches:4
Branch coverage:50% (2 of 4)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
get_RestClient()-100%100%
.ctor()-100%100%
.ctor(...)-100%100%
DeleteAsync()-57.14%100%
Delete(...)-57.14%100%
CreateOrUpdateAsync()-57.14%100%
CreateOrUpdate(...)-57.14%100%
GetAsync()-100%100%
Get(...)-100%100%
<ListAtSubscriptionAsync()-62.5%100%
<ListAtSubscriptionAsync()-0%100%
ListAtSubscriptionAsync(...)-100%100%
ListAtSubscription(...)-100%100%
ListAtSourceScopeAsync(...)-36.84%50%
<ListAtSourceScopeAsync()-62.5%100%
<ListAtSourceScopeAsync()-0%100%
ListAtSourceScope(...)-36.84%50%

File(s)

C:\Git\azure-sdk-for-net\sdk\resources\Azure.ResourceManager.Resources\src\Generated\ResourceLinksOperations.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.Threading;
 10using System.Threading.Tasks;
 11using Azure;
 12using Azure.Core;
 13using Azure.Core.Pipeline;
 14using Azure.ResourceManager.Resources.Models;
 15
 16namespace Azure.ResourceManager.Resources
 17{
 18    /// <summary> The ResourceLinks service client. </summary>
 19    public partial class ResourceLinksOperations
 20    {
 21        private readonly ClientDiagnostics _clientDiagnostics;
 22        private readonly HttpPipeline _pipeline;
 2823        internal ResourceLinksRestOperations RestClient { get; }
 24        /// <summary> Initializes a new instance of ResourceLinksOperations for mocking. </summary>
 2825        protected ResourceLinksOperations()
 26        {
 2827        }
 28        /// <summary> Initializes a new instance of ResourceLinksOperations. </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 ID of the target subscription. </param>
 32        /// <param name="endpoint"> server parameter. </param>
 2833        internal ResourceLinksOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscription
 34        {
 2835            RestClient = new ResourceLinksRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint);
 2836            _clientDiagnostics = clientDiagnostics;
 2837            _pipeline = pipeline;
 2838        }
 39
 40        /// <summary> Deletes a resource link with the specified ID. </summary>
 41        /// <param name="linkId"> The fully qualified ID of the resource link. Use the format, /subscriptions/{subscript
 42        /// <param name="cancellationToken"> The cancellation token to use. </param>
 43        public virtual async Task<Response> DeleteAsync(string linkId, CancellationToken cancellationToken = default)
 44        {
 245            using var scope = _clientDiagnostics.CreateScope("ResourceLinksOperations.Delete");
 246            scope.Start();
 47            try
 48            {
 249                return await RestClient.DeleteAsync(linkId, cancellationToken).ConfigureAwait(false);
 50            }
 051            catch (Exception e)
 52            {
 053                scope.Failed(e);
 054                throw;
 55            }
 256        }
 57
 58        /// <summary> Deletes a resource link with the specified ID. </summary>
 59        /// <param name="linkId"> The fully qualified ID of the resource link. Use the format, /subscriptions/{subscript
 60        /// <param name="cancellationToken"> The cancellation token to use. </param>
 61        public virtual Response Delete(string linkId, CancellationToken cancellationToken = default)
 62        {
 263            using var scope = _clientDiagnostics.CreateScope("ResourceLinksOperations.Delete");
 264            scope.Start();
 65            try
 66            {
 267                return RestClient.Delete(linkId, cancellationToken);
 68            }
 069            catch (Exception e)
 70            {
 071                scope.Failed(e);
 072                throw;
 73            }
 274        }
 75
 76        /// <summary> Creates or updates a resource link between the specified resources. </summary>
 77        /// <param name="linkId"> The fully qualified ID of the resource link. Use the format, /subscriptions/{subscript
 78        /// <param name="parameters"> Parameters for creating or updating a resource link. </param>
 79        /// <param name="cancellationToken"> The cancellation token to use. </param>
 80        public virtual async Task<Response<ResourceLink>> CreateOrUpdateAsync(string linkId, ResourceLink parameters, Ca
 81        {
 282            using var scope = _clientDiagnostics.CreateScope("ResourceLinksOperations.CreateOrUpdate");
 283            scope.Start();
 84            try
 85            {
 286                return await RestClient.CreateOrUpdateAsync(linkId, parameters, cancellationToken).ConfigureAwait(false)
 87            }
 088            catch (Exception e)
 89            {
 090                scope.Failed(e);
 091                throw;
 92            }
 293        }
 94
 95        /// <summary> Creates or updates a resource link between the specified resources. </summary>
 96        /// <param name="linkId"> The fully qualified ID of the resource link. Use the format, /subscriptions/{subscript
 97        /// <param name="parameters"> Parameters for creating or updating a resource link. </param>
 98        /// <param name="cancellationToken"> The cancellation token to use. </param>
 99        public virtual Response<ResourceLink> CreateOrUpdate(string linkId, ResourceLink parameters, CancellationToken c
 100        {
 2101            using var scope = _clientDiagnostics.CreateScope("ResourceLinksOperations.CreateOrUpdate");
 2102            scope.Start();
 103            try
 104            {
 2105                return RestClient.CreateOrUpdate(linkId, parameters, cancellationToken);
 106            }
 0107            catch (Exception e)
 108            {
 0109                scope.Failed(e);
 0110                throw;
 111            }
 2112        }
 113
 114        /// <summary> Gets a resource link with the specified ID. </summary>
 115        /// <param name="linkId"> The fully qualified Id of the resource link. For example, /subscriptions/00000000-0000
 116        /// <param name="cancellationToken"> The cancellation token to use. </param>
 117        public virtual async Task<Response<ResourceLink>> GetAsync(string linkId, CancellationToken cancellationToken = 
 118        {
 4119            using var scope = _clientDiagnostics.CreateScope("ResourceLinksOperations.Get");
 4120            scope.Start();
 121            try
 122            {
 4123                return await RestClient.GetAsync(linkId, cancellationToken).ConfigureAwait(false);
 124            }
 2125            catch (Exception e)
 126            {
 2127                scope.Failed(e);
 2128                throw;
 129            }
 2130        }
 131
 132        /// <summary> Gets a resource link with the specified ID. </summary>
 133        /// <param name="linkId"> The fully qualified Id of the resource link. For example, /subscriptions/00000000-0000
 134        /// <param name="cancellationToken"> The cancellation token to use. </param>
 135        public virtual Response<ResourceLink> Get(string linkId, CancellationToken cancellationToken = default)
 136        {
 4137            using var scope = _clientDiagnostics.CreateScope("ResourceLinksOperations.Get");
 4138            scope.Start();
 139            try
 140            {
 4141                return RestClient.Get(linkId, cancellationToken);
 142            }
 2143            catch (Exception e)
 144            {
 2145                scope.Failed(e);
 2146                throw;
 147            }
 2148        }
 149
 150        /// <summary> Gets all the linked resources for the subscription. </summary>
 151        /// <param name="filter"> The filter to apply on the list resource links operation. The supported filter for lis
 152        /// <param name="cancellationToken"> The cancellation token to use. </param>
 153        public virtual AsyncPageable<ResourceLink> ListAtSubscriptionAsync(string filter = null, CancellationToken cance
 154        {
 155            async Task<Page<ResourceLink>> FirstPageFunc(int? pageSizeHint)
 156            {
 4157                using var scope = _clientDiagnostics.CreateScope("ResourceLinksOperations.ListAtSubscription");
 4158                scope.Start();
 159                try
 160                {
 4161                    var response = await RestClient.ListAtSubscriptionAsync(filter, cancellationToken).ConfigureAwait(fa
 4162                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 163                }
 0164                catch (Exception e)
 165                {
 0166                    scope.Failed(e);
 0167                    throw;
 168                }
 4169            }
 170            async Task<Page<ResourceLink>> NextPageFunc(string nextLink, int? pageSizeHint)
 171            {
 0172                using var scope = _clientDiagnostics.CreateScope("ResourceLinksOperations.ListAtSubscription");
 0173                scope.Start();
 174                try
 175                {
 0176                    var response = await RestClient.ListAtSubscriptionNextPageAsync(nextLink, filter, cancellationToken)
 0177                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 178                }
 0179                catch (Exception e)
 180                {
 0181                    scope.Failed(e);
 0182                    throw;
 183                }
 0184            }
 4185            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
 186        }
 187
 188        /// <summary> Gets all the linked resources for the subscription. </summary>
 189        /// <param name="filter"> The filter to apply on the list resource links operation. The supported filter for lis
 190        /// <param name="cancellationToken"> The cancellation token to use. </param>
 191        public virtual Pageable<ResourceLink> ListAtSubscription(string filter = null, CancellationToken cancellationTok
 192        {
 193            Page<ResourceLink> FirstPageFunc(int? pageSizeHint)
 194            {
 4195                using var scope = _clientDiagnostics.CreateScope("ResourceLinksOperations.ListAtSubscription");
 4196                scope.Start();
 197                try
 198                {
 4199                    var response = RestClient.ListAtSubscription(filter, cancellationToken);
 4200                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 201                }
 0202                catch (Exception e)
 203                {
 0204                    scope.Failed(e);
 0205                    throw;
 206                }
 4207            }
 208            Page<ResourceLink> NextPageFunc(string nextLink, int? pageSizeHint)
 209            {
 0210                using var scope = _clientDiagnostics.CreateScope("ResourceLinksOperations.ListAtSubscription");
 0211                scope.Start();
 212                try
 213                {
 0214                    var response = RestClient.ListAtSubscriptionNextPage(nextLink, filter, cancellationToken);
 0215                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 216                }
 0217                catch (Exception e)
 218                {
 0219                    scope.Failed(e);
 0220                    throw;
 221                }
 0222            }
 4223            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 224        }
 225
 226        /// <summary> Gets a list of resource links at and below the specified source scope. </summary>
 227        /// <param name="scope"> The fully qualified ID of the scope for getting the resource links. For example, to lis
 228        /// <param name="cancellationToken"> The cancellation token to use. </param>
 229        public virtual AsyncPageable<ResourceLink> ListAtSourceScopeAsync(string scope, CancellationToken cancellationTo
 230        {
 2231            if (scope == null)
 232            {
 0233                throw new ArgumentNullException(nameof(scope));
 234            }
 235
 236            async Task<Page<ResourceLink>> FirstPageFunc(int? pageSizeHint)
 237            {
 2238                using var scope0 = _clientDiagnostics.CreateScope("ResourceLinksOperations.ListAtSourceScope");
 2239                scope0.Start();
 240                try
 241                {
 2242                    var response = await RestClient.ListAtSourceScopeAsync(scope, cancellationToken).ConfigureAwait(fals
 2243                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 244                }
 0245                catch (Exception e)
 246                {
 0247                    scope0.Failed(e);
 0248                    throw;
 249                }
 2250            }
 251            async Task<Page<ResourceLink>> NextPageFunc(string nextLink, int? pageSizeHint)
 252            {
 0253                using var scope0 = _clientDiagnostics.CreateScope("ResourceLinksOperations.ListAtSourceScope");
 0254                scope0.Start();
 255                try
 256                {
 0257                    var response = await RestClient.ListAtSourceScopeNextPageAsync(nextLink, scope, cancellationToken).C
 0258                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 259                }
 0260                catch (Exception e)
 261                {
 0262                    scope0.Failed(e);
 0263                    throw;
 264                }
 0265            }
 2266            return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc);
 267        }
 268
 269        /// <summary> Gets a list of resource links at and below the specified source scope. </summary>
 270        /// <param name="scope"> The fully qualified ID of the scope for getting the resource links. For example, to lis
 271        /// <param name="cancellationToken"> The cancellation token to use. </param>
 272        public virtual Pageable<ResourceLink> ListAtSourceScope(string scope, CancellationToken cancellationToken = defa
 273        {
 2274            if (scope == null)
 275            {
 0276                throw new ArgumentNullException(nameof(scope));
 277            }
 278
 279            Page<ResourceLink> FirstPageFunc(int? pageSizeHint)
 280            {
 2281                using var scope0 = _clientDiagnostics.CreateScope("ResourceLinksOperations.ListAtSourceScope");
 2282                scope0.Start();
 283                try
 284                {
 2285                    var response = RestClient.ListAtSourceScope(scope, cancellationToken);
 2286                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 287                }
 0288                catch (Exception e)
 289                {
 0290                    scope0.Failed(e);
 0291                    throw;
 292                }
 2293            }
 294            Page<ResourceLink> NextPageFunc(string nextLink, int? pageSizeHint)
 295            {
 0296                using var scope0 = _clientDiagnostics.CreateScope("ResourceLinksOperations.ListAtSourceScope");
 0297                scope0.Start();
 298                try
 299                {
 0300                    var response = RestClient.ListAtSourceScopeNextPage(nextLink, scope, cancellationToken);
 0301                    return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse());
 302                }
 0303                catch (Exception e)
 304                {
 0305                    scope0.Failed(e);
 0306                    throw;
 307                }
 0308            }
 2309            return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc);
 310        }
 311    }
 312}