diff --git a/README.md b/README.md index 62ef878..99b8ca8 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/WapTenantPublicAPI.psd1 b/WapTenantPublicAPI.psd1 index 11ef7aa..8f96d8f 100644 --- a/WapTenantPublicAPI.psd1 +++ b/WapTenantPublicAPI.psd1 @@ -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' @@ -118,7 +118,8 @@ FunctionsToExport = @( 'New-WAPWebSiteGitRepository', 'Get-WAPWebSiteGitRepository', 'Remove-WAPWebSiteGitRepository', - 'Get-WAPWebSitePublishingInfo' + 'Get-WAPWebSitePublishingInfo', + 'Get-WAPAdminSubscription' ) # Cmdlets to export from this module diff --git a/WapTenantPublicAPI.psm1 b/WapTenantPublicAPI.psm1 index 372c993..95bbbbf 100644 --- a/WapTenantPublicAPI.psm1 +++ b/WapTenantPublicAPI.psm1 @@ -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? @@ -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)) { @@ -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')] @@ -2946,6 +3002,7 @@ function Remove-WAPSQLDatabase { } } } +#endregion SQL DB #region Websites function Get-WAPWebSpace {