Skip to content
This repository has been archived by the owner on Oct 9, 2019. It is now read-only.

Commit

Permalink
Added new website functions: Get-WAPWebSitePublishingInfo, Remove-WAP…
Browse files Browse the repository at this point in the history
…WebSiteGitRepository, New-WAPWebSiteGitRepository, Get-WAPWebSiteGitRepository
  • Loading branch information
bgelens committed May 19, 2016
1 parent 85f00a2 commit 9494bf4
Show file tree
Hide file tree
Showing 3 changed files with 147 additions and 5 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ New-WAPWebSite -Name ben -Mode SharedFree -Verbose
Get-WAPWebSite
Get-WAPWebSite -Name ben | Get-WAPWebSitePublishingXML -OutFile C:\Users\gelensb.eu\Desktop\test.xml
Get-WAPWebSite -Name ben | Get-WAPWebSiteConfiguration
Get-WAPWebSite -Name ben | New-WAPWebSiteGitRepository
Get-WAPWebSite -Name ben | Get-WAPWebSiteGitRepository
Get-WAPWebSite -Name ben | Get-WAPWebSitePublishingInfo
Get-WAPWebSite -Name ben | Remove-WAPWebSiteGitRepository
Get-WAPWebSite -Name ben | Restart-WAPWebSite
Get-WAPWebSite -Name ben | Remove-WAPWebSite
Expand Down
10 changes: 7 additions & 3 deletions WapTenantPublicAPI.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'WapTenantPublicAPI'

# Version number of this module.
ModuleVersion = '0.0.6.0'
ModuleVersion = '0.0.6.1'

# ID used to uniquely identify this module
GUID = 'eaa28acf-4a1e-4d0e-96dd-fa36de33a658'
Expand Down Expand Up @@ -114,7 +114,11 @@ FunctionsToExport = @(
'Remove-WAPWebSite',
'Get-WAPWebSiteConfiguration',
'Get-WAPWebSitePublishingXML',
'Restart-WAPWebSite'
'Restart-WAPWebSite',
'New-WAPWebSiteGitRepository',
'Get-WAPWebSiteGitRepository',
'Remove-WAPWebSiteGitRepository',
'Get-WAPWebSitePublishingInfo'
)

# Cmdlets to export from this module
Expand Down Expand Up @@ -168,4 +172,4 @@ HelpInfoURI = 'https://github.com/bgelens/WAPTenantPublicAPI'
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''

}
}
138 changes: 136 additions & 2 deletions WapTenantPublicAPI.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -2334,8 +2334,7 @@ function Stop-WAPVM {
[OutputType([void])]
param (
[Parameter(Mandatory, ValueFromPipeline)]
[ValidateNotNull()]
[PSCustomObject] $VM,
[ValidateNotNull()][PSCustomObject] $VM,

[Switch] $RunAsynchronously,

Expand Down Expand Up @@ -3272,6 +3271,141 @@ function Restart-WAPWebSite {
}
}

function Get-WAPWebSiteGitRepository {
[cmdletbinding()]
[outputtype([system.string])]
param (
[Parameter(Mandatory, ValueFromPipeline)]
[System.Management.Automation.PSTypeName('WAP.WebSite')] $Website
)
process {
try {
if ($script:IgnoreSSL) {
Write-Warning -Message 'IgnoreSSL defined by Connect-WAPAPI, Certificate errors will be ignored!'
#Change Certificate Policy to ignore
IgnoreSSL
}
PreFlight -IncludeConnection -IncludeSubscription -IncludeWebSpace

$URI = '{0}:{1}/{2}/services/WebSpaces/{3}/sites/{4}/repository' -f $script:PublicTenantAPIUrl,$script:Port,$script:Subscription.SubscriptionId,$script:WebSpace.Name,$Website.Name
Write-Verbose -Message "Constructed WebSite URI: $URI"

Invoke-RestMethod -Uri $URI -Headers $script:Headers -Method Get -ContentType 'application/json'
} catch {
Write-Error -ErrorRecord $_
} finally {
#Change Certificate Policy to the original
if ($script:IgnoreSSL) {
[System.Net.ServicePointManager]::CertificatePolicy = $script:OriginalCertificatePolicy
}
}
}
}

function New-WAPWebSiteGitRepository {
[cmdletbinding()]
[outputtype([void],[System.String])]
param (
[Parameter(Mandatory, ValueFromPipeline)]
[System.Management.Automation.PSTypeName('WAP.WebSite')] $Website,

[switch] $PassThru
)
process {
try {
if ($script:IgnoreSSL) {
Write-Warning -Message 'IgnoreSSL defined by Connect-WAPAPI, Certificate errors will be ignored!'
#Change Certificate Policy to ignore
IgnoreSSL
}
PreFlight -IncludeConnection -IncludeSubscription -IncludeWebSpace

$URI = '{0}:{1}/{2}/services/WebSpaces/{3}/sites/{4}/repository' -f $script:PublicTenantAPIUrl,$script:Port,$script:Subscription.SubscriptionId,$script:WebSpace.Name,$Website.Name
Write-Verbose -Message "Constructed WebSite URI: $URI"

$null = Invoke-RestMethod -Uri $URI -Headers $script:Headers -Method Post -ContentType 'application/json'
if ($PassThru) {
$Website | Get-WAPWebSiteGitRepository
}
} catch {
Write-Error -ErrorRecord $_
} finally {
#Change Certificate Policy to the original
if ($script:IgnoreSSL) {
[System.Net.ServicePointManager]::CertificatePolicy = $script:OriginalCertificatePolicy
}
}
}
}

function Remove-WAPWebSiteGitRepository {
[CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact='High')]
param (
[Parameter(Mandatory, ValueFromPipeline)]
[System.Management.Automation.PSTypeName('WAP.WebSite')] $Website,

[Switch] $Force
)
process {
try {
if ($script:IgnoreSSL) {
Write-Warning -Message 'IgnoreSSL defined by Connect-WAPAPI, Certificate errors will be ignored!'
#Change Certificate Policy to ignore
IgnoreSSL
}

PreFlight -IncludeConnection -IncludeSubscription -IncludeWebSpace

$URI = '{0}:{1}/{2}/services/WebSpaces/{3}/sites/{4}/repository' -f $script:PublicTenantAPIUrl,$script:Port,$script:Subscription.SubscriptionId,$script:WebSpace.Name,$Website.Name
Write-Verbose -Message "Constructed WebSite URI: $URI"

if ($Force -or $PSCmdlet.ShouldProcess($Website.Name)) {
Invoke-RestMethod -Uri $URI -Headers $script:Headers -Method Delete
}
} catch {
Write-Error -ErrorRecord $_
} finally {
#Change Certificate Policy to the original
if ($IgnoreSSL) {
[System.Net.ServicePointManager]::CertificatePolicy = $script:OriginalCertificatePolicy
}
}
}
}

function Get-WAPWebSitePublishingInfo {
[cmdletbinding()]
[outputtype([pscustomobject])]
param (
[Parameter(Mandatory, ValueFromPipeline)]
[System.Management.Automation.PSTypeName('WAP.WebSite')] $Website
)
process {
try {
if ($script:IgnoreSSL) {
Write-Warning -Message 'IgnoreSSL defined by Connect-WAPAPI, Certificate errors will be ignored!'
#Change Certificate Policy to ignore
IgnoreSSL
}

PreFlight -IncludeConnection -IncludeSubscription -IncludeWebSpace

$URI = $Website.SelfLink + '?propertiesToInclude=RepositoryUri,PublishingUsername,PublishingPassword,Metadata,ScmType'
Write-Verbose -Message "Constructed WebSite URI: $URI"

(Invoke-RestMethod -Uri $URI -Headers $script:Headers -Method Get).SiteProperties.Properties

} catch {
Write-Error -ErrorRecord $_
} finally {
#Change Certificate Policy to the original
if ($IgnoreSSL) {
[System.Net.ServicePointManager]::CertificatePolicy = $script:OriginalCertificatePolicy
}
}
}
}

#endregion

Export-ModuleMember -Function *-WAP*
Expand Down

0 comments on commit 9494bf4

Please sign in to comment.