Skip to content

Commit 8ae1467

Browse files
authored
Merge pull request #123 from UiPath/feature/credential_stores
19.10 credential stores support
2 parents d3edd35 + aef40c1 commit 8ae1467

File tree

6 files changed

+173
-0
lines changed

6 files changed

+173
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using System.Management.Automation;
2+
using UiPath.PowerShell.Models;
3+
using UiPath.PowerShell.Util;
4+
using UiPath.Web.Client201910;
5+
//NB: the use of 20.4 resource type enum on the 19.10 client is intentional
6+
using ResourceType20204 = UiPath.Web.Client20204.Models.DefaultCredentialStoreDtoResourceType;
7+
8+
namespace UiPath.PowerShell.Cmdlets
9+
{
10+
[Cmdlet(VerbsCommon.Get, Nouns.CredentialStore)]
11+
public class GetCredentialStore : FilteredIdCmdlet
12+
{
13+
[Filter]
14+
[Parameter(ParameterSetName = "Filter")]
15+
public string Name { get; set; }
16+
17+
[Filter]
18+
[Parameter(ParameterSetName = "Filter")]
19+
public string Type { get; set; }
20+
21+
[ValidateEnum(typeof(ResourceType20204))]
22+
[Parameter(ParameterSetName = "Defaults", Mandatory = true)]
23+
public string Default { get; set; }
24+
25+
protected override void ProcessRecord()
26+
{
27+
if (ParameterSetName == "Defaults")
28+
{
29+
var id = HandleHttpResponseException(() => Api_19_10.CredentialStores.GetDefaultStoreForResourceTypeByResourcetypeWithHttpMessagesAsync(Default));
30+
if (id.Value.HasValue)
31+
{
32+
var store = HandleHttpResponseException(() => Api_19_10.CredentialStores.GetByIdWithHttpMessagesAsync(id.Value.Value));
33+
WriteObject(CredentialStore.FromDto(store));
34+
}
35+
}
36+
else
37+
{
38+
ProcessImpl(
39+
(filter, top, skip) => HandleHttpResponseException(() => Api_19_10.CredentialStores.GetCredentialStoresWithHttpMessagesAsync(filter: filter, top: top, skip: skip, count: false)),
40+
id => HandleHttpResponseException(() => Api_19_10.CredentialStores.GetByIdWithHttpMessagesAsync(id)),
41+
dto => CredentialStore.FromDto(dto));
42+
}
43+
}
44+
}
45+
}

UiPath.PowerShell/Cmdlets/Nouns.cs

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ internal static class Nouns
77
internal const string Asset = UiPath + "Asset";
88
internal const string AssetRobotValue = UiPath + "AssetRobotValue";
99
internal const string AuthToken = UiPath + "AuthToken";
10+
internal const string CredentialStore = UiPath + "CredentialStore";
1011
internal const string Environment = UiPath + "Environment";
1112
internal const string EnvironmentRobot = UiPath + "EnvironmentRobot";
1213
internal const string Folder = UiPath + "Folder";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System.ComponentModel;
2+
using UiPath.PowerShell.Util;
3+
using UiPath.Web.Client201910.Models;
4+
5+
namespace UiPath.PowerShell.Models
6+
{
7+
[TypeConverter(typeof(UiPathTypeConverter))]
8+
public class CredentialStore
9+
{
10+
public long Id { get; private set; }
11+
public string Name { get; private set; }
12+
public string Type { get; private set; }
13+
public string AdditionalConfiguration { get; private set; }
14+
public bool? IsReadOnly { get; private set; }
15+
16+
internal static CredentialStore FromDto(CredentialStoreDto dto) =>
17+
new CredentialStore
18+
{
19+
Id = dto.Id.Value,
20+
Name = dto.Name,
21+
Type = dto.Type,
22+
AdditionalConfiguration = dto.AdditionalConfiguration,
23+
IsReadOnly = dto.Details?.IsReadOnly
24+
};
25+
}
26+
}

UiPath.Web.Client/Extensions/ODataExtensions.cs

+5
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,9 @@ public partial class ODataResponseListUserRolesDto: IODataValues<UserRolesDto>
111111
{
112112

113113
}
114+
115+
public partial class ODataResponseListCredentialStoreDto: IODataValues<CredentialStoreDto>
116+
{
117+
118+
}
114119
}

docs/Get-UiPathCredentialStore.md

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
```PowerShell
2+
3+
NAME
4+
Get-UiPathCredentialStore
5+
6+
SYNOPSIS
7+
8+
9+
SYNTAX
10+
Get-UiPathCredentialStore [-AuthToken <AuthToken>] [-Name <string>] [-Paging <SwitchParameter>] [-RequestTimeout
11+
<int>] [-Type <string>] [<CommonParameters>]
12+
13+
Get-UiPathCredentialStore -Default <string> [-AuthToken <AuthToken>] [-Paging <SwitchParameter>] [-RequestTimeout
14+
<int>] [<CommonParameters>]
15+
16+
Get-UiPathCredentialStore -Id <long> [-AuthToken <AuthToken>] [-Paging <SwitchParameter>] [-RequestTimeout <int>]
17+
[<CommonParameters>]
18+
19+
20+
DESCRIPTION
21+
22+
23+
PARAMETERS
24+
-Name <string>
25+
26+
Required? false
27+
Position? named
28+
Default value
29+
Accept pipeline input? false
30+
Accept wildcard characters? false
31+
32+
-Type <string>
33+
34+
Required? false
35+
Position? named
36+
Default value
37+
Accept pipeline input? false
38+
Accept wildcard characters? false
39+
40+
-Default <string>
41+
42+
Required? true
43+
Position? named
44+
Default value
45+
Accept pipeline input? false
46+
Accept wildcard characters? false
47+
48+
-Id <long>
49+
50+
Required? true
51+
Position? named
52+
Default value
53+
Accept pipeline input? false
54+
Accept wildcard characters? false
55+
56+
-Paging <SwitchParameter>
57+
58+
Required? false
59+
Position? named
60+
Default value False
61+
Accept pipeline input? false
62+
Accept wildcard characters? false
63+
64+
-AuthToken <AuthToken>
65+
66+
Required? false
67+
Position? named
68+
Default value
69+
Accept pipeline input? false
70+
Accept wildcard characters? false
71+
72+
-RequestTimeout <int>
73+
74+
Required? false
75+
Position? named
76+
Default value 100
77+
Accept pipeline input? false
78+
Accept wildcard characters? false
79+
80+
<CommonParameters>
81+
This cmdlet supports the common parameters: Verbose, Debug,
82+
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
83+
OutBuffer, PipelineVariable, and OutVariable. For more information, see
84+
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
85+
86+
INPUTS
87+
88+
OUTPUTS
89+
90+
91+
RELATED LINKS
92+
93+
94+
95+
```

docs/Home.md

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
- [Edit-UiPathWebhook](Edit-UiPathWebhook.md)
3333
- [Get-UiPathAsset](Get-UiPathAsset.md)
3434
- [Get-UiPathAuthToken](Get-UiPathAuthToken.md)
35+
- [Get-UiPathCredentialStore](Get-UiPathCredentialStore.md)
3536
- [Get-UiPathCurrentUserFolders](Get-UiPathCurrentUserFolders.md)
3637
- [Get-UiPathEnvironment](Get-UiPathEnvironment.md)
3738
- [Get-UiPathEnvironmentRobot](Get-UiPathEnvironmentRobot.md)

0 commit comments

Comments
 (0)