44using UiPath . PowerShell . Util ;
55using UiPath . Web . Client20181 ;
66using UiPath . Web . Client20183 ;
7+ using UiPath . Web . Client20184 ;
78using RobotDtoType20181 = UiPath . Web . Client20181 . Models . RobotDtoType ;
89using RobotDtoType20183 = UiPath . Web . Client20183 . Models . RobotDtoType ;
10+ using RobotDtoType20184 = UiPath . Web . Client20184 . Models . RobotDtoType ;
911using RobotDtoHostingType20183 = UiPath . Web . Client20183 . Models . RobotDtoHostingType ;
1012using RobotDto20181 = UiPath . Web . Client20181 . Models . RobotDto ;
1113using RobotDto20183 = UiPath . Web . Client20183 . Models . RobotDto ;
14+ using RobotDto20184 = UiPath . Web . Client20184 . Models . RobotDto ;
1215
1316namespace UiPath . PowerShell . Cmdlets
1417{
1518 [ Cmdlet ( VerbsCommon . Add , Nouns . Robot ) ]
16- public class AddRobot : AuthenticatedCmdlet
19+ public class AddRobot : AuthenticatedCmdlet
1720 {
1821 [ Parameter ( Mandatory = true ) ]
1922 public string Name { get ; private set ; }
@@ -42,9 +45,17 @@ public class AddRobot: AuthenticatedCmdlet
4245 [ Parameter ]
4346 public string HostingType { get ; set ; }
4447
48+ [ ValidateEnum ( typeof ( Web . Client20184 . Models . RobotDtoCredentialType ) ) ]
49+ [ Parameter ]
50+ public string CredentialType { get ; set ; }
51+
4552 protected override void ProcessRecord ( )
4653 {
47- if ( MyInvocation . BoundParameters . ContainsKey ( nameof ( HostingType ) ) )
54+ if ( MyInvocation . BoundParameters . ContainsKey ( nameof ( CredentialType ) ) )
55+ {
56+ AddRobot20184 ( ) ;
57+ }
58+ else if ( MyInvocation . BoundParameters . ContainsKey ( nameof ( HostingType ) ) )
4859 {
4960 AddRobot20183 ( ) ;
5061 }
@@ -55,7 +66,7 @@ protected override void ProcessRecord()
5566 }
5667
5768 private void AddRobot20181 ( )
58- {
69+ {
5970 var robot = new RobotDto20181
6071 {
6172 Name = Name ,
@@ -66,11 +77,7 @@ private void AddRobot20181()
6677 Description = Description ,
6778 } ;
6879
69- RobotDtoType20181 type ;
70- if ( Enum . TryParse < RobotDtoType20181 > ( Type , out type ) )
71- {
72- robot . Type = type ;
73- }
80+ ApplyEnumMember < RobotDtoType20181 > ( Type , type => robot . Type = type ) ;
7481
7582 var dto = HandleHttpOperationException ( ( ) => Api . Robots . Post ( robot ) ) ;
7683 WriteObject ( Robot . FromDto ( dto ) ) ;
@@ -85,18 +92,34 @@ private void AddRobot20183()
8592 LicenseKey = LicenseKey ,
8693 Username = Username ,
8794 Password = Password ,
88- Description = Description ,
89- HostingType = ( RobotDtoHostingType20183 ) Enum . Parse ( typeof ( RobotDtoHostingType20183 ) , HostingType )
95+ Description = Description
9096 } ;
9197
92- RobotDtoType20183 type ;
93- if ( Enum . TryParse < RobotDtoType20183 > ( Type , out type ) )
94- {
95- robot . Type = type ;
96- }
98+ ApplyEnumMember < RobotDtoHostingType20183 > ( Type , hostingType => robot . HostingType = hostingType ) ;
99+ ApplyEnumMember < RobotDtoType20183 > ( Type , type => robot . Type = type ) ;
97100
98101 var dto = HandleHttpOperationException ( ( ) => Api_18_3 . Robots . Post ( robot ) ) ;
99102 WriteObject ( Robot . FromDto ( dto ) ) ;
100103 }
104+
105+ private void AddRobot20184 ( )
106+ {
107+ var robot = new RobotDto20184
108+ {
109+ Name = Name ,
110+ MachineName = MachineName ,
111+ LicenseKey = LicenseKey ,
112+ Username = Username ,
113+ Password = Password ,
114+ Description = Description ,
115+ } ;
116+
117+ ApplyEnumMember < Web . Client20184 . Models . RobotDtoCredentialType > ( CredentialType , credentialType => robot . CredentialType = credentialType ) ;
118+ ApplyEnumMember < Web . Client20184 . Models . RobotDtoHostingType > ( HostingType , hostingType => robot . HostingType = hostingType ) ;
119+ ApplyEnumMember < RobotDtoType20184 > ( Type , type => robot . Type = type ) ;
120+
121+ var dto = HandleHttpOperationException ( ( ) => Api_18_4 . Robots . Post ( robot ) ) ;
122+ WriteObject ( Robot . FromDto ( dto ) ) ;
123+ }
101124 }
102125}
0 commit comments