| | 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 Tags service client. </summary> |
| | 19 | | public partial class TagsOperations |
| | 20 | | { |
| | 21 | | private readonly ClientDiagnostics _clientDiagnostics; |
| | 22 | | private readonly HttpPipeline _pipeline; |
| 116 | 23 | | internal TagsRestOperations RestClient { get; } |
| | 24 | | /// <summary> Initializes a new instance of TagsOperations for mocking. </summary> |
| 256 | 25 | | protected TagsOperations() |
| | 26 | | { |
| 256 | 27 | | } |
| | 28 | | /// <summary> Initializes a new instance of TagsOperations. </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> |
| 256 | 33 | | internal TagsOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptionId, Uri e |
| | 34 | | { |
| 256 | 35 | | RestClient = new TagsRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint); |
| 256 | 36 | | _clientDiagnostics = clientDiagnostics; |
| 256 | 37 | | _pipeline = pipeline; |
| 256 | 38 | | } |
| | 39 | |
|
| | 40 | | /// <summary> This operation allows deleting a value from the list of predefined values for an existing predefin |
| | 41 | | /// <param name="tagName"> The name of the tag. </param> |
| | 42 | | /// <param name="tagValue"> The value of the tag to delete. </param> |
| | 43 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 44 | | public virtual async Task<Response> DeleteValueAsync(string tagName, string tagValue, CancellationToken cancella |
| | 45 | | { |
| 2 | 46 | | using var scope = _clientDiagnostics.CreateScope("TagsOperations.DeleteValue"); |
| 2 | 47 | | scope.Start(); |
| | 48 | | try |
| | 49 | | { |
| 2 | 50 | | return await RestClient.DeleteValueAsync(tagName, tagValue, cancellationToken).ConfigureAwait(false); |
| | 51 | | } |
| 0 | 52 | | catch (Exception e) |
| | 53 | | { |
| 0 | 54 | | scope.Failed(e); |
| 0 | 55 | | throw; |
| | 56 | | } |
| 2 | 57 | | } |
| | 58 | |
|
| | 59 | | /// <summary> This operation allows deleting a value from the list of predefined values for an existing predefin |
| | 60 | | /// <param name="tagName"> The name of the tag. </param> |
| | 61 | | /// <param name="tagValue"> The value of the tag to delete. </param> |
| | 62 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 63 | | public virtual Response DeleteValue(string tagName, string tagValue, CancellationToken cancellationToken = defau |
| | 64 | | { |
| 2 | 65 | | using var scope = _clientDiagnostics.CreateScope("TagsOperations.DeleteValue"); |
| 2 | 66 | | scope.Start(); |
| | 67 | | try |
| | 68 | | { |
| 2 | 69 | | return RestClient.DeleteValue(tagName, tagValue, cancellationToken); |
| | 70 | | } |
| 0 | 71 | | catch (Exception e) |
| | 72 | | { |
| 0 | 73 | | scope.Failed(e); |
| 0 | 74 | | throw; |
| | 75 | | } |
| 2 | 76 | | } |
| | 77 | |
|
| | 78 | | /// <summary> This operation allows adding a value to the list of predefined values for an existing predefined t |
| | 79 | | /// <param name="tagName"> The name of the tag. </param> |
| | 80 | | /// <param name="tagValue"> The value of the tag to create. </param> |
| | 81 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 82 | | public virtual async Task<Response<TagValue>> CreateOrUpdateValueAsync(string tagName, string tagValue, Cancella |
| | 83 | | { |
| 4 | 84 | | using var scope = _clientDiagnostics.CreateScope("TagsOperations.CreateOrUpdateValue"); |
| 4 | 85 | | scope.Start(); |
| | 86 | | try |
| | 87 | | { |
| 4 | 88 | | return await RestClient.CreateOrUpdateValueAsync(tagName, tagValue, cancellationToken).ConfigureAwait(fa |
| | 89 | | } |
| 2 | 90 | | catch (Exception e) |
| | 91 | | { |
| 2 | 92 | | scope.Failed(e); |
| 2 | 93 | | throw; |
| | 94 | | } |
| 2 | 95 | | } |
| | 96 | |
|
| | 97 | | /// <summary> This operation allows adding a value to the list of predefined values for an existing predefined t |
| | 98 | | /// <param name="tagName"> The name of the tag. </param> |
| | 99 | | /// <param name="tagValue"> The value of the tag to create. </param> |
| | 100 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 101 | | public virtual Response<TagValue> CreateOrUpdateValue(string tagName, string tagValue, CancellationToken cancell |
| | 102 | | { |
| 4 | 103 | | using var scope = _clientDiagnostics.CreateScope("TagsOperations.CreateOrUpdateValue"); |
| 4 | 104 | | scope.Start(); |
| | 105 | | try |
| | 106 | | { |
| 4 | 107 | | return RestClient.CreateOrUpdateValue(tagName, tagValue, cancellationToken); |
| | 108 | | } |
| 2 | 109 | | catch (Exception e) |
| | 110 | | { |
| 2 | 111 | | scope.Failed(e); |
| 2 | 112 | | throw; |
| | 113 | | } |
| 2 | 114 | | } |
| | 115 | |
|
| | 116 | | /// <summary> This operation allows adding a name to the list of predefined tag names for the given subscription |
| | 117 | | /// <param name="tagName"> The name of the tag to create. </param> |
| | 118 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 119 | | public virtual async Task<Response<TagDetails>> CreateOrUpdateAsync(string tagName, CancellationToken cancellati |
| | 120 | | { |
| 4 | 121 | | using var scope = _clientDiagnostics.CreateScope("TagsOperations.CreateOrUpdate"); |
| 4 | 122 | | scope.Start(); |
| | 123 | | try |
| | 124 | | { |
| 4 | 125 | | return await RestClient.CreateOrUpdateAsync(tagName, cancellationToken).ConfigureAwait(false); |
| | 126 | | } |
| 0 | 127 | | catch (Exception e) |
| | 128 | | { |
| 0 | 129 | | scope.Failed(e); |
| 0 | 130 | | throw; |
| | 131 | | } |
| 4 | 132 | | } |
| | 133 | |
|
| | 134 | | /// <summary> This operation allows adding a name to the list of predefined tag names for the given subscription |
| | 135 | | /// <param name="tagName"> The name of the tag to create. </param> |
| | 136 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 137 | | public virtual Response<TagDetails> CreateOrUpdate(string tagName, CancellationToken cancellationToken = default |
| | 138 | | { |
| 4 | 139 | | using var scope = _clientDiagnostics.CreateScope("TagsOperations.CreateOrUpdate"); |
| 4 | 140 | | scope.Start(); |
| | 141 | | try |
| | 142 | | { |
| 4 | 143 | | return RestClient.CreateOrUpdate(tagName, cancellationToken); |
| | 144 | | } |
| 0 | 145 | | catch (Exception e) |
| | 146 | | { |
| 0 | 147 | | scope.Failed(e); |
| 0 | 148 | | throw; |
| | 149 | | } |
| 4 | 150 | | } |
| | 151 | |
|
| | 152 | | /// <summary> This operation allows deleting a name from the list of predefined tag names for the given subscrip |
| | 153 | | /// <param name="tagName"> The name of the tag. </param> |
| | 154 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 155 | | public virtual async Task<Response> DeleteAsync(string tagName, CancellationToken cancellationToken = default) |
| | 156 | | { |
| 4 | 157 | | using var scope = _clientDiagnostics.CreateScope("TagsOperations.Delete"); |
| 4 | 158 | | scope.Start(); |
| | 159 | | try |
| | 160 | | { |
| 4 | 161 | | return await RestClient.DeleteAsync(tagName, cancellationToken).ConfigureAwait(false); |
| | 162 | | } |
| 0 | 163 | | catch (Exception e) |
| | 164 | | { |
| 0 | 165 | | scope.Failed(e); |
| 0 | 166 | | throw; |
| | 167 | | } |
| 4 | 168 | | } |
| | 169 | |
|
| | 170 | | /// <summary> This operation allows deleting a name from the list of predefined tag names for the given subscrip |
| | 171 | | /// <param name="tagName"> The name of the tag. </param> |
| | 172 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 173 | | public virtual Response Delete(string tagName, CancellationToken cancellationToken = default) |
| | 174 | | { |
| 4 | 175 | | using var scope = _clientDiagnostics.CreateScope("TagsOperations.Delete"); |
| 4 | 176 | | scope.Start(); |
| | 177 | | try |
| | 178 | | { |
| 4 | 179 | | return RestClient.Delete(tagName, cancellationToken); |
| | 180 | | } |
| 0 | 181 | | catch (Exception e) |
| | 182 | | { |
| 0 | 183 | | scope.Failed(e); |
| 0 | 184 | | throw; |
| | 185 | | } |
| 4 | 186 | | } |
| | 187 | |
|
| | 188 | | /// <summary> This operation allows adding or replacing the entire set of tags on the specified resource or subs |
| | 189 | | /// <param name="scope"> The resource scope. </param> |
| | 190 | | /// <param name="parameters"> The TagsResource to use. </param> |
| | 191 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 192 | | public virtual async Task<Response<TagsResource>> CreateOrUpdateAtScopeAsync(string scope, TagsResource paramete |
| | 193 | | { |
| 16 | 194 | | using var scope0 = _clientDiagnostics.CreateScope("TagsOperations.CreateOrUpdateAtScope"); |
| 16 | 195 | | scope0.Start(); |
| | 196 | | try |
| | 197 | | { |
| 16 | 198 | | return await RestClient.CreateOrUpdateAtScopeAsync(scope, parameters, cancellationToken).ConfigureAwait( |
| | 199 | | } |
| 0 | 200 | | catch (Exception e) |
| | 201 | | { |
| 0 | 202 | | scope0.Failed(e); |
| 0 | 203 | | throw; |
| | 204 | | } |
| 16 | 205 | | } |
| | 206 | |
|
| | 207 | | /// <summary> This operation allows adding or replacing the entire set of tags on the specified resource or subs |
| | 208 | | /// <param name="scope"> The resource scope. </param> |
| | 209 | | /// <param name="parameters"> The TagsResource to use. </param> |
| | 210 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 211 | | public virtual Response<TagsResource> CreateOrUpdateAtScope(string scope, TagsResource parameters, CancellationT |
| | 212 | | { |
| 16 | 213 | | using var scope0 = _clientDiagnostics.CreateScope("TagsOperations.CreateOrUpdateAtScope"); |
| 16 | 214 | | scope0.Start(); |
| | 215 | | try |
| | 216 | | { |
| 16 | 217 | | return RestClient.CreateOrUpdateAtScope(scope, parameters, cancellationToken); |
| | 218 | | } |
| 0 | 219 | | catch (Exception e) |
| | 220 | | { |
| 0 | 221 | | scope0.Failed(e); |
| 0 | 222 | | throw; |
| | 223 | | } |
| 16 | 224 | | } |
| | 225 | |
|
| | 226 | | /// <summary> This operation allows replacing, merging or selectively deleting tags on the specified resource or |
| | 227 | | /// <param name="scope"> The resource scope. </param> |
| | 228 | | /// <param name="parameters"> The TagsPatchResource to use. </param> |
| | 229 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 230 | | public virtual async Task<Response<TagsResource>> UpdateAtScopeAsync(string scope, TagsPatchResource parameters, |
| | 231 | | { |
| 12 | 232 | | using var scope0 = _clientDiagnostics.CreateScope("TagsOperations.UpdateAtScope"); |
| 12 | 233 | | scope0.Start(); |
| | 234 | | try |
| | 235 | | { |
| 12 | 236 | | return await RestClient.UpdateAtScopeAsync(scope, parameters, cancellationToken).ConfigureAwait(false); |
| | 237 | | } |
| 0 | 238 | | catch (Exception e) |
| | 239 | | { |
| 0 | 240 | | scope0.Failed(e); |
| 0 | 241 | | throw; |
| | 242 | | } |
| 12 | 243 | | } |
| | 244 | |
|
| | 245 | | /// <summary> This operation allows replacing, merging or selectively deleting tags on the specified resource or |
| | 246 | | /// <param name="scope"> The resource scope. </param> |
| | 247 | | /// <param name="parameters"> The TagsPatchResource to use. </param> |
| | 248 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 249 | | public virtual Response<TagsResource> UpdateAtScope(string scope, TagsPatchResource parameters, CancellationToke |
| | 250 | | { |
| 12 | 251 | | using var scope0 = _clientDiagnostics.CreateScope("TagsOperations.UpdateAtScope"); |
| 12 | 252 | | scope0.Start(); |
| | 253 | | try |
| | 254 | | { |
| 12 | 255 | | return RestClient.UpdateAtScope(scope, parameters, cancellationToken); |
| | 256 | | } |
| 0 | 257 | | catch (Exception e) |
| | 258 | | { |
| 0 | 259 | | scope0.Failed(e); |
| 0 | 260 | | throw; |
| | 261 | | } |
| 12 | 262 | | } |
| | 263 | |
|
| | 264 | | /// <summary> Gets the entire set of tags on a resource or subscription. </summary> |
| | 265 | | /// <param name="scope"> The resource scope. </param> |
| | 266 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 267 | | public virtual async Task<Response<TagsResource>> GetAtScopeAsync(string scope, CancellationToken cancellationTo |
| | 268 | | { |
| 8 | 269 | | using var scope0 = _clientDiagnostics.CreateScope("TagsOperations.GetAtScope"); |
| 8 | 270 | | scope0.Start(); |
| | 271 | | try |
| | 272 | | { |
| 8 | 273 | | return await RestClient.GetAtScopeAsync(scope, cancellationToken).ConfigureAwait(false); |
| | 274 | | } |
| 0 | 275 | | catch (Exception e) |
| | 276 | | { |
| 0 | 277 | | scope0.Failed(e); |
| 0 | 278 | | throw; |
| | 279 | | } |
| 8 | 280 | | } |
| | 281 | |
|
| | 282 | | /// <summary> Gets the entire set of tags on a resource or subscription. </summary> |
| | 283 | | /// <param name="scope"> The resource scope. </param> |
| | 284 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 285 | | public virtual Response<TagsResource> GetAtScope(string scope, CancellationToken cancellationToken = default) |
| | 286 | | { |
| 8 | 287 | | using var scope0 = _clientDiagnostics.CreateScope("TagsOperations.GetAtScope"); |
| 8 | 288 | | scope0.Start(); |
| | 289 | | try |
| | 290 | | { |
| 8 | 291 | | return RestClient.GetAtScope(scope, cancellationToken); |
| | 292 | | } |
| 0 | 293 | | catch (Exception e) |
| | 294 | | { |
| 0 | 295 | | scope0.Failed(e); |
| 0 | 296 | | throw; |
| | 297 | | } |
| 8 | 298 | | } |
| | 299 | |
|
| | 300 | | /// <summary> Deletes the entire set of tags on a resource or subscription. </summary> |
| | 301 | | /// <param name="scope"> The resource scope. </param> |
| | 302 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 303 | | public virtual async Task<Response> DeleteAtScopeAsync(string scope, CancellationToken cancellationToken = defau |
| | 304 | | { |
| 4 | 305 | | using var scope0 = _clientDiagnostics.CreateScope("TagsOperations.DeleteAtScope"); |
| 4 | 306 | | scope0.Start(); |
| | 307 | | try |
| | 308 | | { |
| 4 | 309 | | return await RestClient.DeleteAtScopeAsync(scope, cancellationToken).ConfigureAwait(false); |
| | 310 | | } |
| 0 | 311 | | catch (Exception e) |
| | 312 | | { |
| 0 | 313 | | scope0.Failed(e); |
| 0 | 314 | | throw; |
| | 315 | | } |
| 4 | 316 | | } |
| | 317 | |
|
| | 318 | | /// <summary> Deletes the entire set of tags on a resource or subscription. </summary> |
| | 319 | | /// <param name="scope"> The resource scope. </param> |
| | 320 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 321 | | public virtual Response DeleteAtScope(string scope, CancellationToken cancellationToken = default) |
| | 322 | | { |
| 4 | 323 | | using var scope0 = _clientDiagnostics.CreateScope("TagsOperations.DeleteAtScope"); |
| 4 | 324 | | scope0.Start(); |
| | 325 | | try |
| | 326 | | { |
| 4 | 327 | | return RestClient.DeleteAtScope(scope, cancellationToken); |
| | 328 | | } |
| 0 | 329 | | catch (Exception e) |
| | 330 | | { |
| 0 | 331 | | scope0.Failed(e); |
| 0 | 332 | | throw; |
| | 333 | | } |
| 4 | 334 | | } |
| | 335 | |
|
| | 336 | | /// <summary> This operation performs a union of predefined tags, resource tags, resource group tags and subscri |
| | 337 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 338 | | public virtual AsyncPageable<TagDetails> ListAsync(CancellationToken cancellationToken = default) |
| | 339 | | { |
| | 340 | | async Task<Page<TagDetails>> FirstPageFunc(int? pageSizeHint) |
| | 341 | | { |
| 4 | 342 | | using var scope0 = _clientDiagnostics.CreateScope("TagsOperations.List"); |
| 4 | 343 | | scope0.Start(); |
| | 344 | | try |
| | 345 | | { |
| 4 | 346 | | var response = await RestClient.ListAsync(cancellationToken).ConfigureAwait(false); |
| 4 | 347 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 348 | | } |
| 0 | 349 | | catch (Exception e) |
| | 350 | | { |
| 0 | 351 | | scope0.Failed(e); |
| 0 | 352 | | throw; |
| | 353 | | } |
| 4 | 354 | | } |
| | 355 | | async Task<Page<TagDetails>> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 356 | | { |
| 0 | 357 | | using var scope0 = _clientDiagnostics.CreateScope("TagsOperations.List"); |
| 0 | 358 | | scope0.Start(); |
| | 359 | | try |
| | 360 | | { |
| 0 | 361 | | var response = await RestClient.ListNextPageAsync(nextLink, cancellationToken).ConfigureAwait(false) |
| 0 | 362 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 363 | | } |
| 0 | 364 | | catch (Exception e) |
| | 365 | | { |
| 0 | 366 | | scope0.Failed(e); |
| 0 | 367 | | throw; |
| | 368 | | } |
| 0 | 369 | | } |
| 4 | 370 | | return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); |
| | 371 | | } |
| | 372 | |
|
| | 373 | | /// <summary> This operation performs a union of predefined tags, resource tags, resource group tags and subscri |
| | 374 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 375 | | public virtual Pageable<TagDetails> List(CancellationToken cancellationToken = default) |
| | 376 | | { |
| | 377 | | Page<TagDetails> FirstPageFunc(int? pageSizeHint) |
| | 378 | | { |
| 4 | 379 | | using var scope0 = _clientDiagnostics.CreateScope("TagsOperations.List"); |
| 4 | 380 | | scope0.Start(); |
| | 381 | | try |
| | 382 | | { |
| 4 | 383 | | var response = RestClient.List(cancellationToken); |
| 4 | 384 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 385 | | } |
| 0 | 386 | | catch (Exception e) |
| | 387 | | { |
| 0 | 388 | | scope0.Failed(e); |
| 0 | 389 | | throw; |
| | 390 | | } |
| 4 | 391 | | } |
| | 392 | | Page<TagDetails> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 393 | | { |
| 0 | 394 | | using var scope0 = _clientDiagnostics.CreateScope("TagsOperations.List"); |
| 0 | 395 | | scope0.Start(); |
| | 396 | | try |
| | 397 | | { |
| 0 | 398 | | var response = RestClient.ListNextPage(nextLink, cancellationToken); |
| 0 | 399 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 400 | | } |
| 0 | 401 | | catch (Exception e) |
| | 402 | | { |
| 0 | 403 | | scope0.Failed(e); |
| 0 | 404 | | throw; |
| | 405 | | } |
| 0 | 406 | | } |
| 4 | 407 | | return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); |
| | 408 | | } |
| | 409 | | } |
| | 410 | | } |