@@ -28,67 +28,61 @@ namespace Microsoft.WindowsAzure.Commands.StorSimple.Cmdlets
28
28
/// <summary>
29
29
/// Stop the specified device job if its in progress and is cancellable.
30
30
/// </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 ) ) ]
33
32
public class GetAzureStorSimpleJob : StorSimpleCmdletBase
34
33
{
35
34
#region params
36
35
/// <summary>
37
36
/// Name of StorSimple device for which to fetch jobs
38
37
/// </summary>
39
- [ Parameter ( Mandatory = true , Position = 0 , ParameterSetName = StorSimpleCmdletParameterSet . IdentifyByDeviceName ,
40
- HelpMessage = StorSimpleCmdletHelpMessage . DeviceName ) ]
38
+ [ Parameter ( Mandatory = false , Position = 0 , HelpMessage = StorSimpleCmdletHelpMessage . DeviceName ) ]
41
39
[ ValidateNotNullOrEmpty ]
42
40
public string DeviceName { get ; set ; }
43
41
44
-
45
42
/// <summary>
46
43
/// InstanceId/JobId of the job to retrieve
47
44
/// </summary>
48
- [ Parameter ( Mandatory = true , Position = 0 , ParameterSetName = StorSimpleCmdletParameterSet . IdentifyById ,
49
- HelpMessage = StorSimpleCmdletHelpMessage . DeviceJobId ) ]
45
+ [ Parameter ( Mandatory = false , Position = 1 , HelpMessage = StorSimpleCmdletHelpMessage . DeviceJobId ) ]
50
46
[ ValidateNotNullOrEmpty ]
51
47
public string InstanceId { get ; set ; }
52
48
53
49
/// <summary>
54
50
/// Filter jobs by their status.
55
51
/// </summary>
56
- [ Parameter ( Mandatory = true , Position = 0 , ParameterSetName = StorSimpleCmdletParameterSet . IdentifyByStatus ,
57
- HelpMessage = StorSimpleCmdletHelpMessage . DeviceJobStatus ) ]
52
+ [ Parameter ( Mandatory = false , Position = 2 , HelpMessage = StorSimpleCmdletHelpMessage . DeviceJobStatus ) ]
58
53
[ ValidateSetAttribute ( new string [ ] { "Running" , "Completed" , "Cancelled" , "Failed" , "Cancelling" , "CompletedWithErrors" } ) ]
59
54
public string Status { get ; set ; }
60
55
61
56
/// <summary>
62
57
/// Filter jobs by their status.
63
58
/// </summary>
64
- [ Parameter ( Mandatory = true , Position = 0 , ParameterSetName = StorSimpleCmdletParameterSet . IdentifyByType ,
65
- HelpMessage = StorSimpleCmdletHelpMessage . DeviceJobType ) ]
59
+ [ Parameter ( Mandatory = false , Position = 3 , HelpMessage = StorSimpleCmdletHelpMessage . DeviceJobType ) ]
66
60
[ ValidateSetAttribute ( new string [ ] { "Backup" , "ManualBackup" , "Restore" , "CloneWorkflow" , "DeviceRestore" , "Update" , "SupportPackage" , "VirtualApplianceProvisioning" } ) ]
67
61
public string Type { get ; set ; }
68
62
69
63
/// <summary>
70
64
/// Filter jobs that were created after specified time
71
65
/// </summary>
72
- [ Parameter ( Position = 1 , Mandatory = false , HelpMessage = StorSimpleCmdletHelpMessage . FromTime ) ]
66
+ [ Parameter ( Mandatory = false , Position = 4 , HelpMessage = StorSimpleCmdletHelpMessage . FromTime ) ]
73
67
public DateTime ? From { get ; set ; }
74
68
75
69
/// <summary>
76
70
/// Filter jobs that were created till specified time
77
71
/// </summary
78
- [ Parameter ( Position = 2 , Mandatory = false , HelpMessage = StorSimpleCmdletHelpMessage . ToTime ) ]
72
+ [ Parameter ( Mandatory = false , Position = 5 , HelpMessage = StorSimpleCmdletHelpMessage . ToTime ) ]
79
73
public DateTime ? To { get ; set ; }
80
74
81
75
/// <summary>
82
76
/// Number of results to skip
83
77
/// </summary>
84
- [ Parameter ( Position = 3 , Mandatory = false , HelpMessage = StorSimpleCmdletHelpMessage . SkipDesc ) ]
78
+ [ Parameter ( Mandatory = false , Position = 6 , HelpMessage = StorSimpleCmdletHelpMessage . SkipDesc ) ]
85
79
[ ValidateRange ( 0 , Int32 . MaxValue ) ]
86
80
public int ? Skip { get ; set ; }
87
81
88
82
/// <summary>
89
83
/// Number of results to include.
90
84
/// </summary>
91
- [ Parameter ( Position = 4 , Mandatory = false , HelpMessage = StorSimpleCmdletHelpMessage . FirstDesc ) ]
85
+ [ Parameter ( Mandatory = false , Position = 7 , HelpMessage = StorSimpleCmdletHelpMessage . FirstDesc ) ]
92
86
[ ValidateRange ( 0 , Int32 . MaxValue ) ]
93
87
public int ? First { get ; set ; }
94
88
#endregion params
@@ -108,41 +102,29 @@ public override void ExecuteCmdlet()
108
102
// Make call to get device jobs.
109
103
var response = StorSimpleClient . GetDeviceJobs ( deviceId , Type , Status , InstanceId , fromDateTimeIsoString , toDateTimeIsoString , ( int ) Skip , ( int ) First ) ;
110
104
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" )
112
110
{
113
- if ( response == null || response . DeviceJobList . Count < 1 )
111
+ if ( First != null )
114
112
{
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 ) ) ;
140
116
}
141
117
else
142
118
{
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 ) ) ;
144
122
}
145
123
}
124
+ else
125
+ {
126
+ WriteVerbose ( Resources . DeviceJobsNoMorePagesMessage ) ;
127
+ }
146
128
}
147
129
catch ( Exception exception )
148
130
{
@@ -164,7 +146,7 @@ private void ProcessParameters()
164
146
165
147
deviceId = null ;
166
148
167
- if ( ParameterSetName == StorSimpleCmdletParameterSet . IdentifyByDeviceName )
149
+ if ( DeviceName != null )
168
150
{
169
151
deviceId = StorSimpleClient . GetDeviceId ( DeviceName ) ;
170
152
if ( deviceId == null )
0 commit comments