Public/Subscriptions.ps1
Function New-NmeLinkedSubscription { <# .SYNOPSIS Link Azure subscripiton. .DESCRIPTION Link Azure subscripiton. This function calls the /api/v1/subscriptions endpoint of the NME REST API, using the post method. .PARAMETER NmeLinkSubscriptionRestPayload Requires an NmeLinkSubscriptionRestPayload object, as generated by the New-NmeLinkSubscriptionRestPayload command. #> [CmdletBinding()] Param( [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$True)][ValidateScript({if ($_.PSObject.TypeNames -contains "NmeLinkSubscriptionRestPayload"){$true} else{throw " is not a NmeLinkSubscriptionRestPayload object."}})]$NmeLinkSubscriptionRestPayload ) Set-NmeAuthHeaders Try { $json = $NmeLinkSubscriptionRestPayload | ConvertTo-Json -Depth 20 Write-Debug 'json:' Write-Debug $json $Result = Invoke-RestMethod "$script:NmeUri/api/v1/subscriptions$QueryString" -Method post -Headers $script:AuthHeaders -ContentType 'application/json' -body $json Write-Verbose ($result | out-string) $Result.PSObject.TypeNames.Insert(0, 'NmeLinkedSubscriptionRestModel') $Result | CapProps } Catch { $message = ParseErrorForResponseBody($_) write-error ($message | out-string) } } Function Set-NmeAzureSubscriptionId { <# .SYNOPSIS . .DESCRIPTION . This function calls the /api/v1/subscriptions/{subscriptionId} endpoint of the NME REST API, using the patch method. .PARAMETER SubscriptionId The id (guid) of the subscription where this subscriptions resides .PARAMETER NmePatchLinkedSubscriptionRestModel Requires an NmePatchLinkedSubscriptionRestModel object, as generated by the New-NmePatchLinkedSubscriptionRestModel command. #> [CmdletBinding()] Param( [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][string]$SubscriptionId, [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$True)][ValidateScript({if ($_.PSObject.TypeNames -contains "NmePatchLinkedSubscriptionRestModel"){$true} else{throw " is not a NmePatchLinkedSubscriptionRestModel object."}})]$NmePatchLinkedSubscriptionRestModel ) Set-NmeAuthHeaders Try { $json = $NmePatchLinkedSubscriptionRestModel | ConvertTo-Json -Depth 20 Write-Debug 'json:' Write-Debug $json $Result = Invoke-RestMethod "$script:NmeUri/api/v1/subscriptions/$SubscriptionId$QueryString" -Method patch -Headers $script:AuthHeaders -ContentType 'application/json' -body $json Write-Verbose ($result | out-string) $Result.PSObject.TypeNames.Insert(0, 'NmeLinkedSubscriptionRestModel') $Result | Add-Member -NotePropertyName 'subscriptionId' -NotePropertyValue $subscriptionId -erroraction 'SilentlyContinue' $Result | CapProps } Catch { $message = ParseErrorForResponseBody($_) write-error ($message | out-string) } } |