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

Commit

Permalink
Added first admin function and defaulted remove-wapvmnetwork to sync …
Browse files Browse the repository at this point in the history
…mode
  • Loading branch information
bgelens committed May 31, 2016
1 parent 9494bf4 commit af0c408
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ The function is based on the example WAP functions found in the Admin-API instal

Both Tenant and Admin should have the same relying party settings configured.

## Admin API functions
Started with implementation of Admin API functions. These functions are prefixed with the noun WAPAdmin.
- Get-WAPAdminSubscription [-SubscriptionId 'subscriptionid']

Examples
--------
```powershell
Expand Down
5 changes: 3 additions & 2 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.1'
ModuleVersion = '0.0.6.3'

# ID used to uniquely identify this module
GUID = 'eaa28acf-4a1e-4d0e-96dd-fa36de33a658'
Expand Down Expand Up @@ -118,7 +118,8 @@ FunctionsToExport = @(
'New-WAPWebSiteGitRepository',
'Get-WAPWebSiteGitRepository',
'Remove-WAPWebSiteGitRepository',
'Get-WAPWebSitePublishingInfo'
'Get-WAPWebSitePublishingInfo',
'Get-WAPAdminSubscription'
)

# Cmdlets to export from this module
Expand Down
59 changes: 58 additions & 1 deletion WapTenantPublicAPI.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1548,6 +1548,8 @@ function Remove-WAPVMNetwork {
[ValidateNotNull()]
[PSCustomObject] $VMNetwork,

[Switch] $RunAsynchronously,

[Switch] $Force
)
#// TODO: for now, only support pipeline VMNetwork. Later support Name/ID?
Expand All @@ -1565,7 +1567,12 @@ function Remove-WAPVMNetwork {

PreFlight -IncludeConnection -IncludeSubscription

$RemURI = '{0}:{1}/{2}/services/systemcenter/vmm/VMNetworks(ID=guid''{3}'',StampId=guid''{4}'')' -f $PublicTenantAPIUrl,$Port,$Subscription.SubscriptionId,$VMNetwork.ID,$VMNetwork.StampId
$RemURI = '{0}:{1}/{2}/services/systemcenter/vmm/VMNetworks(ID=guid''{3}'',StampId=guid''{4}'')?RunAsynchronously=' -f $PublicTenantAPIUrl,$Port,$Subscription.SubscriptionId,$VMNetwork.ID,$VMNetwork.StampId
if ($RunAsynchronously) {
$RemURI = $RemURI + '1'
} else {
$RemURI = $RemURI + '0'
}
Write-Verbose -Message "Constructed Remove VM Network URI: $RemURI"

if ($Force -or $PSCmdlet.ShouldProcess($VMNetwork.Name)) {
Expand Down Expand Up @@ -2541,6 +2548,55 @@ function Get-WAPVMRoleVMSize {

}

#region Admin functions
function Get-WAPAdminSubscription {
[OutputType([PSCustomObject])]
[CmdletBinding(DefaultParameterSetName = 'List')]
param (
[Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName, ParameterSetName = 'Id')]
[ValidateNotNullOrEmpty()]
[String] $SubscriptionId
)
process {
try {
if ($IgnoreSSL) {
Write-Warning -Message 'IgnoreSSL defined by Connect-WAPAPI, Certificate errors will be ignored!'
#Change Certificate Policy to ignore
IgnoreSSL
}

PreFlight -IncludeConnection

if ($SubscriptionId) {
$URI = '{0}:{1}/subscriptions/{2}' -f $PublicTenantAPIUrl,$Port,$SubscriptionId
} else {
$URI = '{0}:{1}/subscriptions' -f $PublicTenantAPIUrl,$Port
}
Write-Verbose -Message "Constructed Subscription URI: $URI"
$Subscriptions = Invoke-RestMethod -Uri $URI -Headers $Headers -Method Get

if ($SubscriptionId) {
$Subscriptions.PSObject.TypeNames.Insert(0,'WAP.AdminSubscription')
Write-Output -InputObject $Subscriptions
} else {
foreach ($S in $Subscriptions.Items) {
$S.PSObject.TypeNames.Insert(0,'WAP.AdminSubscription')
Write-Output -InputObject $S
}
}
} catch {
Write-Error -ErrorRecord $_
} finally {
#Change Certificate Policy to the original
if ($IgnoreSSL) {
[System.Net.ServicePointManager]::CertificatePolicy = $OriginalCertificatePolicy
}
}
}
}
#endregion Admin functions

#region SQL DB
function Get-WAPSQLDatabase {
[OutputType([PSCustomObject])]
[CmdletBinding(DefaultParameterSetName = 'List')]
Expand Down Expand Up @@ -2946,6 +3002,7 @@ function Remove-WAPSQLDatabase {
}
}
}
#endregion SQL DB

#region Websites
function Get-WAPWebSpace {
Expand Down

0 comments on commit af0c408

Please sign in to comment.