@@ -207,6 +207,7 @@ function New-GitHubMilestone
207
207
208
208
[Parameter (ParameterSetName = ' Uri' )]
209
209
[Parameter (ParameterSetName = ' Elements' )]
210
+ [ValidateSet (' open' , ' closed' )]
210
211
[string ] $State ,
211
212
212
213
[Parameter (ParameterSetName = ' Uri' )]
@@ -215,7 +216,7 @@ function New-GitHubMilestone
215
216
216
217
[Parameter (ParameterSetName = ' Uri' )]
217
218
[Parameter (ParameterSetName = ' Elements' )]
218
- [string ] $Due_On ,
219
+ [DateTime ] $Due_On ,
219
220
220
221
[string ] $AccessToken ,
221
222
@@ -230,7 +231,7 @@ function New-GitHubMilestone
230
231
231
232
if ($null -ne $Due_On )
232
233
{
233
- $DueOnFormattedTime = $Since .ToUniversalTime ().ToString(' o' )
234
+ $DueOnFormattedTime = $Due_On .ToUniversalTime ().ToString(' o' )
234
235
}
235
236
236
237
$telemetryProperties = @ {
@@ -241,9 +242,21 @@ function New-GitHubMilestone
241
242
242
243
$hashBody = @ {
243
244
' title' = $Title
244
- ' state' = $State
245
- ' description' = $Description
246
- ' due_on' = $DueOnFormattedTime
245
+ }
246
+
247
+ if ($PSBoundParameters.ContainsKey (' State' ))
248
+ {
249
+ $hashBody += " state=$State "
250
+ }
251
+
252
+ if ($PSBoundParameters.ContainsKey (' Description' ))
253
+ {
254
+ $hashBody += " description=$Description "
255
+ }
256
+
257
+ if ($PSBoundParameters.ContainsKey (' Due_On' ))
258
+ {
259
+ $hashBody += " due_on=$DueOnFormattedTime "
247
260
}
248
261
249
262
$params = @ {
@@ -281,6 +294,9 @@ function Set-GitHubMilestone
281
294
The OwnerName and RepositoryName will be extracted from here instead of needing to provide
282
295
them individually.
283
296
297
+ . PARAMETER MilestoneNumber
298
+ The number of a specific milestone to get.
299
+
284
300
. PARAMETER Title
285
301
The title of the milestone.
286
302
@@ -304,7 +320,7 @@ function Set-GitHubMilestone
304
320
If not supplied here, the DefaultNoStatus configuration property value will be used.
305
321
306
322
. EXAMPLE
307
- Set-GitHubMilestone -OwnerName Powershell -RepositoryName PowerShellForGitHub -Title "Testing this API"
323
+ Set-GitHubMilestone -OwnerName Powershell -RepositoryName PowerShellForGitHub -MilestoneNumber 1 - Title "Testing this API"
308
324
309
325
Update an existing milestone for the PowerShell\PowerShellForGitHub project.
310
326
#>
@@ -322,12 +338,17 @@ function Set-GitHubMilestone
322
338
[Parameter (Mandatory , ParameterSetName = ' Uri' )]
323
339
[string ] $Uri ,
324
340
341
+ [Parameter (Mandatory , ParameterSetName = ' Uri' )]
342
+ [Parameter (Mandatory , ParameterSetName = ' Elements' )]
343
+ [string ] $MilestoneNumber ,
344
+
325
345
[Parameter (Mandatory , ParameterSetName = ' Uri' )]
326
346
[Parameter (Mandatory , ParameterSetName = ' Elements' )]
327
347
[string ] $Title ,
328
348
329
349
[Parameter (ParameterSetName = ' Uri' )]
330
350
[Parameter (ParameterSetName = ' Elements' )]
351
+ [ValidateSet (' open' , ' closed' )]
331
352
[string ] $State ,
332
353
333
354
[Parameter (ParameterSetName = ' Uri' )]
@@ -336,7 +357,7 @@ function Set-GitHubMilestone
336
357
337
358
[Parameter (ParameterSetName = ' Uri' )]
338
359
[Parameter (ParameterSetName = ' Elements' )]
339
- [string ] $Due_On ,
360
+ [DateTime ] $Due_On ,
340
361
341
362
[string ] $AccessToken ,
342
363
@@ -351,27 +372,40 @@ function Set-GitHubMilestone
351
372
352
373
if ($null -ne $Due_On )
353
374
{
354
- $DueOnFormattedTime = $Since .ToUniversalTime ().ToString(' o' )
375
+ $DueOnFormattedTime = $Due_On .ToUniversalTime ().ToString(' o' )
355
376
}
356
377
357
378
$telemetryProperties = @ {
358
379
' OwnerName' = (Get-PiiSafeString - PlainText $OwnerName )
359
380
' RepositoryName' = (Get-PiiSafeString - PlainText $RepositoryName )
360
381
' Title' = (Get-PiiSafeString - PlainText $Title )
382
+ ' MilestoneNumber' = (Get-PiiSafeString - PlainText $MilestoneNumber )
361
383
}
362
384
363
385
$hashBody = @ {
364
386
' title' = $Title
365
- ' state' = $State
366
- ' description' = $Description
367
- ' due_on' = $DueOnFormattedTime
387
+ }
388
+
389
+ if ($PSBoundParameters.ContainsKey (' State' ))
390
+ {
391
+ $hashBody += " state=$State "
392
+ }
393
+
394
+ if ($PSBoundParameters.ContainsKey (' Description' ))
395
+ {
396
+ $hashBody += " description=$Description "
397
+ }
398
+
399
+ if ($PSBoundParameters.ContainsKey (' Due_On' ))
400
+ {
401
+ $hashBody += " due_on=$DueOnFormattedTime "
368
402
}
369
403
370
404
$params = @ {
371
- ' UriFragment' = " repos/$OwnerName /$RepositoryName /milestones"
405
+ ' UriFragment' = " repos/$OwnerName /$RepositoryName /milestones/ $MilestoneNumber "
372
406
' Body' = (ConvertTo-Json - InputObject $hashBody )
373
407
' Method' = ' Patch'
374
- ' Description' = " Creating milestone for $RepositoryName "
408
+ ' Description' = " Setting milestone $MilestoneNumber for $RepositoryName "
375
409
' AccessToken' = $AccessToken
376
410
' TelemetryEventName' = $MyInvocation.MyCommand.Name
377
411
' TelemetryProperties' = $telemetryProperties
0 commit comments