-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
RedisResource.cs
103 lines (97 loc) · 4.88 KB
/
RedisResource.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#nullable disable
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using Azure.ResourceManager;
using Azure.ResourceManager.Redis.Models;
using Azure.ResourceManager.Resources;
namespace Azure.ResourceManager.Redis
{
/// <summary>
/// A Class representing a Redis along with the instance operations that can be performed on it.
/// If you have a <see cref="ResourceIdentifier" /> you can construct a <see cref="RedisResource" />
/// from an instance of <see cref="ArmClient" /> using the GetRedisResource method.
/// Otherwise you can get one from its parent resource <see cref="ResourceGroupResource" /> using the GetRedis method.
/// </summary>
public partial class RedisResource : ArmResource
{
/// <summary>
/// Update an existing Redis cache.
/// <list type="bullet">
/// <item>
/// <term>Request Path</term>
/// <description>/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}</description>
/// </item>
/// <item>
/// <term>Operation Id</term>
/// <description>Redis_Update</description>
/// </item>
/// </list>
/// </summary>
/// <param name="patch"> Parameters supplied to the Update Redis operation. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <exception cref="ArgumentNullException"> <paramref name="patch"/> is null. </exception>
[Obsolete("This method is obsolete and will be removed in a future release. Please use another long-running operation with same method name instead.", false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual async Task<Response<RedisResource>> UpdateAsync(RedisPatch patch, CancellationToken cancellationToken = default)
{
Argument.AssertNotNull(patch, nameof(patch));
using var scope = _redisClientDiagnostics.CreateScope("RedisResource.Update");
scope.Start();
try
{
var response = await _redisRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken).ConfigureAwait(false);
var operation = new RedisArmOperation<RedisResource>(new RedisOperationSource(Client), _redisClientDiagnostics, Pipeline, _redisRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch).Request, response, OperationFinalStateVia.Location);
return await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
}
catch (Exception e)
{
scope.Failed(e);
throw;
}
}
/// <summary>
/// Update an existing Redis cache.
/// <list type="bullet">
/// <item>
/// <term>Request Path</term>
/// <description>/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/redis/{name}</description>
/// </item>
/// <item>
/// <term>Operation Id</term>
/// <description>Redis_Update</description>
/// </item>
/// </list>
/// </summary>
/// <param name="patch"> Parameters supplied to the Update Redis operation. </param>
/// <param name="cancellationToken"> The cancellation token to use. </param>
/// <exception cref="ArgumentNullException"> <paramref name="patch"/> is null. </exception>
[Obsolete("This method is obsolete and will be removed in a future release. Please use another long-running operation with same method name instead.", false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual Response<RedisResource> Update(RedisPatch patch, CancellationToken cancellationToken = default)
{
Argument.AssertNotNull(patch, nameof(patch));
using var scope = _redisClientDiagnostics.CreateScope("RedisResource.Update");
scope.Start();
try
{
var response = _redisRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken);
var operation = new RedisArmOperation<RedisResource>(new RedisOperationSource(Client), _redisClientDiagnostics, Pipeline, _redisRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch).Request, response, OperationFinalStateVia.Location);
return operation.WaitForCompletion(cancellationToken);
}
catch (Exception e)
{
scope.Failed(e);
throw;
}
}
}
}