Skip to content

Commit

Permalink
Merge pull request #189 from shristi-dev/exclude_page_body
Browse files Browse the repository at this point in the history
Exclude page body from Get-Page and Get-ChildPage calls
  • Loading branch information
lipkau authored Mar 9, 2021
2 parents 2aa759a + 9fccca2 commit ef5b426
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 9 deletions.
8 changes: 7 additions & 1 deletion ConfluencePS/Public/Get-ChildPage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ function Get-ChildPage {
[switch]$Recurse,

[ValidateRange(1, [int]::MaxValue)]
[int]$PageSize = 25
[int]$PageSize = 25,

[switch]$ExcludePageBody
)

BEGIN {
Expand Down Expand Up @@ -59,6 +61,10 @@ function Get-ChildPage {
expand = "space,version,body.storage,ancestors"
limit = $PageSize
}
if($ExcludePageBody){
$iwParameters.GetParameters.expand = "space,version,ancestors"
}

$iwParameters['OutputType'] = [ConfluencePS.Page]

# Paging
Expand Down
9 changes: 8 additions & 1 deletion ConfluencePS/Public/Get-Page.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ function Get-Page {
[string]$Query,

[ValidateRange(1, [int]::MaxValue)]
[int]$PageSize = 25
[int]$PageSize = 25,

[switch]$ExcludePageBody
)

BEGIN {
Expand All @@ -87,6 +89,11 @@ function Get-Page {
expand = "space,version,body.storage,ancestors"
limit = $PageSize
}

if($ExcludePageBody){
$iwParameters.GetParameters.expand = "space,version,ancestors"
}

$iwParameters['OutputType'] = [ConfluencePS.Page]
}

Expand Down
7 changes: 7 additions & 0 deletions Tests/Integration.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ Describe 'Integration Tests' -Tag Integration {
{ Get-ConfluenceSpace -Key $Key1 -ErrorAction Stop } | Should Throw

# ACT
Get-ConfluenceSpace|Where-Object {
$_.Name -in @($Name1,$Name2)
}| ForEach-Object {
Write-Warning "Removing space: $($_.Name) $($_.key)"
Remove-ConfluenceSpace $_.Key -Force -ErrorAction Stop
}

$NewSpace1 = $Space1 | New-ConfluenceSpace -ErrorAction Stop
$NewSpace2 = New-ConfluenceSpace -Key $Key2 -Name $Name2 -Description $Description -ErrorAction Stop

Expand Down
21 changes: 19 additions & 2 deletions docs/en-US/commands/Get-ChildPage.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ Retrieve the child pages of a given wiki page or pages.
## SYNTAX

```powershell
Get-ConfluenceChildPage -ApiUri <Uri> -Credential <PSCredential> [-PageID] <Int32> [-Recurse] [-PageSize <Int32>] [-IncludeTotalCount] [-Skip <UInt64>] [-First <UInt64>]
Get-ConfluenceChildPage -ApiUri <Uri> -Credential <PSCredential> [-PageID] <Int32> [-Recurse] [-PageSize <Int32>] [-IncludeTotalCount] [-Skip <UInt64>] [-First <UInt64>] [-ExcludePageBody]
```

## DESCRIPTION

Return all pages directly below the given page(s).

Optionally, the -Recurse parameter will return all child pages, no matter how nested.
Optionally, the -Recurse parameter will return all child pages, no matter how nested.
Pass the optional parameter -ExcludePageBody to avoid fetching the pages' HTML content.

## EXAMPLES

Expand Down Expand Up @@ -206,6 +207,22 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -ExcludePageBody
Avoids fetching pages' body
```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```
## INPUTS
## OUTPUTS
Expand Down
35 changes: 30 additions & 5 deletions docs/en-US/commands/Get-Page.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,37 @@ Retrieve a listing of pages in your Confluence instance.
### byId (Default)

```powershell
Get-ConfluencePage -ApiUri <Uri> -Credential <PSCredential> [-PageID] <Int32[]> [-PageSize <Int32>] [-IncludeTotalCount] [-Skip <UInt64>] [-First <UInt64>]
Get-ConfluencePage -ApiUri <Uri> -Credential <PSCredential> [-PageID] <Int32[]> [-PageSize <Int32>] [-IncludeTotalCount] [-Skip <UInt64>] [-First <UInt64>] [-ExcludePageBody]
```

### byLabel

```powershell
Get-ConfluencePage -ApiUri <Uri> -Credential <PSCredential> [-SpaceKey <String>] [-Space <Space>] -Label <String[]> [-PageSize <Int32>] [-IncludeTotalCount] [-Skip <UInt64>] [-First <UInt64>]
Get-ConfluencePage -ApiUri <Uri> -Credential <PSCredential> [-SpaceKey <String>] [-Space <Space>] -Label <String[]> [-PageSize <Int32>] [-IncludeTotalCount] [-Skip <UInt64>] [-First <UInt64>] [-ExcludePageBody]
```

### bySpace

```powershell
Get-ConfluencePage -ApiUri <Uri> -Credential <PSCredential> -SpaceKey <String> [-Title <String>] [-PageSize <Int32>] [-IncludeTotalCount] [-Skip <UInt64>] [-First <UInt64>]
Get-ConfluencePage -ApiUri <Uri> -Credential <PSCredential> -SpaceKey <String> [-Title <String>] [-PageSize <Int32>] [-IncludeTotalCount] [-Skip <UInt64>] [-First <UInt64>] [-ExcludePageBody]
```

### byQuery

```powershell
Get-ConfluencePage -ApiUri <Uri> -Credential <PSCredential> [-Query <String>] [-PageSize <Int32>] [-IncludeTotalCount] [-Skip <UInt64>] [-First <UInt64>]
Get-ConfluencePage -ApiUri <Uri> -Credential <PSCredential> [-Query <String>] [-PageSize <Int32>] [-IncludeTotalCount] [-Skip <UInt64>] [-First <UInt64>] [-ExcludePageBody]
```

### bySpaceObject

```powershell
Get-ConfluencePage -ApiUri <Uri> -Credential <PSCredential> -Space <Space> [-Title <String>] [-PageSize <Int32>] [-IncludeTotalCount] [-Skip <UInt64>] [-First <UInt64>]
Get-ConfluencePage -ApiUri <Uri> -Credential <PSCredential> -Space <Space> [-Title <String>] [-PageSize <Int32>] [-IncludeTotalCount] [-Skip <UInt64>] [-First <UInt64>] [-ExcludePageBody]
```

## DESCRIPTION

Return Confluence pages, filtered by ID, Name, or Space.
Pass the optional parameter -ExcludePageBody to avoid fetching the pages' HTML content.

## EXAMPLES

Expand Down Expand Up @@ -96,6 +97,14 @@ Get-ConfluencePage -Query "mention = jSmith and creator != jSmith"

Return all pages matching the query.

### -------------------------- EXAMPLE 5 --------------------------

```powershell
Get-ConfluencePage -Label 'skywalker' -ExcludePageBody
```

Return all pages containing the label "skywalker" (case-insensitive) without their page content.

## PARAMETERS

### -ApiUri
Expand Down Expand Up @@ -352,6 +361,22 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -ExcludePageBody

Avoids fetching pages' body

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```

## INPUTS

## OUTPUTS
Expand Down

0 comments on commit ef5b426

Please sign in to comment.