Skip to content

Commit

Permalink
Add new cmdlets for PATs
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-peterson committed Aug 14, 2024
1 parent 232be28 commit c65656c
Show file tree
Hide file tree
Showing 11 changed files with 466 additions and 82 deletions.
16 changes: 5 additions & 11 deletions src/GitlabCli/AuditEvents.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ function Get-GitlabAuditEvent {
[Parameter()]
$FetchAuthors,

[Parameter()]
[uint]
$MaxPages,

[switch]
[Parameter()]
$All,
Expand All @@ -44,22 +48,11 @@ function Get-GitlabAuditEvent {
[string]
$After,

[Parameter()]
[uint]
$MaxPages = $global:GitlabGetProjectDefaultPages,

[Parameter()]
[string]
$SiteUrl
)

if ($All) {
if ($MaxPages -ne $global:GitlabGetProjectDefaultPages) {
Write-Warning -Message "Ignoring -MaxPages in favor of -All"
}
$MaxPages = [uint]::MaxValue
}

if ($GroupId) {
$Group = Get-GitlabGroup $GroupId
$Resource = "groups/$($Group.Id)/audit_events"
Expand Down Expand Up @@ -89,6 +82,7 @@ function Get-GitlabAuditEvent {
if ($After) {
$Query.created_after = $After
}
$MaxPages = Get-GitlabMaxPages -MaxPages:$MaxPages -All:$All

$Results = Invoke-GitlabApi GET $Resource -Query $Query -MaxPages $MaxPages -SiteUrl $SiteUrl | New-WrapperObject 'Gitlab.AuditEvent'

Expand Down
78 changes: 78 additions & 0 deletions src/GitlabCli/Formats.ps1xml
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,84 @@
</TableRowEntries>
</TableControl>
</View>
<View>
<Name>GitlabPersonalAccessToken</Name>
<ViewSelectedBy>
<TypeName>Gitlab.PersonalAccessToken</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
<TableColumnHeader/>
<TableColumnHeader/>
<TableColumnHeader/>
<TableColumnHeader>
<Label>LastUsedAt</Label>
</TableColumnHeader>
<TableColumnHeader>
<Label>ExpiresAt</Label>
</TableColumnHeader>
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
<TableColumnItems>
<TableColumnItem>
<PropertyName>Id</PropertyName>
<Alignment>Right</Alignment>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Name</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Scope</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>LastUsedAtSortable</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>ExpiresAtSortable</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>
<View>
<Name>GitlabNewPersonalAccessToken</Name>
<ViewSelectedBy>
<TypeName>Gitlab.NewPersonalAccessToken</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
<TableColumnHeader/>
<TableColumnHeader/>
<TableColumnHeader/>
<TableColumnHeader/>
<TableColumnHeader/>
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
<TableColumnItems>
<TableColumnItem>
<PropertyName>Id</PropertyName>
<Alignment>Right</Alignment>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Name</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Scope</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>ExpiresAt</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Token</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>
<View>
<Name>GitlabPipeline</Name>
<ViewSelectedBy>
Expand Down
15 changes: 12 additions & 3 deletions src/GitlabCli/GitlabCli.psd1
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
@{
ModuleVersion = '1.112.0'
ModuleVersion = '1.113.0'

PrivateData = @{
PSData = @{
LicenseUri = 'https://github.com/chris-peterson/pwsh-gitlab/blob/main/LICENSE'
ProjectUri = 'https://github.com/chris-peterson/pwsh-gitlab'
ReleaseNotes =
@'
new cmdlet: Add-GitlabGroupToProject
cmdlets for PATs
'@
}
}
Expand Down Expand Up @@ -42,6 +42,7 @@ new cmdlet: Add-GitlabGroupToProject
'Members.psm1'
'MergeRequests.psm1'
'Notes.psm1'
'PersonalAccessTokens.psm1'
'Pipelines.psm1'
'Projects.psm1'
'ProjectHooks.psm1'
Expand Down Expand Up @@ -166,7 +167,13 @@ new cmdlet: Add-GitlabGroupToProject
'Get-GitlabMergeRequestApprovalRule'
'New-GitlabMergeRequestApprovalRule'
'Remove-GitlabMergeRequestApprovalRule'


# PATs
'Get-GitlabPersonalAccessToken'
'New-GitlabPersonalAccessToken'
'Invoke-GitlabPersonalAccessTokenRotation'
'Revoke-GitlabPersonalAccessToken'

# Pipelines
'Get-GitlabPipeline'
'Get-GitlabPipelineVariable'
Expand Down Expand Up @@ -255,6 +262,7 @@ new cmdlet: Add-GitlabGroupToProject
'ConvertTo-UrlEncoded'
'ConvertTo-GitlabVariables'
'Get-FilteredObject'
'Get-GitlabMaxPages'
'Get-GitlabVersion'
'Invoke-GitlabApi'
'New-WrapperObject'
Expand All @@ -273,6 +281,7 @@ new cmdlet: Add-GitlabGroupToProject
'Play-GitlabJob'
'Pull-GitlabGroup'
'Remove-GitlabProtectedBranch'
'Rotate-GitlabPersonalAccessToken'
'Review-GitlabMergeRequest'
'Revoke-GitlabGroupAccessToken'
'Share-GitlabProjectWithGroup'
Expand Down
Loading

0 comments on commit c65656c

Please sign in to comment.