| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | // <auto-generated/> |
| | 5 | |
|
| | 6 | | #nullable disable |
| | 7 | |
|
| | 8 | | using System; |
| | 9 | | using System.Threading; |
| | 10 | | using System.Threading.Tasks; |
| | 11 | | using Azure; |
| | 12 | | using Azure.Core; |
| | 13 | | using Azure.Core.Pipeline; |
| | 14 | | using Azure.ResourceManager.Resources.Models; |
| | 15 | |
|
| | 16 | | namespace 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; |
| 28 | 23 | | internal ResourceLinksRestOperations RestClient { get; } |
| | 24 | | /// <summary> Initializes a new instance of ResourceLinksOperations for mocking. </summary> |
| 28 | 25 | | protected ResourceLinksOperations() |
| | 26 | | { |
| 28 | 27 | | } |
| | 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> |
| 28 | 33 | | internal ResourceLinksOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscription |
| | 34 | | { |
| 28 | 35 | | RestClient = new ResourceLinksRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint); |
| 28 | 36 | | _clientDiagnostics = clientDiagnostics; |
| 28 | 37 | | _pipeline = pipeline; |
| 28 | 38 | | } |
| | 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 | | { |
| 2 | 45 | | using var scope = _clientDiagnostics.CreateScope("ResourceLinksOperations.Delete"); |
| 2 | 46 | | scope.Start(); |
| | 47 | | try |
| | 48 | | { |
| 2 | 49 | | return await RestClient.DeleteAsync(linkId, cancellationToken).ConfigureAwait(false); |
| | 50 | | } |
| 0 | 51 | | catch (Exception e) |
| | 52 | | { |
| 0 | 53 | | scope.Failed(e); |
| 0 | 54 | | throw; |
| | 55 | | } |
| 2 | 56 | | } |
| | 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 | | { |
| 2 | 63 | | using var scope = _clientDiagnostics.CreateScope("ResourceLinksOperations.Delete"); |
| 2 | 64 | | scope.Start(); |
| | 65 | | try |
| | 66 | | { |
| 2 | 67 | | return RestClient.Delete(linkId, cancellationToken); |
| | 68 | | } |
| 0 | 69 | | catch (Exception e) |
| | 70 | | { |
| 0 | 71 | | scope.Failed(e); |
| 0 | 72 | | throw; |
| | 73 | | } |
| 2 | 74 | | } |
| | 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 | | { |
| 2 | 82 | | using var scope = _clientDiagnostics.CreateScope("ResourceLinksOperations.CreateOrUpdate"); |
| 2 | 83 | | scope.Start(); |
| | 84 | | try |
| | 85 | | { |
| 2 | 86 | | return await RestClient.CreateOrUpdateAsync(linkId, parameters, cancellationToken).ConfigureAwait(false) |
| | 87 | | } |
| 0 | 88 | | catch (Exception e) |
| | 89 | | { |
| 0 | 90 | | scope.Failed(e); |
| 0 | 91 | | throw; |
| | 92 | | } |
| 2 | 93 | | } |
| | 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 | | { |
| 2 | 101 | | using var scope = _clientDiagnostics.CreateScope("ResourceLinksOperations.CreateOrUpdate"); |
| 2 | 102 | | scope.Start(); |
| | 103 | | try |
| | 104 | | { |
| 2 | 105 | | return RestClient.CreateOrUpdate(linkId, parameters, cancellationToken); |
| | 106 | | } |
| 0 | 107 | | catch (Exception e) |
| | 108 | | { |
| 0 | 109 | | scope.Failed(e); |
| 0 | 110 | | throw; |
| | 111 | | } |
| 2 | 112 | | } |
| | 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 | | { |
| 4 | 119 | | using var scope = _clientDiagnostics.CreateScope("ResourceLinksOperations.Get"); |
| 4 | 120 | | scope.Start(); |
| | 121 | | try |
| | 122 | | { |
| 4 | 123 | | return await RestClient.GetAsync(linkId, cancellationToken).ConfigureAwait(false); |
| | 124 | | } |
| 2 | 125 | | catch (Exception e) |
| | 126 | | { |
| 2 | 127 | | scope.Failed(e); |
| 2 | 128 | | throw; |
| | 129 | | } |
| 2 | 130 | | } |
| | 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 | | { |
| 4 | 137 | | using var scope = _clientDiagnostics.CreateScope("ResourceLinksOperations.Get"); |
| 4 | 138 | | scope.Start(); |
| | 139 | | try |
| | 140 | | { |
| 4 | 141 | | return RestClient.Get(linkId, cancellationToken); |
| | 142 | | } |
| 2 | 143 | | catch (Exception e) |
| | 144 | | { |
| 2 | 145 | | scope.Failed(e); |
| 2 | 146 | | throw; |
| | 147 | | } |
| 2 | 148 | | } |
| | 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 | | { |
| 4 | 157 | | using var scope = _clientDiagnostics.CreateScope("ResourceLinksOperations.ListAtSubscription"); |
| 4 | 158 | | scope.Start(); |
| | 159 | | try |
| | 160 | | { |
| 4 | 161 | | var response = await RestClient.ListAtSubscriptionAsync(filter, cancellationToken).ConfigureAwait(fa |
| 4 | 162 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 163 | | } |
| 0 | 164 | | catch (Exception e) |
| | 165 | | { |
| 0 | 166 | | scope.Failed(e); |
| 0 | 167 | | throw; |
| | 168 | | } |
| 4 | 169 | | } |
| | 170 | | async Task<Page<ResourceLink>> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 171 | | { |
| 0 | 172 | | using var scope = _clientDiagnostics.CreateScope("ResourceLinksOperations.ListAtSubscription"); |
| 0 | 173 | | scope.Start(); |
| | 174 | | try |
| | 175 | | { |
| 0 | 176 | | var response = await RestClient.ListAtSubscriptionNextPageAsync(nextLink, filter, cancellationToken) |
| 0 | 177 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 178 | | } |
| 0 | 179 | | catch (Exception e) |
| | 180 | | { |
| 0 | 181 | | scope.Failed(e); |
| 0 | 182 | | throw; |
| | 183 | | } |
| 0 | 184 | | } |
| 4 | 185 | | 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 | | { |
| 4 | 195 | | using var scope = _clientDiagnostics.CreateScope("ResourceLinksOperations.ListAtSubscription"); |
| 4 | 196 | | scope.Start(); |
| | 197 | | try |
| | 198 | | { |
| 4 | 199 | | var response = RestClient.ListAtSubscription(filter, cancellationToken); |
| 4 | 200 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 201 | | } |
| 0 | 202 | | catch (Exception e) |
| | 203 | | { |
| 0 | 204 | | scope.Failed(e); |
| 0 | 205 | | throw; |
| | 206 | | } |
| 4 | 207 | | } |
| | 208 | | Page<ResourceLink> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 209 | | { |
| 0 | 210 | | using var scope = _clientDiagnostics.CreateScope("ResourceLinksOperations.ListAtSubscription"); |
| 0 | 211 | | scope.Start(); |
| | 212 | | try |
| | 213 | | { |
| 0 | 214 | | var response = RestClient.ListAtSubscriptionNextPage(nextLink, filter, cancellationToken); |
| 0 | 215 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 216 | | } |
| 0 | 217 | | catch (Exception e) |
| | 218 | | { |
| 0 | 219 | | scope.Failed(e); |
| 0 | 220 | | throw; |
| | 221 | | } |
| 0 | 222 | | } |
| 4 | 223 | | 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 | | { |
| 2 | 231 | | if (scope == null) |
| | 232 | | { |
| 0 | 233 | | throw new ArgumentNullException(nameof(scope)); |
| | 234 | | } |
| | 235 | |
|
| | 236 | | async Task<Page<ResourceLink>> FirstPageFunc(int? pageSizeHint) |
| | 237 | | { |
| 2 | 238 | | using var scope0 = _clientDiagnostics.CreateScope("ResourceLinksOperations.ListAtSourceScope"); |
| 2 | 239 | | scope0.Start(); |
| | 240 | | try |
| | 241 | | { |
| 2 | 242 | | var response = await RestClient.ListAtSourceScopeAsync(scope, cancellationToken).ConfigureAwait(fals |
| 2 | 243 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 244 | | } |
| 0 | 245 | | catch (Exception e) |
| | 246 | | { |
| 0 | 247 | | scope0.Failed(e); |
| 0 | 248 | | throw; |
| | 249 | | } |
| 2 | 250 | | } |
| | 251 | | async Task<Page<ResourceLink>> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 252 | | { |
| 0 | 253 | | using var scope0 = _clientDiagnostics.CreateScope("ResourceLinksOperations.ListAtSourceScope"); |
| 0 | 254 | | scope0.Start(); |
| | 255 | | try |
| | 256 | | { |
| 0 | 257 | | var response = await RestClient.ListAtSourceScopeNextPageAsync(nextLink, scope, cancellationToken).C |
| 0 | 258 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 259 | | } |
| 0 | 260 | | catch (Exception e) |
| | 261 | | { |
| 0 | 262 | | scope0.Failed(e); |
| 0 | 263 | | throw; |
| | 264 | | } |
| 0 | 265 | | } |
| 2 | 266 | | 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 | | { |
| 2 | 274 | | if (scope == null) |
| | 275 | | { |
| 0 | 276 | | throw new ArgumentNullException(nameof(scope)); |
| | 277 | | } |
| | 278 | |
|
| | 279 | | Page<ResourceLink> FirstPageFunc(int? pageSizeHint) |
| | 280 | | { |
| 2 | 281 | | using var scope0 = _clientDiagnostics.CreateScope("ResourceLinksOperations.ListAtSourceScope"); |
| 2 | 282 | | scope0.Start(); |
| | 283 | | try |
| | 284 | | { |
| 2 | 285 | | var response = RestClient.ListAtSourceScope(scope, cancellationToken); |
| 2 | 286 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 287 | | } |
| 0 | 288 | | catch (Exception e) |
| | 289 | | { |
| 0 | 290 | | scope0.Failed(e); |
| 0 | 291 | | throw; |
| | 292 | | } |
| 2 | 293 | | } |
| | 294 | | Page<ResourceLink> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 295 | | { |
| 0 | 296 | | using var scope0 = _clientDiagnostics.CreateScope("ResourceLinksOperations.ListAtSourceScope"); |
| 0 | 297 | | scope0.Start(); |
| | 298 | | try |
| | 299 | | { |
| 0 | 300 | | var response = RestClient.ListAtSourceScopeNextPage(nextLink, scope, cancellationToken); |
| 0 | 301 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 302 | | } |
| 0 | 303 | | catch (Exception e) |
| | 304 | | { |
| 0 | 305 | | scope0.Failed(e); |
| 0 | 306 | | throw; |
| | 307 | | } |
| 0 | 308 | | } |
| 2 | 309 | | return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); |
| | 310 | | } |
| | 311 | | } |
| | 312 | | } |