Skip to content

Commit 1854410

Browse files
committed
Fix all string parameters to be CamelCased and avoid abbreviation
Updated all parameter sets to use `CamelCased` inputs, and adjusted their usage internally to still conform to the API requirements. Made minor documentation changes related to these udpates. Resolves microsoft#65: Fix all string parameters to be CamelCased and avoid abbreviation
1 parent 13bbf17 commit 1854410

16 files changed

+184
-146
lines changed

GitHubAnalytics.ps1

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function Group-GitHubIssue
3131
$issues = @()
3232
$issues += Get-GitHubIssue -Uri 'https://github.com/powershell/xpsdesiredstateconfiguration'
3333
$issues += Get-GitHubIssue -Uri 'https://github.com/powershell/xactivedirectory'
34-
$issues | Group-GitHubIssue -Weeks 12 -DateType closed
34+
$issues | Group-GitHubIssue -Weeks 12 -DateType Closed
3535
#>
3636
[CmdletBinding(
3737
SupportsShouldProcess,
@@ -51,8 +51,8 @@ function Group-GitHubIssue
5151
[int] $Weeks,
5252

5353
[Parameter(ParameterSetName='Weekly')]
54-
[ValidateSet('created', 'closed')]
55-
[string] $DateType = 'created'
54+
[ValidateSet('Created', 'Closed')]
55+
[string] $DateType = 'Created'
5656
)
5757

5858
Write-InvocationLog
@@ -66,8 +66,8 @@ function Group-GitHubIssue
6666
foreach ($week in $weekDates)
6767
{
6868
$filteredIssues = @($Issue | Where-Object {
69-
(($DateType -eq 'created') -and ($_.created_at -ge $week) -and ($_.created_at -le $endOfWeek)) -or
70-
(($DateType -eq 'closed') -and ($_.closed_at -ge $week) -and ($_.closed_at -le $endOfWeek))
69+
(($DateType -eq 'Created') -and ($_.created_at -ge $week) -and ($_.created_at -le $endOfWeek)) -or
70+
(($DateType -eq 'Closed') -and ($_.closed_at -ge $week) -and ($_.closed_at -le $endOfWeek))
7171
})
7272

7373
$endOfWeek = $week
@@ -124,7 +124,7 @@ function Group-GitHubPullRequest
124124
$pullRequests = @()
125125
$pullRequests += Get-GitHubPullRequest -Uri 'https://github.com/powershell/xpsdesiredstateconfiguration'
126126
$pullRequests += Get-GitHubPullRequest -Uri 'https://github.com/powershell/xactivedirectory'
127-
$pullRequests | Group-GitHubPullRequest -Weeks 12 -DateType closed
127+
$pullRequests | Group-GitHubPullRequest -Weeks 12 -DateType Closed
128128
#>
129129
[CmdletBinding(
130130
SupportsShouldProcess,
@@ -144,8 +144,8 @@ function Group-GitHubPullRequest
144144
[int] $Weeks,
145145

146146
[Parameter(ParameterSetName='Weekly')]
147-
[ValidateSet('created', 'merged')]
148-
[string] $DateType = 'created'
147+
[ValidateSet('Created', 'Merged')]
148+
[string] $DateType = 'Created'
149149
)
150150

151151
Write-InvocationLog
@@ -159,8 +159,8 @@ function Group-GitHubPullRequest
159159
foreach ($week in $weekDates)
160160
{
161161
$filteredPullRequests = @($PullRequest | Where-Object {
162-
(($DateType -eq 'created') -and ($_.created_at -ge $week) -and ($_.created_at -le $endOfWeek)) -or
163-
(($DateType -eq 'merged') -and ($_.merged_at -ge $week) -and ($_.merged_at -le $endOfWeek))
162+
(($DateType -eq 'Created') -and ($_.created_at -ge $week) -and ($_.created_at -le $endOfWeek)) -or
163+
(($DateType -eq 'Merged') -and ($_.merged_at -ge $week) -and ($_.merged_at -le $endOfWeek))
164164
})
165165

166166
$endOfWeek = $week

GitHubComments.ps1

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,16 @@ function Get-GitHubComment
9696

9797
[Parameter(ParameterSetName='RepositoryUri')]
9898
[Parameter(ParameterSetName='RepositoryElements')]
99-
[ValidateSet('created', 'updated')]
99+
[ValidateSet('Created', 'Updated')]
100100
[string] $Sort,
101101

102102
[Parameter(ParameterSetName='RepositoryUri')]
103103
[Parameter(ParameterSetName='RepositoryElements')]
104-
[ValidateSet('asc', 'desc')]
104+
[ValidateSet('Ascending', 'Descending')]
105105
[string] $Direction,
106106

107-
[ValidateSet('raw', 'text', 'html', 'full')]
108-
[string] $MediaType ='raw',
107+
[ValidateSet('Raw', 'Text', 'Html', 'Full')]
108+
[string] $MediaType ='Raw',
109109

110110
[string] $AccessToken,
111111

@@ -120,9 +120,10 @@ function Get-GitHubComment
120120
$uriFragment = [String]::Empty
121121
$description = [String]::Empty
122122

123+
$sinceFormattedTime = [String]::Empty
123124
if ($null -ne $Since)
124125
{
125-
$SinceFormattedTime = $Since.ToUniversalTime().ToString('o')
126+
$sinceFormattedTime = $Since.ToUniversalTime().ToString('o')
126127
}
127128

128129
$telemetryProperties = @{
@@ -143,7 +144,7 @@ function Get-GitHubComment
143144

144145
if ($PSBoundParameters.ContainsKey('Since'))
145146
{
146-
$uriFragment += "since=$SinceFormattedTime"
147+
$uriFragment += "since=$sinceFormattedTime"
147148
}
148149

149150
$description = "Getting comments for issue $Issue in $RepositoryName"
@@ -154,17 +155,22 @@ function Get-GitHubComment
154155

155156
if ($PSBoundParameters.ContainsKey('Sort'))
156157
{
157-
$getParams += "sort=$Sort"
158+
$getParams += "sort=$($Sort.ToLower())"
158159
}
159160

160161
if ($PSBoundParameters.ContainsKey('Direction'))
161162
{
162-
$getParams += "direction=$Direction"
163+
$directionConverter = @{
164+
'Ascending' = 'asc'
165+
'Descending' = 'desc'
166+
}
167+
168+
$getParams += "direction=$($directionConverter[$Direction])"
163169
}
164170

165171
if ($PSBoundParameters.ContainsKey('Since'))
166172
{
167-
$getParams += "since=$SinceFormattedTime"
173+
$getParams += "since=$sinceFormattedTime"
168174
}
169175

170176
$uriFragment = "repos/$OwnerName/$RepositoryName/issues/comments`?" + ($getParams -join '&')
@@ -256,8 +262,8 @@ function New-GitHubComment
256262
[Parameter(Mandatory)]
257263
[string] $Body,
258264

259-
[ValidateSet('raw', 'text', 'html', 'full')]
260-
[string] $MediaType ='raw',
265+
[ValidateSet('Raw', 'Text', 'Html', 'Full')]
266+
[string] $MediaType ='Raw',
261267

262268
[string] $AccessToken,
263269

@@ -367,8 +373,8 @@ function Set-GitHubComment
367373
[Parameter(Mandatory)]
368374
[string] $Body,
369375

370-
[ValidateSet('raw', 'text', 'html', 'full')]
371-
[string] $MediaType ='raw',
376+
[ValidateSet('Raw', 'Text', 'Html', 'Full')]
377+
[string] $MediaType ='Raw',
372378

373379
[string] $AccessToken,
374380

@@ -512,19 +518,19 @@ function Get-CommentAcceptHeader
512518
full - Return raw, text and HTML representations. Response will include body, body_text, and body_html.
513519
514520
.EXAMPLE
515-
Get-CommentAcceptHeader -MediaType raw
521+
Get-CommentAcceptHeader -MediaType Raw
516522
517523
Returns a formatted AcceptHeader for v3 of the response object
518524
#>
519525
[CmdletBinding()]
520526
param(
521-
[ValidateSet('raw', 'text', 'html', 'full')]
522-
[string] $MediaType ='raw'
527+
[ValidateSet('Raw', 'Text', 'Html', 'Full')]
528+
[string] $MediaType ='Raw'
523529
)
524530

525531
$acceptHeaders = @(
526532
'application/vnd.github.squirrel-girl-preview',
527-
"application/vnd.github.$mediaTypeVersion.$MediaType+json")
533+
"application/vnd.github.$mediaTypeVersion.$($MediaType.ToLower())+json")
528534

529535
return ($acceptHeaders -join ',')
530536
}

GitHubCore.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
Set-Variable -Scope Script -Option ReadOnly -Name $_.Key -Value $_.Value
1313
}
1414

15-
Set-Variable -Scope Script -Option ReadOnly -Name ValidBodyContainingRequestMethods -Value ('post', 'patch', 'put', 'delete')
15+
Set-Variable -Scope Script -Option ReadOnly -Name ValidBodyContainingRequestMethods -Value ('Post', 'Patch', 'Put', 'Delete')
1616

1717
function Invoke-GHRestMethod
1818
{
@@ -102,7 +102,7 @@ function Invoke-GHRestMethod
102102
[string] $UriFragment,
103103

104104
[Parameter(Mandatory)]
105-
[ValidateSet('delete', 'get', 'post', 'patch', 'put')]
105+
[ValidateSet('Delete', 'Get', 'Post', 'Patch', 'Put')]
106106
[string] $Method,
107107

108108
[string] $Description,
@@ -208,7 +208,7 @@ function Invoke-GHRestMethod
208208

209209
[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12
210210
$result = Invoke-WebRequest @params
211-
if ($Method -eq 'delete')
211+
if ($Method -eq 'Delete')
212212
{
213213
Write-Log -Message "Successfully removed." -Level Verbose
214214
}
@@ -306,7 +306,7 @@ function Invoke-GHRestMethod
306306
throw $remoteErrors[0].Exception
307307
}
308308

309-
if ($Method -eq 'delete')
309+
if ($Method -eq 'Delete')
310310
{
311311
Write-Log -Message "Successfully removed." -Level Verbose
312312
}

GitHubIssues.ps1

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,12 @@ function Get-GitHubIssue
9898
If not supplied here, the DefaultNoStatus configuration property value will be used.
9999
100100
.EXAMPLE
101-
Get-GitHubIssue -OwnerName PowerShell -RepositoryName PowerShellForGitHub -State open
101+
Get-GitHubIssue -OwnerName PowerShell -RepositoryName PowerShellForGitHub -State Open
102102
103103
Gets all the currently open issues in the PowerShell\PowerShellForGitHub repository.
104104
105105
.EXAMPLE
106-
Get-GitHubIssue -OwnerName PowerShell -RepositoryName PowerShellForGitHub -State all -Assignee Octocat
106+
Get-GitHubIssue -OwnerName PowerShell -RepositoryName PowerShellForGitHub -State All -Assignee Octocat
107107
108108
Gets every issue in the PowerShell\PowerShellForGitHub repository that is assigned to Octocat.
109109
#>
@@ -125,35 +125,35 @@ function Get-GitHubIssue
125125

126126
[string] $OrganizationName,
127127

128-
[ValidateSet('all', 'ownedAndMember')]
129-
[string] $RepositoryType = 'all',
128+
[ValidateSet('All', 'OwnedAndMember')]
129+
[string] $RepositoryType = 'All',
130130

131131
[int] $Issue,
132132

133133
[switch] $IgnorePullRequests,
134134

135-
[ValidateSet('assigned', 'created', 'mentioned', 'subscribed', 'all')]
136-
[string] $Filter = 'assigned',
135+
[ValidateSet('Assigned', 'Created', 'Mentioned', 'Subscribed', 'All')]
136+
[string] $Filter = 'Assigned',
137137

138-
[ValidateSet('open', 'closed', 'all')]
139-
[string] $State = 'open',
138+
[ValidateSet('Open', 'Closed', 'All')]
139+
[string] $State = 'Open',
140140

141141
[string[]] $Label,
142142

143-
[ValidateSet('created', 'updated', 'comments')]
144-
[string] $Sort = 'created',
143+
[ValidateSet('Created', 'Updated', 'Comments')]
144+
[string] $Sort = 'Created',
145145

146-
[ValidateSet('asc', 'desc')]
147-
[string] $Direction = 'desc',
146+
[ValidateSet('Ascending', 'Descending')]
147+
[string] $Direction = 'Descending',
148148

149149
[DateTime] $Since,
150150

151-
[ValidateSet('specific', 'all', 'none')]
151+
[ValidateSet('Specific', 'All', 'None')]
152152
[string] $MilestoneType,
153153

154154
[string] $Milestone,
155155

156-
[ValidateSet('specific', 'all', 'none')]
156+
[ValidateSet('Specific', 'All', 'None')]
157157
[string] $AssigneeType,
158158

159159
[string] $Assignee,
@@ -203,12 +203,12 @@ function Get-GitHubIssue
203203
$uriFragment = "/orgs/$OrganizationName/issues"
204204
$description = "Getting issues for $OrganizationName"
205205
}
206-
elseif ($RepositoryType -eq 'all')
206+
elseif ($RepositoryType -eq 'All')
207207
{
208208
$uriFragment = "/issues"
209209
$description = "Getting issues across owned, member and org repositories"
210210
}
211-
elseif ($RepositoryType -eq 'ownedAndMember')
211+
elseif ($RepositoryType -eq 'OwnedAndMember')
212212
{
213213
$uriFragment = "/user/issues"
214214
$description = "Getting issues across owned and member repositories"
@@ -218,11 +218,16 @@ function Get-GitHubIssue
218218
throw "Parameter set not supported."
219219
}
220220

221+
$directionConverter = @{
222+
'Ascending' = 'asc'
223+
'Descending' = 'desc'
224+
}
225+
221226
$getParams = @(
222-
"filter=$Filter",
223-
"state=$State",
224-
"sort=$Sort",
225-
"direction=$Direction"
227+
"filter=$($Filter.ToLower())",
228+
"state=$($State.ToLower())",
229+
"sort=$($Sort.ToLower())",
230+
"direction=$($directionConverter[$Direction])"
226231
)
227232

228233
if ($PSBoundParameters.ContainsKey('Label'))
@@ -242,11 +247,11 @@ function Get-GitHubIssue
242247

243248
if ($PSBoundParameters.ContainsKey('MilestoneType'))
244249
{
245-
if ($MilestoneType -eq 'all')
250+
if ($MilestoneType -eq 'All')
246251
{
247252
$getParams += 'mentioned=*'
248253
}
249-
elseif ($MilestoneType -eq 'none')
254+
elseif ($MilestoneType -eq 'None')
250255
{
251256
$getParams += 'mentioned=none'
252257
}
@@ -585,7 +590,7 @@ function Update-GitHubIssue
585590
If not supplied here, the DefaultNoStatus configuration property value will be used.
586591
587592
.EXAMPLE
588-
Update-GitHubIssue -OwnerName PowerShell -RepositoryName PowerShellForGitHub -Issue 4 -Title 'Test Issue' -State closed
593+
Update-GitHubIssue -OwnerName PowerShell -RepositoryName PowerShellForGitHub -Issue 4 -Title 'Test Issue' -State Closed
589594
#>
590595
[CmdletBinding(
591596
SupportsShouldProcess,
@@ -616,7 +621,7 @@ function Update-GitHubIssue
616621

617622
[string[]] $Label,
618623

619-
[ValidateSet('open', 'closed')]
624+
[ValidateSet('Open', 'Closed')]
620625
[string] $State,
621626

622627
[string] $AccessToken,
@@ -641,7 +646,7 @@ function Update-GitHubIssue
641646
if ($PSBoundParameters.ContainsKey('Body')) { $hashBody['body'] = $Body }
642647
if ($PSBoundParameters.ContainsKey('Assignee')) { $hashBody['assignees'] = @($Assignee) }
643648
if ($PSBoundParameters.ContainsKey('Label')) { $hashBody['labels'] = @($Label) }
644-
if ($PSBoundParameters.ContainsKey('State')) { $hashBody['state'] = $State }
649+
if ($PSBoundParameters.ContainsKey('State')) { $hashBody['state'] = $State.ToLower() }
645650
if ($PSBoundParameters.ContainsKey('Milestone'))
646651
{
647652
$hashBody['milestone'] = $Milestone
@@ -707,7 +712,7 @@ function Lock-GitHubIssue
707712
If not supplied here, the DefaultNoStatus configuration property value will be used.
708713
709714
.EXAMPLE
710-
Lock-GitHubIssue -OwnerName PowerShell -RepositoryName PowerShellForGitHub -Issue 4 -Title 'Test Issue' -Reason spam
715+
Lock-GitHubIssue -OwnerName PowerShell -RepositoryName PowerShellForGitHub -Issue 4 -Title 'Test Issue' -Reason Spam
711716
#>
712717
[CmdletBinding(
713718
SupportsShouldProcess,
@@ -728,7 +733,7 @@ function Lock-GitHubIssue
728733
[Parameter(Mandatory)]
729734
[int] $Issue,
730735

731-
[ValidateSet('off-topic', 'too heated', 'resolved', 'spam')]
736+
[ValidateSet('OffTopic', 'TooHeated', 'Resolved', 'Spam')]
732737
[string] $Reason,
733738

734739
[string] $AccessToken,
@@ -753,8 +758,15 @@ function Lock-GitHubIssue
753758

754759
if ($PSBoundParameters.ContainsKey('Reason'))
755760
{
761+
$reasonConverter = @{
762+
'OffTopic' = 'off-topic'
763+
'TooHeated' = 'too heated'
764+
'Resolved' = 'resolved'
765+
'Spam' = 'spam'
766+
}
767+
756768
$telemetryProperties['Reason'] = $Reason
757-
$hashBody['active_lock_reason'] = $Reason
769+
$hashBody['active_lock_reason'] = $reasonConverter[$Reason]
758770
}
759771

760772
$params = @{

0 commit comments

Comments
 (0)