Skip to content

Commit e32fcd9

Browse files
committed
Fix assets with value per robot
1 parent c33ff2a commit e32fcd9

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

UiPath.PowerShell/Cmdlets/GetAsset.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class GetAsset: FilteredBaseCmdlet
1515
protected override void ProcessRecord()
1616
{
1717
ProcessImpl(
18-
filter => Api.Assets.GetAssets(filter: filter).Value,
18+
filter => Api.Assets.GetAssets(filter: filter, expand: "RobotValues").Value,
1919
dto => Asset.FromDto(dto));
2020
}
2121
}

UiPath.PowerShell/Models/Asset.cs

+18-15
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
using System;
2-
using System.Collections.Generic;
1+
using System.Collections.Generic;
32
using System.Linq;
43
using System.Management.Automation;
5-
using System.Security;
6-
using System.Text;
7-
using System.Threading.Tasks;
84
using UiPath.Web.Client.Models;
95

106
namespace UiPath.PowerShell.Models
@@ -27,25 +23,32 @@ public class Asset
2723

2824
internal static Asset FromDto(AssetDto dto)
2925
{
30-
return new Asset
26+
var asset = new Asset
3127
{
3228
Id = dto.Id.Value,
3329
Name = dto.Name,
3430
ValueType = dto.ValueType,
3531
ValueScope = dto.ValueScope,
36-
Value = dto.Value,
37-
RobotValues = dto.RobotValues?.ToDictionary(r => r.RobotId.Value, r=> r.Value),
32+
Value = dto.ValueScope == AssetDtoValueScope.Global ? dto.Value : null,
33+
RobotValues = dto.RobotValues?.ToDictionary(r => r.RobotId.Value, r => r.Value),
3834
KeyValueList = dto.KeyValueList?.ToDictionary(kv => kv.Key, kv => kv.Value),
3935
CanBeDeleted = dto.CanBeDeleted,
40-
WindowsCredential = (dto.ValueType == AssetDtoValueType.WindowsCredential) ?
41-
new PSCredential(
42-
dto.CredentialUsername,
43-
Cmdlets.AddAsset.MakeSecureString(dto.CredentialPassword)) : null,
44-
Credential = (dto.ValueType == AssetDtoValueType.Credential) ?
45-
new PSCredential(
36+
};
37+
38+
if (dto.ValueScope == AssetDtoValueScope.Global && dto.ValueType == AssetDtoValueType.WindowsCredential)
39+
{
40+
asset.WindowsCredential = new PSCredential(
41+
dto.CredentialUsername,
42+
Cmdlets.AddAsset.MakeSecureString(dto.CredentialPassword));
43+
}
44+
else if (dto.ValueScope == AssetDtoValueScope.Global && dto.ValueType == AssetDtoValueType.Credential)
45+
{
46+
asset.Credential = new PSCredential(
4647
dto.CredentialUsername,
47-
Cmdlets.AddAsset.MakeSecureString(dto.CredentialPassword)) : null
48+
Cmdlets.AddAsset.MakeSecureString(dto.CredentialPassword));
49+
4850
};
51+
return asset;
4952
}
5053
}
5154
}

0 commit comments

Comments
 (0)