Public/Set-DattoDtcAgentBandwidth.ps1
|
function Set-DattoDtcAgentBandwidth { <# .SYNOPSIS Updates bandwidth settings for a Direct-to-Cloud agent. .DESCRIPTION Implements PUT /v1/dtc/agent/{agentUuid}/bandwidth. Only explicitly supplied settings are sent. PUT requests are not automatically retried by this cmdlet. .PARAMETER AgentUuid The Direct-to-Cloud agent UUID. .PARAMETER PauseWhileMetered Whether the agent should pause while the connection is metered. .PARAMETER MaximumBandwidthInBits The maximum bandwidth in bits. Supply an explicit null to send JSON null, or omit the parameter to leave the field out of the request. .PARAMETER MaximumThrottledBandwidthInBits The maximum throttled bandwidth in bits. Supply an explicit null to send JSON null, or omit the parameter to leave the field out of the request. .PARAMETER Connection A connection object, name, or ID. .EXAMPLE Set-DattoDtcAgentBandwidth -AgentUuid 'deadbeef-dead-beef-dead-beefdeadbeef' -PauseWhileMetered $false -MaximumBandwidthInBits 5242880 -WhatIf #> [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Medium')] param( [Parameter(Mandatory)][ValidateNotNullOrEmpty()][string]$AgentUuid, [Parameter()][bool]$PauseWhileMetered, [Parameter()][AllowNull()][ValidateRange(0, [long]::MaxValue)][Nullable[long]]$MaximumBandwidthInBits, [Parameter()][AllowNull()][ValidateRange(0, [long]::MaxValue)][Nullable[long]]$MaximumThrottledBandwidthInBits, [Parameter()][AllowNull()][object]$Connection ) $settingNames = @('PauseWhileMetered', 'MaximumBandwidthInBits', 'MaximumThrottledBandwidthInBits') $hasSetting = @($settingNames | Where-Object { $PSBoundParameters.ContainsKey($_) }).Count -gt 0 if (-not $hasSetting) { throw [System.ArgumentException]::new('Specify at least one bandwidth setting to update.') } $body = [ordered]@{} if ($PSBoundParameters.ContainsKey('PauseWhileMetered')) { $body['pauseWhileMetered'] = $PauseWhileMetered } if ($PSBoundParameters.ContainsKey('MaximumBandwidthInBits')) { $body['maximumBandwidthInBits'] = $MaximumBandwidthInBits } if ($PSBoundParameters.ContainsKey('MaximumThrottledBandwidthInBits')) { $body['maximumThrottledBandwidthInBits'] = $MaximumThrottledBandwidthInBits } $agent = ConvertTo-DattoApiPathSegment -Value $AgentUuid if ($PSCmdlet.ShouldProcess("Direct-to-Cloud agent $AgentUuid", 'Update bandwidth settings')) { Invoke-DattoApiRequest -Method PUT -Path "/v1/dtc/agent/$agent/bandwidth" -Body $body -Connection $Connection } } |