Skip to content

Commit

Permalink
ShouldContinue
Browse files Browse the repository at this point in the history
  • Loading branch information
TehMuffinMoo committed Jul 19, 2024
1 parent 1a9806b commit 1b57777
Show file tree
Hide file tree
Showing 24 changed files with 295 additions and 124 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
.PARAMETER Strict
Use strict filter matching. By default, filters are searched using wildcards where possible. Using strict matching will only return results matching exactly what is entered in the applicable parameters.
.EXAMPLE
PS> Get-B1HAGroup -Name "MyHAGroup" -Strict
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@
$splat = @{
"server" = $DHCPConfigProfileId
}

$splat = $splat | ConvertTo-Json

if($PSCmdlet.ShouldProcess("Assign DHCP Config Profile: $($Name) to Host: $($iObject.name)","Assign DHCP Config Profile: $($Name) to Host: $($iObject.name)",$MyInvocation.MyCommand)){
$Result = Invoke-CSP -Method "PATCH" -Uri "$(Get-B1CSPUrl)/api/ddi/v1/$($iObject.id)" -Data $splat | Select-Object -ExpandProperty result -ErrorAction SilentlyContinue
if ($Result.server -eq $DHCPConfigProfileId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
$splat = @{
"server" = $DNSConfigProfileId
}

$splat = $splat | ConvertTo-Json

if($PSCmdlet.ShouldProcess("Assign DNS Config Profile: $($Name) to Host: $($iObject.name)","Assign DNS Config Profile: $($Name) to Host: $($iObject.name)",$MyInvocation.MyCommand)){
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Remove-B1DHCPConfigProfile {
function Remove-B1DHCPConfigProfile {
<#
.SYNOPSIS
Removes a DHCP Config Profile
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Remove-B1DNSConfigProfile {
function Remove-B1DNSConfigProfile {
<#
.SYNOPSIS
Removes a DNS Config Profile
Expand Down
23 changes: 17 additions & 6 deletions Modules/ibPS/Functions/BloxOne/BloxOneDDI/Set-B1AddressBlock.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
.PARAMETER Object
The Address Block Object to update. Accepts pipeline input
.PARAMETER Force
Perform the operation without prompting for confirmation. By default, this function will not prompt for confirmation unless $ConfirmPreference is set to Medium.
.EXAMPLE
## Example usage when combined with Get-B1DHCPOptionCode
$DHCPOptions = @()
Expand All @@ -59,6 +62,10 @@
.FUNCTIONALITY
IPAM
#>
[CmdletBinding(
SupportsShouldProcess,
ConfirmImpact = 'Medium'
)]
param(
[Parameter(ParameterSetName="Subnet",Mandatory=$true)]
[String]$Subnet,
Expand All @@ -82,10 +89,12 @@
ParameterSetName="Object",
Mandatory=$true
)]
[System.Object]$Object
[System.Object]$Object,
[Switch]$Force
)

begin {
$ConfirmPreference = Confirm-ShouldProcess $PSBoundParameters
if ($Compartment) {
$CompartmentID = (Get-B1Compartment -Name $Compartment -Strict).id
if (!($CompartmentID)) {
Expand Down Expand Up @@ -148,11 +157,13 @@
$NewObj.compartment_id = $CompartmentID
}
$JSON = $NewObj | ConvertTo-Json -Depth 10 -Compress
$Results = Invoke-CSP -Method PATCH -Uri "$(Get-B1CSPUrl)/api/ddi/v1/$($Object.id)" -Data $JSON
if ($Results | Select-Object -ExpandProperty result -EA SilentlyContinue -WA SilentlyContinue) {
$Results | Select-Object -ExpandProperty result
} else {
$Results
if($PSCmdlet.ShouldProcess("Update Address Block:`n$(JSONPretty($JSON))","Update Address Block: $($Object.address)/$($Object.cidr) ($($Object.id))",$MyInvocation.MyCommand)){
$Results = Invoke-CSP -Method PATCH -Uri "$(Get-B1CSPUrl)/api/ddi/v1/$($Object.id)" -Data $JSON
if ($Results | Select-Object -ExpandProperty result -EA SilentlyContinue -WA SilentlyContinue) {
$Results | Select-Object -ExpandProperty result
} else {
$Results
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
.PARAMETER Object
The Authoritative Zone Object to update. Accepts pipeline input
.PARAMETER Force
Perform the operation without prompting for confirmation. By default, this function will not prompt for confirmation unless $ConfirmPreference is set to Medium.
.EXAMPLE
PS> Set-B1AuthoritativeZone -FQDN "mysubzone.mycompany.corp" -View "default" -DNSHosts "mybloxoneddihost1.corp.mycompany.com" -AddAuthNSGs "Data Centre"
Expand All @@ -48,6 +51,10 @@
.FUNCTIONALITY
DNS
#>
[CmdletBinding(
SupportsShouldProcess,
ConfirmImpact = 'Medium'
)]
param(
[Parameter(ParameterSetName="Default",Mandatory=$true)]
[String]$FQDN,
Expand All @@ -68,10 +75,12 @@
ParameterSetName="Object",
Mandatory=$true
)]
[System.Object]$Object
[System.Object]$Object,
[Switch]$Force
)

begin {
$ConfirmPreference = Confirm-ShouldProcess $PSBoundParameters
if ($Compartment) {
$CompartmentID = (Get-B1Compartment -Name $Compartment -Strict).id
if (!($CompartmentID)) {
Expand Down Expand Up @@ -147,11 +156,13 @@

$JSON = $NewObj | ConvertTo-Json -Depth 5 -Compress

$Results = Invoke-CSP -Method PATCH -Uri "$(Get-B1CSPUrl)/api/ddi/v1/$($Object.id)" -Data $JSON
if ($Results | Select-Object -ExpandProperty result -EA SilentlyContinue -WA SilentlyContinue) {
$Results | Select-Object -ExpandProperty result
} else {
$Results
if($PSCmdlet.ShouldProcess("Update Authoritative Zone:`n$(JSONPretty($JSON))","Update Authoritative Zone: $($Object.fqdn) ($($Object.id))",$MyInvocation.MyCommand)){
$Results = Invoke-CSP -Method PATCH -Uri "$(Get-B1CSPUrl)/api/ddi/v1/$($Object.id)" -Data $JSON
if ($Results | Select-Object -ExpandProperty result -EA SilentlyContinue -WA SilentlyContinue) {
$Results | Select-Object -ExpandProperty result
} else {
$Results
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
.PARAMETER Object
The DHCP Config Profile Object to update. Accepts pipeline input
.PARAMETER Force
Perform the operation without prompting for confirmation. By default, this function will not prompt for confirmation unless $ConfirmPreference is set to Medium.
.EXAMPLE
PS> Set-B1DHCPConfigProfile -Name 'Data Centre DHCP' -AddDDNSZones -DDNSZones 'company.corp' -DNSView default
Expand All @@ -53,6 +56,10 @@
.FUNCTIONALITY
BloxOneDDI
#>
[CmdletBinding(
SupportsShouldProcess,
ConfirmImpact = 'Medium'
)]
param(
[Parameter(ParameterSetName="Default",Mandatory=$true)]
[String]$Name,
Expand All @@ -74,10 +81,12 @@
ParameterSetName="Object",
Mandatory=$true
)]
[System.Object]$Object
[System.Object]$Object,
[Switch]$Force
)

process {
$ConfirmPreference = Confirm-ShouldProcess $PSBoundParameters
if ($AddDDNSZones -and $RemoveDDNSZones) {
Write-Error "Error. -AddDDNSZones and -RemoveDDNSZones are mutually exclusive parameters."
return $null
Expand All @@ -96,9 +105,12 @@
Write-Error "Error. Unsupported pipeline object. This function only supports 'dhcp/server' objects as input"
return $null
}
if (($DDNSDomain -or $AddDDNSZones -or $RemoveDDNSZones) -and ($Object.inheritance_sources -eq $null)) {
if (($DDNSDomain -or $AddDDNSZones -or $RemoveDDNSZones -or $EnableDDNS -or $SendDDNSUpdates) -and ($Object.inheritance_sources -eq $null)) {
$Object = Get-B1DHCPConfigProfile -id $Object.id -IncludeInheritance
}
if ($Object.inheritance_sources -eq $null) {
$Object.PSObject.Properties.Remove('inheritance_sources')
}
} else {
$Object = Get-B1DHCPConfigProfile -Name $Name -IncludeInheritance -Strict
if (!($Object)) {
Expand Down Expand Up @@ -167,11 +179,14 @@
}
}
$JSON = $NewObj | ConvertTo-Json -Depth 10 -Compress
$Results = Invoke-CSP -Method PATCH -Uri "$(Get-B1CSPUrl)/api/ddi/v1/$($Object.id)" -Data $JSON
if ($Results | Select-Object -ExpandProperty result -EA SilentlyContinue -WA SilentlyContinue) {
$Results | Select-Object -ExpandProperty result
} else {
$Results

if($PSCmdlet.ShouldProcess("Update DHCP Config Profile:`n$(JSONPretty($JSON))","Update DHCP Config Profile: $($Object.name) ($($Object.id))",$MyInvocation.MyCommand)){
$Results = Invoke-CSP -Method PATCH -Uri "$(Get-B1CSPUrl)/api/ddi/v1/$($Object.id)" -Data $JSON
if ($Results | Select-Object -ExpandProperty result -EA SilentlyContinue -WA SilentlyContinue) {
$Results | Select-Object -ExpandProperty result
} else {
$Results
}
}
}
}
Loading

0 comments on commit 1b57777

Please sign in to comment.