Skip to content

Commit 4e248d4

Browse files
authored
Merge pull request Azure#6126 from dragav/preview
adding support for listing pending certificates
2 parents 4c823d0 + 35c61b0 commit 4e248d4

File tree

7 files changed

+67
-13
lines changed

7 files changed

+67
-13
lines changed

src/ResourceManager/KeyVault/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Current Release
21+
* Adding support for listing certificates in a pending state
2122

2223
## Version 5.0.0
2324
* Breaking changes to support piping scenarios

src/ResourceManager/KeyVault/Commands.KeyVault/Commands.KeyVault.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
<Compile Include="Commands\UndoAzureKeyVaultKeyRemoval.cs" />
9292
<Compile Include="Commands\UndoAzureKeyVaultSecretRemoval.cs" />
9393
<Compile Include="Commands\UpdateAzureKeyVaultSecret.cs" />
94+
<Compile Include="Models\KeyVaultCertificateFilterOptions.cs" />
9495
<Compile Include="Models\ManagedStorageAccounts\PSDeletedKeyVaultManagedStorageAccount.cs" />
9596
<Compile Include="Models\ManagedStorageAccounts\PSDeletedKeyVaultManagedStorageAccountIdentityItem.cs" />
9697
<Compile Include="Models\ManagedStorageAccounts\PSDeletedKeyVaultManagedStorageSasDefinition.cs" />

src/ResourceManager/KeyVault/Commands.KeyVault/Commands/GetAzureKeyVaultCertificate.cs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,20 @@ public class GetAzureKeyVaultCertificate : KeyVaultCmdletBase
186186
ParameterSetName = ResourceIdByVaultNameParameterSet,
187187
HelpMessage = "Specifies whether to show the previously deleted certificates in the output.")]
188188
public SwitchParameter InRemovedState { get; set; }
189+
190+
/// <summary>
191+
/// Switch specifying whether to include the pending certificates in the enumeration.
192+
/// </summary>
193+
[Parameter(Mandatory = false,
194+
ParameterSetName = ByVaultNameParameterSet,
195+
HelpMessage = "Specifies whether to include the pending certificates in the output.")]
196+
[Parameter(Mandatory = false,
197+
ParameterSetName = InputObjectByVaultNameParameterSet,
198+
HelpMessage = "Specifies whether to include the pending certificates in the output.")]
199+
[Parameter(Mandatory = false,
200+
ParameterSetName = ResourceIdByVaultNameParameterSet,
201+
HelpMessage = "Specifies whether to include the pending certificates in the output.")]
202+
public SwitchParameter IncludePending { get; set; }
189203
#endregion
190204

191205
public override void ExecuteCmdlet()
@@ -241,10 +255,11 @@ public override void ExecuteCmdlet()
241255

242256
private void GetAndWriteCertificates(string vaultName)
243257
{
244-
KeyVaultObjectFilterOptions options = new KeyVaultObjectFilterOptions
258+
var options = new KeyVaultCertificateFilterOptions
245259
{
246260
VaultName = VaultName,
247-
NextLink = null
261+
NextLink = null,
262+
IncludePending = IncludePending
248263
};
249264

250265
do
@@ -272,10 +287,11 @@ private void GetAndWriteCertificatesVersions(string vaultName, string name, stri
272287

273288
private void GetAndWriteDeletedCertificates( string vaultName )
274289
{
275-
KeyVaultObjectFilterOptions options = new KeyVaultObjectFilterOptions
290+
var options = new KeyVaultCertificateFilterOptions
276291
{
277292
VaultName = VaultName,
278-
NextLink = null
293+
NextLink = null,
294+
IncludePending = IncludePending
279295
};
280296

281297
do

src/ResourceManager/KeyVault/Commands.KeyVault/Models/IKeyVaultDataServiceClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ public interface IKeyVaultDataServiceClient
8585

8686
PSDeletedKeyVaultCertificate GetDeletedCertificate( string vaultName, string certName );
8787

88-
IEnumerable<PSKeyVaultCertificateIdentityItem> GetCertificates(KeyVaultObjectFilterOptions options);
88+
IEnumerable<PSKeyVaultCertificateIdentityItem> GetCertificates(KeyVaultCertificateFilterOptions options);
8989

90-
IEnumerable<PSDeletedKeyVaultCertificateIdentityItem> GetDeletedCertificates( KeyVaultObjectFilterOptions options );
90+
IEnumerable<PSDeletedKeyVaultCertificateIdentityItem> GetDeletedCertificates( KeyVaultCertificateFilterOptions options );
9191

9292
IEnumerable<PSKeyVaultCertificateIdentityItem> GetCertificateVersions(KeyVaultObjectFilterOptions options);
9393

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
namespace Microsoft.Azure.Commands.KeyVault.Models
16+
{
17+
public sealed class KeyVaultCertificateFilterOptions : KeyVaultObjectFilterOptions
18+
{
19+
public bool? IncludePending { get; set; }
20+
}
21+
}

src/ResourceManager/KeyVault/Commands.KeyVault/Models/KeyVaultDataServiceClient.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ public PSKeyVaultKey GetKey(string vaultName, string keyName, string keyVersion)
340340
return new PSKeyVaultKey(keyBundle, this.vaultUriHelper);
341341
}
342342

343-
public IEnumerable<PSKeyVaultCertificateIdentityItem> GetCertificates(KeyVaultObjectFilterOptions options)
343+
public IEnumerable<PSKeyVaultCertificateIdentityItem> GetCertificates(KeyVaultCertificateFilterOptions options)
344344
{
345345
if (options == null)
346346
throw new ArgumentNullException(nameof(options));
@@ -355,7 +355,7 @@ public IEnumerable<PSKeyVaultCertificateIdentityItem> GetCertificates(KeyVaultOb
355355
IPage<CertificateItem> result;
356356

357357
if (string.IsNullOrEmpty(options.NextLink))
358-
result = this.keyVaultClient.GetCertificatesAsync(vaultAddress).GetAwaiter().GetResult();
358+
result = this.keyVaultClient.GetCertificatesAsync(vaultAddress, maxresults: null, includePending: options.IncludePending).GetAwaiter().GetResult();
359359
else
360360
result = this.keyVaultClient.GetCertificatesNextAsync(options.NextLink).GetAwaiter().GetResult();
361361

@@ -1667,7 +1667,7 @@ public PSDeletedKeyVaultCertificate GetDeletedCertificate( string vaultName, str
16671667
return new PSDeletedKeyVaultCertificate(deletedCertificate);
16681668
}
16691669

1670-
public IEnumerable<PSDeletedKeyVaultCertificateIdentityItem> GetDeletedCertificates( KeyVaultObjectFilterOptions options )
1670+
public IEnumerable<PSDeletedKeyVaultCertificateIdentityItem> GetDeletedCertificates( KeyVaultCertificateFilterOptions options )
16711671
{
16721672
if ( options == null )
16731673
throw new ArgumentNullException( nameof( options ) );
@@ -1681,7 +1681,7 @@ public IEnumerable<PSDeletedKeyVaultCertificateIdentityItem> GetDeletedCertifica
16811681
IPage<DeletedCertificateItem> result;
16821682

16831683
if ( string.IsNullOrEmpty( options.NextLink ) )
1684-
result = this.keyVaultClient.GetDeletedCertificatesAsync( vaultAddress ).GetAwaiter( ).GetResult( );
1684+
result = this.keyVaultClient.GetDeletedCertificatesAsync( vaultAddress, maxresults: null, includePending: options.IncludePending ).GetAwaiter( ).GetResult( );
16851685
else
16861686
result = this.keyVaultClient.GetDeletedCertificatesNextAsync( options.NextLink ).GetAwaiter( ).GetResult( );
16871687

src/ResourceManager/KeyVault/Commands.KeyVault/help/Get-AzureKeyVaultCertificate.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Gets a certificate from a key vault.
1616
### ByName (Default)
1717
```
1818
Get-AzureKeyVaultCertificate [-VaultName] <String> [[-Name] <String>] [-InRemovedState]
19-
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
19+
[-IncludePending] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
2020
```
2121

2222
### ByCertificateNameAndVersion
@@ -34,7 +34,7 @@ Get-AzureKeyVaultCertificate [-VaultName] <String> [-Name] <String> [-IncludeVer
3434
### ByNameInputObject
3535
```
3636
Get-AzureKeyVaultCertificate [-InputObject] <PSKeyVault> [[-Name] <String>] [-InRemovedState]
37-
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
37+
[-IncludePending] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
3838
```
3939

4040
### ByCertificateNameAndVersionInputObject
@@ -52,7 +52,7 @@ Get-AzureKeyVaultCertificate [-InputObject] <PSKeyVault> [-Name] <String> [-Incl
5252
### ByNameResourceId
5353
```
5454
Get-AzureKeyVaultCertificate [-ResourceId] <String> [[-Name] <String>] [-InRemovedState]
55-
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
55+
[-IncludePending] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
5656
```
5757

5858
### ByCertificateNameAndVersionResourceId
@@ -252,6 +252,21 @@ Accept pipeline input: False
252252
Accept wildcard characters: False
253253
```
254254
255+
### -IncludePending
256+
Specifies whether to include pending certificates in the output
257+
258+
```yaml
259+
Type: SwitchParameter
260+
Parameter Sets: ByName, ByNameInputObject, ByNameResourceId
261+
Aliases:
262+
263+
Required: False
264+
Position: Named
265+
Default value: None
266+
Accept pipeline input: False
267+
Accept wildcard characters: False
268+
```
269+
255270
### CommonParameters
256271
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
257272

0 commit comments

Comments
 (0)