Created
June 21, 2020 16:43
-
-
Save smaglio81/bca389b1f852f82ba823f1166dfd37e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Update-AzDServiceHook { | |
param( | |
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)] | |
[Microsoft.VisualStudio.Services.ServiceHooks.WebApi.Subscription] $Subscription, | |
[Parameter(ValueFromPipelineByPropertyName = $true)] | |
[switch] $Enable, | |
[Parameter(ValueFromPipelineByPropertyName = $true)] | |
[switch] $Disable | |
) | |
if($Enable) { | |
$Subscription.Status = [Microsoft.VisualStudio.Services.ServiceHooks.WebApi.SubscriptionStatus]::Enabled | |
} | |
if($Disable) { | |
$Subscription.Status = [Microsoft.VisualStudio.Services.ServiceHooks.WebApi.SubscriptionStatus]::DisabledByUser | |
} | |
$output = ($Subscription | ft -AutoSize Id, EventType, ConsumerId, Status, ActionDescription | Out-String) -split [Environment]::NewLine | |
Write-Verbose "Updating: $($output[3])" | |
$shpClient = $global:AzDModule.ServiceHooksPublisherClient | |
$response = $shpClient.UpdateSubscriptionAsync($Subscription, $null) | |
if($null -ne $response.Exception) { | |
if($null -ne $response.Exception.InnerException) { | |
throw $response.Exception.InnerException.Message | |
} else { | |
throw $response.Exception.Message | |
} | |
} | |
return $response.Result | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment