Public/New-JuribaDashboardSection.ps1
Function New-JuribaDashboardSection { [alias("New-DwDashboardSection")] [CmdletBinding(SupportsShouldProcess)] param( [Parameter(Mandatory=$false)] [string]$Instance, [Parameter(Mandatory=$false)] [string]$APIKey, [Parameter(Mandatory=$true)] [int]$DashboardId, [Parameter(Mandatory=$false)] [int]$Width = 2 ) if ((Get-Variable 'dwConnection' -Scope 'Global' -ErrorAction 'Ignore') -and !$APIKey -and !$Instance) { $APIKey = ConvertFrom-SecureString -SecureString $dwConnection.secureAPIKey -AsPlainText $Instance = $dwConnection.instance } if ($APIKey -and $Instance) { $request = @{ Uri = ($Instance + "/apiv1/dashboard/" + $DashboardId + "/section/") Method = "Post" Body = @{ "width" = $Width } | ConvertTo-Json ContentType = "application/json" Headers = @{ 'X-API-KEY' = $APIKey } } if ($PSCmdlet.ShouldProcess($DashboardId)) { $response = Invoke-RestMethod @request $response.sectionId } } else { Write-Error "No connection found. Please ensure `$APIKey and `$Instance is provided or connect using Connect-Juriba before proceeding." } } |