@@ -28,67 +28,61 @@ namespace Microsoft.WindowsAzure.Commands.StorSimple.Cmdlets
2828 /// <summary>
2929 /// Stop the specified device job if its in progress and is cancellable.
3030 /// </summary>
31- [ Cmdlet ( VerbsCommon . Get , "AzureStorSimpleJob" , DefaultParameterSetName = StorSimpleCmdletParameterSet . IdentifyByDeviceName ) ,
32- OutputType ( typeof ( IList < DeviceJobDetails > ) , typeof ( DeviceJobDetails ) ) ]
31+ [ Cmdlet ( VerbsCommon . Get , "AzureStorSimpleJob" ) , OutputType ( typeof ( IList < DeviceJobDetails > ) , typeof ( DeviceJobDetails ) ) ]
3332 public class GetAzureStorSimpleJob : StorSimpleCmdletBase
3433 {
3534 #region params
3635 /// <summary>
3736 /// Name of StorSimple device for which to fetch jobs
3837 /// </summary>
39- [ Parameter ( Mandatory = true , Position = 0 , ParameterSetName = StorSimpleCmdletParameterSet . IdentifyByDeviceName ,
40- HelpMessage = StorSimpleCmdletHelpMessage . DeviceName ) ]
38+ [ Parameter ( Mandatory = false , Position = 0 , HelpMessage = StorSimpleCmdletHelpMessage . DeviceName ) ]
4139 [ ValidateNotNullOrEmpty ]
4240 public string DeviceName { get ; set ; }
4341
44-
4542 /// <summary>
4643 /// InstanceId/JobId of the job to retrieve
4744 /// </summary>
48- [ Parameter ( Mandatory = true , Position = 0 , ParameterSetName = StorSimpleCmdletParameterSet . IdentifyById ,
49- HelpMessage = StorSimpleCmdletHelpMessage . DeviceJobId ) ]
45+ [ Parameter ( Mandatory = false , Position = 1 , HelpMessage = StorSimpleCmdletHelpMessage . DeviceJobId ) ]
5046 [ ValidateNotNullOrEmpty ]
5147 public string InstanceId { get ; set ; }
5248
5349 /// <summary>
5450 /// Filter jobs by their status.
5551 /// </summary>
56- [ Parameter ( Mandatory = true , Position = 0 , ParameterSetName = StorSimpleCmdletParameterSet . IdentifyByStatus ,
57- HelpMessage = StorSimpleCmdletHelpMessage . DeviceJobStatus ) ]
52+ [ Parameter ( Mandatory = false , Position = 2 , HelpMessage = StorSimpleCmdletHelpMessage . DeviceJobStatus ) ]
5853 [ ValidateSetAttribute ( new string [ ] { "Running" , "Completed" , "Cancelled" , "Failed" , "Cancelling" , "CompletedWithErrors" } ) ]
5954 public string Status { get ; set ; }
6055
6156 /// <summary>
6257 /// Filter jobs by their status.
6358 /// </summary>
64- [ Parameter ( Mandatory = true , Position = 0 , ParameterSetName = StorSimpleCmdletParameterSet . IdentifyByType ,
65- HelpMessage = StorSimpleCmdletHelpMessage . DeviceJobType ) ]
59+ [ Parameter ( Mandatory = false , Position = 3 , HelpMessage = StorSimpleCmdletHelpMessage . DeviceJobType ) ]
6660 [ ValidateSetAttribute ( new string [ ] { "Backup" , "ManualBackup" , "Restore" , "CloneWorkflow" , "DeviceRestore" , "Update" , "SupportPackage" , "VirtualApplianceProvisioning" } ) ]
6761 public string Type { get ; set ; }
6862
6963 /// <summary>
7064 /// Filter jobs that were created after specified time
7165 /// </summary>
72- [ Parameter ( Position = 1 , Mandatory = false , HelpMessage = StorSimpleCmdletHelpMessage . FromTime ) ]
66+ [ Parameter ( Mandatory = false , Position = 4 , HelpMessage = StorSimpleCmdletHelpMessage . FromTime ) ]
7367 public DateTime ? From { get ; set ; }
7468
7569 /// <summary>
7670 /// Filter jobs that were created till specified time
7771 /// </summary
78- [ Parameter ( Position = 2 , Mandatory = false , HelpMessage = StorSimpleCmdletHelpMessage . ToTime ) ]
72+ [ Parameter ( Mandatory = false , Position = 5 , HelpMessage = StorSimpleCmdletHelpMessage . ToTime ) ]
7973 public DateTime ? To { get ; set ; }
8074
8175 /// <summary>
8276 /// Number of results to skip
8377 /// </summary>
84- [ Parameter ( Position = 3 , Mandatory = false , HelpMessage = StorSimpleCmdletHelpMessage . SkipDesc ) ]
78+ [ Parameter ( Mandatory = false , Position = 6 , HelpMessage = StorSimpleCmdletHelpMessage . SkipDesc ) ]
8579 [ ValidateRange ( 0 , Int32 . MaxValue ) ]
8680 public int ? Skip { get ; set ; }
8781
8882 /// <summary>
8983 /// Number of results to include.
9084 /// </summary>
91- [ Parameter ( Position = 4 , Mandatory = false , HelpMessage = StorSimpleCmdletHelpMessage . FirstDesc ) ]
85+ [ Parameter ( Mandatory = false , Position = 7 , HelpMessage = StorSimpleCmdletHelpMessage . FirstDesc ) ]
9286 [ ValidateRange ( 0 , Int32 . MaxValue ) ]
9387 public int ? First { get ; set ; }
9488 #endregion params
@@ -108,41 +102,29 @@ public override void ExecuteCmdlet()
108102 // Make call to get device jobs.
109103 var response = StorSimpleClient . GetDeviceJobs ( deviceId , Type , Status , InstanceId , fromDateTimeIsoString , toDateTimeIsoString , ( int ) Skip , ( int ) First ) ;
110104
111- if ( ParameterSetName == StorSimpleCmdletParameterSet . IdentifyById )
105+ WriteObject ( response . DeviceJobList , true ) ;
106+ WriteVerbose ( string . Format ( Resources . DeviceJobsReturnedCount , response . DeviceJobList . Count ,
107+ response . DeviceJobList . Count > 1 ? "s" : string . Empty ) ) ;
108+ if ( response . NextPageUri != null
109+ && response . NextPageStartIdentifier != "-1" )
112110 {
113- if ( response == null || response . DeviceJobList . Count < 1 )
111+ if ( First != null )
114112 {
115- throw new ArgumentException ( string . Format ( Resources . NoDeviceJobFoundWithGivenIdMessage , InstanceId ) ) ;
116- }
117- WriteObject ( response . DeviceJobList . First ( ) ) ;
118- return ;
119- }
120- else
121- {
122- WriteObject ( response . DeviceJobList , true ) ;
123- WriteVerbose ( string . Format ( Resources . DeviceJobsReturnedCount , response . DeviceJobList . Count ,
124- response . DeviceJobList . Count > 1 ? "s" : string . Empty ) ) ;
125- if ( response . NextPageUri != null
126- && response . NextPageStartIdentifier != "-1" )
127- {
128- if ( First != null )
129- {
130- //user has provided First(Top) parameter while calling the commandlet
131- //so we need to provide it to him for calling the next page
132- WriteVerbose ( string . Format ( Resources . DeviceJobsNextPageFormatMessage , First , response . NextPageStartIdentifier ) ) ;
133- }
134- else
135- {
136- //user has NOT provided First(Top) parameter while calling the commandlet
137- //so we DONT need to provide it to him for calling the next page
138- WriteVerbose ( string . Format ( Resources . DeviceJobsNextPagewithNoFirstMessage , response . NextPageStartIdentifier ) ) ;
139- }
113+ //user has provided First(Top) parameter while calling the commandlet
114+ //so we need to provide it to him for calling the next page
115+ WriteVerbose ( string . Format ( Resources . DeviceJobsNextPageFormatMessage , First , response . NextPageStartIdentifier ) ) ;
140116 }
141117 else
142118 {
143- WriteVerbose ( Resources . DeviceJobsNoMorePagesMessage ) ;
119+ //user has NOT provided First(Top) parameter while calling the commandlet
120+ //so we DONT need to provide it to him for calling the next page
121+ WriteVerbose ( string . Format ( Resources . DeviceJobsNextPagewithNoFirstMessage , response . NextPageStartIdentifier ) ) ;
144122 }
145123 }
124+ else
125+ {
126+ WriteVerbose ( Resources . DeviceJobsNoMorePagesMessage ) ;
127+ }
146128 }
147129 catch ( Exception exception )
148130 {
@@ -164,7 +146,7 @@ private void ProcessParameters()
164146
165147 deviceId = null ;
166148
167- if ( ParameterSetName == StorSimpleCmdletParameterSet . IdentifyByDeviceName )
149+ if ( DeviceName != null )
168150 {
169151 deviceId = StorSimpleClient . GetDeviceId ( DeviceName ) ;
170152 if ( deviceId == null )
0 commit comments