Skip to content

Commit 6c328fc

Browse files
authored
Prepare Key Vault release (Azure#27201)
* Resolve APIView feedback * Update public APIs
1 parent e271c76 commit 6c328fc

File tree

10 files changed

+62
-50
lines changed

10 files changed

+62
-50
lines changed

sdk/keyvault/Azure.Security.KeyVault.Keys/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
### Breaking Changes
88

9+
- Changed `KeyRotationLifetimeAction.Action` to read-only and added constructor to set the `KeyRotationPolicyAction`.
10+
- Renamed `name` parameter in `GetKeyRotationPolicy` and `GetKeyRotationPolicyAsync` to `keyName`.
11+
- Renamed `name` parameter in `UpdateKeyRotationPolicy` and `UpdateKeyRotationPolicyAsync` to `keyName`.
12+
913
### Bugs Fixed
1014

1115
### Other Changes

sdk/keyvault/Azure.Security.KeyVault.Keys/api/Azure.Security.KeyVault.Keys.netstandard2.0.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ public KeyClient(System.Uri vaultUri, Azure.Core.TokenCredential credential, Azu
126126
public virtual Azure.AsyncPageable<Azure.Security.KeyVault.Keys.DeletedKey> GetDeletedKeysAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
127127
public virtual Azure.Response<Azure.Security.KeyVault.Keys.KeyVaultKey> GetKey(string name, string version = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
128128
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Security.KeyVault.Keys.KeyVaultKey>> GetKeyAsync(string name, string version = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
129-
public virtual Azure.Response<Azure.Security.KeyVault.Keys.KeyRotationPolicy> GetKeyRotationPolicy(string name, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
130-
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Security.KeyVault.Keys.KeyRotationPolicy>> GetKeyRotationPolicyAsync(string name, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
129+
public virtual Azure.Response<Azure.Security.KeyVault.Keys.KeyRotationPolicy> GetKeyRotationPolicy(string keyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
130+
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Security.KeyVault.Keys.KeyRotationPolicy>> GetKeyRotationPolicyAsync(string keyName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
131131
public virtual Azure.Pageable<Azure.Security.KeyVault.Keys.KeyProperties> GetPropertiesOfKeys(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
132132
public virtual Azure.AsyncPageable<Azure.Security.KeyVault.Keys.KeyProperties> GetPropertiesOfKeysAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
133133
public virtual Azure.Pageable<Azure.Security.KeyVault.Keys.KeyProperties> GetPropertiesOfKeyVersions(string name, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
@@ -154,8 +154,8 @@ public KeyClient(System.Uri vaultUri, Azure.Core.TokenCredential credential, Azu
154154
public virtual System.Threading.Tasks.Task<Azure.Security.KeyVault.Keys.RecoverDeletedKeyOperation> StartRecoverDeletedKeyAsync(string name, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
155155
public virtual Azure.Response<Azure.Security.KeyVault.Keys.KeyVaultKey> UpdateKeyProperties(Azure.Security.KeyVault.Keys.KeyProperties properties, System.Collections.Generic.IEnumerable<Azure.Security.KeyVault.Keys.KeyOperation> keyOperations = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
156156
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Security.KeyVault.Keys.KeyVaultKey>> UpdateKeyPropertiesAsync(Azure.Security.KeyVault.Keys.KeyProperties properties, System.Collections.Generic.IEnumerable<Azure.Security.KeyVault.Keys.KeyOperation> keyOperations = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
157-
public virtual Azure.Response<Azure.Security.KeyVault.Keys.KeyRotationPolicy> UpdateKeyRotationPolicy(string name, Azure.Security.KeyVault.Keys.KeyRotationPolicy policy, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
158-
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Security.KeyVault.Keys.KeyRotationPolicy>> UpdateKeyRotationPolicyAsync(string name, Azure.Security.KeyVault.Keys.KeyRotationPolicy policy, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
157+
public virtual Azure.Response<Azure.Security.KeyVault.Keys.KeyRotationPolicy> UpdateKeyRotationPolicy(string keyName, Azure.Security.KeyVault.Keys.KeyRotationPolicy policy, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
158+
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Security.KeyVault.Keys.KeyRotationPolicy>> UpdateKeyRotationPolicyAsync(string keyName, Azure.Security.KeyVault.Keys.KeyRotationPolicy policy, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
159159
}
160160
public partial class KeyClientOptions : Azure.Core.ClientOptions
161161
{
@@ -271,8 +271,8 @@ public KeyReleasePolicy(System.BinaryData encodedPolicy) { }
271271
}
272272
public partial class KeyRotationLifetimeAction
273273
{
274-
public KeyRotationLifetimeAction() { }
275-
public Azure.Security.KeyVault.Keys.KeyRotationPolicyAction Action { get { throw null; } set { } }
274+
public KeyRotationLifetimeAction(Azure.Security.KeyVault.Keys.KeyRotationPolicyAction action) { }
275+
public Azure.Security.KeyVault.Keys.KeyRotationPolicyAction Action { get { throw null; } }
276276
public string TimeAfterCreate { get { throw null; } set { } }
277277
public string TimeBeforeExpiry { get { throw null; } set { } }
278278
}

sdk/keyvault/Azure.Security.KeyVault.Keys/samples/Sample8_KeyRotation.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ KeyRotationPolicy policy = new KeyRotationPolicy()
4141
ExpiresIn = "P90D",
4242
LifetimeActions =
4343
{
44-
new KeyRotationLifetimeAction()
44+
new KeyRotationLifetimeAction(KeyRotationPolicyAction.Rotate)
4545
{
46-
Action = KeyRotationPolicyAction.Rotate,
4746
TimeBeforeExpiry = "P30D"
4847
}
4948
}

sdk/keyvault/Azure.Security.KeyVault.Keys/src/KeyClient.cs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,26 +1385,26 @@ public virtual CryptographyClient GetCryptographyClient(string keyName, string k
13851385
/// <summary>
13861386
/// Gets the <see cref="KeyRotationPolicy"/> for the specified key in Key Vault.
13871387
/// </summary>
1388-
/// <param name="name">The name of the key.</param>
1388+
/// <param name="keyName">The name of the key.</param>
13891389
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
13901390
/// <remarks>
13911391
/// This operation requires the keys/get permission.
13921392
/// </remarks>
13931393
/// <returns>A <see cref="KeyRotationPolicy"/> for the specified key.</returns>
1394-
/// <exception cref="ArgumentException"><paramref name="name"/> contains an empty string.</exception>
1395-
/// <exception cref="ArgumentNullException"><paramref name="name"/> is null.</exception>
1394+
/// <exception cref="ArgumentException"><paramref name="keyName"/> contains an empty string.</exception>
1395+
/// <exception cref="ArgumentNullException"><paramref name="keyName"/> is null.</exception>
13961396
/// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception>
1397-
public virtual Response<KeyRotationPolicy> GetKeyRotationPolicy(string name, CancellationToken cancellationToken = default)
1397+
public virtual Response<KeyRotationPolicy> GetKeyRotationPolicy(string keyName, CancellationToken cancellationToken = default)
13981398
{
1399-
Argument.AssertNotNullOrEmpty(name, nameof(name));
1399+
Argument.AssertNotNullOrEmpty(keyName, nameof(keyName));
14001400

14011401
using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(KeyClient)}.{nameof(GetKeyRotationPolicy)}");
1402-
scope.AddAttribute("key", name);
1402+
scope.AddAttribute("key", keyName);
14031403
scope.Start();
14041404

14051405
try
14061406
{
1407-
return _pipeline.SendRequest(RequestMethod.Get, () => new KeyRotationPolicy(), cancellationToken, KeysPath, name, "/rotationpolicy");
1407+
return _pipeline.SendRequest(RequestMethod.Get, () => new KeyRotationPolicy(), cancellationToken, KeysPath, keyName, "/rotationpolicy");
14081408
}
14091409
catch (Exception e)
14101410
{
@@ -1416,26 +1416,26 @@ public virtual Response<KeyRotationPolicy> GetKeyRotationPolicy(string name, Can
14161416
/// <summary>
14171417
/// Gets the <see cref="KeyRotationPolicy"/> for the specified key in Key Vault.
14181418
/// </summary>
1419-
/// <param name="name">The name of the key.</param>
1419+
/// <param name="keyName">The name of the key.</param>
14201420
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
14211421
/// <remarks>
14221422
/// This operation requires the keys/get permission.
14231423
/// </remarks>
14241424
/// <returns>A <see cref="KeyRotationPolicy"/> for the specified key.</returns>
1425-
/// <exception cref="ArgumentException"><paramref name="name"/> contains an empty string.</exception>
1426-
/// <exception cref="ArgumentNullException"><paramref name="name"/> is null.</exception>
1425+
/// <exception cref="ArgumentException"><paramref name="keyName"/> contains an empty string.</exception>
1426+
/// <exception cref="ArgumentNullException"><paramref name="keyName"/> is null.</exception>
14271427
/// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception>
1428-
public virtual async Task<Response<KeyRotationPolicy>> GetKeyRotationPolicyAsync(string name, CancellationToken cancellationToken = default)
1428+
public virtual async Task<Response<KeyRotationPolicy>> GetKeyRotationPolicyAsync(string keyName, CancellationToken cancellationToken = default)
14291429
{
1430-
Argument.AssertNotNullOrEmpty(name, nameof(name));
1430+
Argument.AssertNotNullOrEmpty(keyName, nameof(keyName));
14311431

14321432
using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(KeyClient)}.{nameof(GetKeyRotationPolicy)}");
1433-
scope.AddAttribute("key", name);
1433+
scope.AddAttribute("key", keyName);
14341434
scope.Start();
14351435

14361436
try
14371437
{
1438-
return await _pipeline.SendRequestAsync(RequestMethod.Get, () => new KeyRotationPolicy(), cancellationToken, KeysPath, name, "/rotationpolicy").ConfigureAwait(false);
1438+
return await _pipeline.SendRequestAsync(RequestMethod.Get, () => new KeyRotationPolicy(), cancellationToken, KeysPath, keyName, "/rotationpolicy").ConfigureAwait(false);
14391439
}
14401440
catch (Exception e)
14411441
{
@@ -1509,28 +1509,28 @@ public virtual async Task<Response<KeyVaultKey>> RotateKeyAsync(string name, Can
15091509
/// <summary>
15101510
/// Updates the <see cref="KeyRotationPolicy"/> for the specified key in Key Vault.
15111511
/// </summary>
1512-
/// <param name="name">The name of the key.</param>
1512+
/// <param name="keyName">The name of the key.</param>
15131513
/// <param name="policy">The <see cref="KeyRotationPolicy"/> to update.</param>
15141514
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
15151515
/// <remarks>
15161516
/// This operation requires the keys/update permission.
15171517
/// </remarks>
15181518
/// <returns>A <see cref="KeyRotationPolicy"/> for the specified key.</returns>
1519-
/// <exception cref="ArgumentException"><paramref name="name"/> contains an empty string.</exception>
1520-
/// <exception cref="ArgumentNullException"><paramref name="name"/> or <paramref name="policy"/> is null.</exception>
1519+
/// <exception cref="ArgumentException"><paramref name="keyName"/> contains an empty string.</exception>
1520+
/// <exception cref="ArgumentNullException"><paramref name="keyName"/> or <paramref name="policy"/> is null.</exception>
15211521
/// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception>
1522-
public virtual Response<KeyRotationPolicy> UpdateKeyRotationPolicy(string name, KeyRotationPolicy policy, CancellationToken cancellationToken = default)
1522+
public virtual Response<KeyRotationPolicy> UpdateKeyRotationPolicy(string keyName, KeyRotationPolicy policy, CancellationToken cancellationToken = default)
15231523
{
1524-
Argument.AssertNotNullOrEmpty(name, nameof(name));
1524+
Argument.AssertNotNullOrEmpty(keyName, nameof(keyName));
15251525
Argument.AssertNotNull(policy, nameof(policy));
15261526

15271527
using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(KeyClient)}.{nameof(UpdateKeyRotationPolicy)}");
1528-
scope.AddAttribute("key", name);
1528+
scope.AddAttribute("key", keyName);
15291529
scope.Start();
15301530

15311531
try
15321532
{
1533-
return _pipeline.SendRequest(RequestMethod.Put, policy, () => new KeyRotationPolicy(), cancellationToken, KeysPath, name, "/rotationpolicy");
1533+
return _pipeline.SendRequest(RequestMethod.Put, policy, () => new KeyRotationPolicy(), cancellationToken, KeysPath, keyName, "/rotationpolicy");
15341534
}
15351535
catch (Exception e)
15361536
{
@@ -1542,28 +1542,28 @@ public virtual Response<KeyRotationPolicy> UpdateKeyRotationPolicy(string name,
15421542
/// <summary>
15431543
/// Updates the <see cref="KeyRotationPolicy"/> for the specified key in Key Vault.
15441544
/// </summary>
1545-
/// <param name="name">The name of the key.</param>
1545+
/// <param name="keyName">The name of the key.</param>
15461546
/// <param name="policy">The <see cref="KeyRotationPolicy"/> to update.</param>
15471547
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
15481548
/// <remarks>
15491549
/// This operation requires the keys/update permission.
15501550
/// </remarks>
15511551
/// <returns>A <see cref="KeyRotationPolicy"/> for the specified key.</returns>
1552-
/// <exception cref="ArgumentException"><paramref name="name"/> contains an empty string.</exception>
1553-
/// <exception cref="ArgumentNullException"><paramref name="name"/> or <paramref name="policy"/> is null.</exception>
1552+
/// <exception cref="ArgumentException"><paramref name="keyName"/> contains an empty string.</exception>
1553+
/// <exception cref="ArgumentNullException"><paramref name="keyName"/> or <paramref name="policy"/> is null.</exception>
15541554
/// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception>
1555-
public virtual async Task<Response<KeyRotationPolicy>> UpdateKeyRotationPolicyAsync(string name, KeyRotationPolicy policy, CancellationToken cancellationToken = default)
1555+
public virtual async Task<Response<KeyRotationPolicy>> UpdateKeyRotationPolicyAsync(string keyName, KeyRotationPolicy policy, CancellationToken cancellationToken = default)
15561556
{
1557-
Argument.AssertNotNullOrEmpty(name, nameof(name));
1557+
Argument.AssertNotNullOrEmpty(keyName, nameof(keyName));
15581558
Argument.AssertNotNull(policy, nameof(policy));
15591559

15601560
using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(KeyClient)}.{nameof(UpdateKeyRotationPolicy)}");
1561-
scope.AddAttribute("key", name);
1561+
scope.AddAttribute("key", keyName);
15621562
scope.Start();
15631563

15641564
try
15651565
{
1566-
return await _pipeline.SendRequestAsync(RequestMethod.Put, policy, () => new KeyRotationPolicy(), cancellationToken, KeysPath, name, "/rotationpolicy").ConfigureAwait(false);
1566+
return await _pipeline.SendRequestAsync(RequestMethod.Put, policy, () => new KeyRotationPolicy(), cancellationToken, KeysPath, keyName, "/rotationpolicy").ConfigureAwait(false);
15671567
}
15681568
catch (Exception e)
15691569
{

sdk/keyvault/Azure.Security.KeyVault.Keys/src/KeyRotationLifetimeAction.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,22 @@ public class KeyRotationLifetimeAction : IJsonSerializable, IJsonDeserializable
2323
private static readonly JsonEncodedText s_timeBeforeExpiryPropertyNameBytes = JsonEncodedText.Encode(TimeBeforeExpiryPropertyName);
2424

2525
/// <summary>
26-
/// Gets or sets he <see cref="KeyRotationPolicyAction"/> that will be executed.
26+
/// Initializes a new instance of the <see cref="KeyRotationLifetimeAction"/> structure.
2727
/// </summary>
28-
public KeyRotationPolicyAction Action { get; set; }
28+
/// <param name="action">The <see cref="KeyRotationPolicyAction"/> that will be executed.</param>
29+
public KeyRotationLifetimeAction(KeyRotationPolicyAction action)
30+
{
31+
Action = action;
32+
}
33+
34+
internal KeyRotationLifetimeAction()
35+
{
36+
}
37+
38+
/// <summary>
39+
/// Gets the <see cref="KeyRotationPolicyAction"/> that will be executed.
40+
/// </summary>
41+
public KeyRotationPolicyAction Action { get; private set; }
2942

3043
/// <summary>
3144
/// Gets or sets the ISO 8601 duration after creation to attempt to rotate. It only applies to <see cref="KeyRotationPolicyAction.Rotate"/>.

sdk/keyvault/Azure.Security.KeyVault.Keys/tests/KeyClientLiveTests.KeyRotation.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,8 @@ public async Task UpdateKeyRotationPolicy()
7070
ExpiresIn = "P90D",
7171
LifetimeActions =
7272
{
73-
new KeyRotationLifetimeAction
73+
new KeyRotationLifetimeAction(KeyRotationPolicyAction.Rotate)
7474
{
75-
Action = KeyRotationPolicyAction.Rotate,
7675
TimeBeforeExpiry = "P10D",
7776
}
7877
}

sdk/keyvault/Azure.Security.KeyVault.Keys/tests/KeyClientTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,10 @@ public async Task GetCryptographyClientUsesSamePipeline()
265265
public void GetKeyRotationPolicyValidation()
266266
{
267267
ArgumentException ex = Assert.ThrowsAsync<ArgumentNullException>(async () => await Client.GetKeyRotationPolicyAsync(null));
268-
Assert.AreEqual("name", ex.ParamName);
268+
Assert.AreEqual("keyName", ex.ParamName);
269269

270270
ex = Assert.ThrowsAsync<ArgumentException>(async () => await Client.GetKeyRotationPolicyAsync(string.Empty));
271-
Assert.AreEqual("name", ex.ParamName);
271+
Assert.AreEqual("keyName", ex.ParamName);
272272
}
273273

274274
[Test]
@@ -285,10 +285,10 @@ public void RotateKeyValidation()
285285
public void UpdateKeyRotationPolicyValidation()
286286
{
287287
ArgumentException ex = Assert.ThrowsAsync<ArgumentNullException>(async () => await Client.UpdateKeyRotationPolicyAsync(null, null));
288-
Assert.AreEqual("name", ex.ParamName);
288+
Assert.AreEqual("keyName", ex.ParamName);
289289

290290
ex = Assert.ThrowsAsync<ArgumentException>(async () => await Client.UpdateKeyRotationPolicyAsync(string.Empty, null));
291-
Assert.AreEqual("name", ex.ParamName);
291+
Assert.AreEqual("keyName", ex.ParamName);
292292

293293
ex = Assert.ThrowsAsync<ArgumentNullException>(async () => await Client.UpdateKeyRotationPolicyAsync("test", null));
294294
Assert.AreEqual("policy", ex.ParamName);

sdk/keyvault/Azure.Security.KeyVault.Keys/tests/KeyRotationPolicyTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,8 @@ public void SerializesOnlyWritableProperties()
8383
ExpiresIn = "P45D",
8484
LifetimeActions =
8585
{
86-
new KeyRotationLifetimeAction
86+
new KeyRotationLifetimeAction(KeyRotationPolicyAction.Rotate)
8787
{
88-
Action = KeyRotationPolicyAction.Rotate,
8988
TimeBeforeExpiry= "P30D",
9089
}
9190
},

0 commit comments

Comments
 (0)