Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ yarn.lock
*.o
*.so

NCRestAPI.code-workspace
NCRestAPI.code-workspace
docs
29 changes: 28 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
# Changelog

## 1.7.1
## 1.8.1

### Fixed

- `Get-NCScheduledTasks`: removed dead `-All`/`-PageNumber`/`-PageSize`/`-SortBy`/`-SortOrder`
parameters that always threw before being used. `-TaskId` is now mandatory.
- `New-NCOrgAccessGroup` / `New-NCDeviceAccessGroup`: optional `orgUnitIds`/`deviceIds`/`userIds`
arrays are no longer sent as `null` when omitted.
- `Get-NCStandardPsaCustomerMapping`: migrated from deprecated
`/api/standard-psa/customer-mapping/{id}` to `/api/standard-psa/customer/{id}/mappings`.
- `Get-NCFilters`, `New-NCServiceOrg`, `New-NCSite`: added `begin`/`process` blocks
for consistency and correct API instance lifecycle.

### Changed

- Standardized PascalCase variable references in body construction and
`ShouldProcess` calls across `New-NCCustomer`, `New-NCSite`, `New-NCServiceOrg`,
`Get-NCJobStatus`, `Get-NCDefaultDeviceProperty`.
- Fixed `.PARAMETER` casing in comment-based help to match parameter declarations
in `Get-NCDeviceServices`, `Get-NCApplianceTask`, `Get-NCScheduledTaskStatus`,
`New-NCSite`, `New-NCCustomer`, `New-NCScheduledTask`.
- Cleaned up indentation and removed extra blank lines in `Get-NCJobStatus`,
`Get-NCDefaultDeviceProperty`, `Get-NCDeviceAssets`, `Get-NCDeviceServices`.
- `SpecDrift.Tests.ps1` now reads root `spec.json` instead of
`Tests/fixtures/openapi-spec.json`.
- Added test asserting `Get-NCScheduledTasks` requires `-TaskId`.

## 1.8.0

### Fixed (surfaced by a full cmdlet matrix run against demo server)

Expand Down
2 changes: 1 addition & 1 deletion NCRestAPI.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
RootModule = 'NCRestAPI.psm1'

# Version number of this module.
ModuleVersion = '1.8.0'
ModuleVersion = '1.8.1'

# Supported PSEditions
CompatiblePSEditions = @('Desktop', 'Core')
Expand Down
4 changes: 2 additions & 2 deletions Public/Get-NCApplianceTask.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ Retrieves the appliance-task information for a given task ID from the N-central
.DESCRIPTION
The `Get-NCApplianceTask` function retrieves the appliance-task information for a specified task ID from the N-central API.

.PARAMETER taskId
.PARAMETER TaskId
Specifies the task ID for which to fetch the appliance-task information. This parameter is mandatory.

.EXAMPLE
PS C:\> Get-NCApplianceTask -taskId "abc123" -Verbose
PS C:\> Get-NCApplianceTask -TaskId "abc123" -Verbose
Retrieves the appliance-task information for the task with ID "abc123" and enables verbose output.

.INPUTS
Expand Down
12 changes: 2 additions & 10 deletions Public/Get-NCDefaultDeviceProperty.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,8 @@ function Get-NCDefaultDeviceProperty {

begin { $api = Get-NCRestApiInstance }



process {
Write-Verbose "[FUNCTION] Get-NCDefaultDeviceProperty: invoked."
$endpoint = "api/org-units/$orgUnitId/custom-properties/device-custom-property-defaults/$propertyId"

Write-Verbose "[FUNCTION] Retrieving default device property with endpoint: $endpoint."
$response = $api.Get($endpoint)
return $response


Write-Verbose "[FUNCTION] Get-NCDefaultDeviceProperty: api/org-units/$OrgUnitId/custom-properties/device-custom-property-defaults/$PropertyId"
$api.Get("api/org-units/$OrgUnitId/custom-properties/device-custom-property-defaults/$PropertyId")
}
}
12 changes: 2 additions & 10 deletions Public/Get-NCDeviceAssets.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,8 @@ function Get-NCDeviceAssets {

begin { $api = Get-NCRestApiInstance }



process {
Write-Verbose "[FUNCTION] Get-NCDeviceAssets: invoked."
$endpoint = "api/devices/$DeviceId/assets"

Write-Verbose "[FUNCTION] Retrieving device assets with endpoint: $endpoint."
$data = $api.Get($endpoint)
return $data


Write-Verbose "[FUNCTION] Get-NCDeviceAssets: api/devices/$DeviceId/assets"
$api.Get("api/devices/$DeviceId/assets")
}
}
16 changes: 4 additions & 12 deletions Public/Get-NCDeviceServices.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ Retrieves service monitor status for a device from the N-central API.
The `Get-NCDeviceServices` function retrieves the service monitor status for a device from the N-central API.
It requires a device ID to specify the device whose service monitor status is to be retrieved.

.PARAMETER deviceId
.PARAMETER DeviceId
The device ID for which to retrieve service monitor status. This parameter is mandatory.

.EXAMPLE
PS C:\> Get-NCDeviceServices -deviceId 12345 -Verbose
PS C:\> Get-NCDeviceServices -DeviceId 12345 -Verbose
Retrieves the service monitor status for the device with the ID 12345 with verbose output enabled.

.INPUTS
Expand All @@ -36,16 +36,8 @@ function Get-NCDeviceServices {

begin { $api = Get-NCRestApiInstance }



process {
Write-Verbose "[FUNCTION] Get-NCDeviceServices: invoked."
$endpoint = "api/devices/$DeviceId/service-monitor-status"

Write-Verbose "[FUNCTION] Retrieving device services for endpoint: $endpoint."
$data = $api.Get($endpoint)
return $data


Write-Verbose "[FUNCTION] Get-NCDeviceServices: api/devices/$DeviceId/service-monitor-status"
$api.Get("api/devices/$DeviceId/service-monitor-status")
}
}
29 changes: 15 additions & 14 deletions Public/Get-NCFilters.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,24 @@ function Get-NCFilters {
[string]$SortOrder = 'asc'
)

$api = Get-NCRestApiInstance
$endpoint = 'api/device-filters'
begin { $api = Get-NCRestApiInstance }

$queryParameters = @{}
if ($ViewScope -and $ViewScope -ne 'ALL') { $queryParameters['viewScope'] = $ViewScope }
Add-NCCommonQuery -Parameters $queryParameters -Select $Select -SortBy $SortBy -SortOrder $SortOrder
process {
$endpoint = 'api/device-filters'

if ($All) {
return Invoke-NCPagedRequest -Endpoint $endpoint -QueryParameters $queryParameters
}

if ($PageNumber) { $queryParameters['pageNumber'] = $PageNumber }
$queryParameters = @{}
if ($ViewScope -and $ViewScope -ne 'ALL') { $queryParameters['viewScope'] = $ViewScope }
Add-NCCommonQuery -Parameters $queryParameters -Select $Select -SortBy $SortBy -SortOrder $SortOrder

if ($All) {
return Invoke-NCPagedRequest -Endpoint $endpoint -QueryParameters $queryParameters
}

if ($PageSize) { $queryParameters['pageSize'] = $PageSize } else { $queryParameters['pageSize'] = 500 }
if ($PageNumber) { $queryParameters['pageNumber'] = $PageNumber }
if ($PageSize) { $queryParameters['pageSize'] = $PageSize } else { $queryParameters['pageSize'] = 500 }

$endpoint += ConvertTo-NCQueryString -Parameters $queryParameters
Write-Verbose "[FUNCTION] Get-NCFilters: $endpoint"
$api.Get($endpoint)
$endpoint += ConvertTo-NCQueryString -Parameters $queryParameters
Write-Verbose "[FUNCTION] Get-NCFilters: $endpoint"
$api.Get($endpoint)
}
}
12 changes: 2 additions & 10 deletions Public/Get-NCJobStatus.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,8 @@ function Get-NCJobStatus {

begin { $api = Get-NCRestApiInstance }



process {
Write-Verbose "[FUNCTION] Get-NCJobStatus: invoked."
$endpoint = "api/org-units/$orgUnitId/job-statuses"

Write-Verbose "[FUNCTION] Retrieving job status with endpoint: $endpoint."
$data = $api.Get($endpoint)
return $data


Write-Verbose "[FUNCTION] Get-NCJobStatus: api/org-units/$OrgUnitId/job-statuses"
$api.Get("api/org-units/$OrgUnitId/job-statuses")
}
}
12 changes: 6 additions & 6 deletions Public/Get-NCScheduledTaskStatus.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@ Retrieves the status of a given task using the task ID or retrieves detailed sta
.DESCRIPTION
The `Get-NCScheduledTaskStatus` function retrieves the status of the given task from the N-central API based on the provided task ID. If the `-details` switch is specified, it retrieves detailed statuses for each device associated with the task instead.

.PARAMETER taskId
.PARAMETER TaskId
Specifies the ID of the task for which status needs to be fetched.

.PARAMETER details
.PARAMETER Details
If specified, retrieves detailed statuses per device for the given task.

.EXAMPLE
PS C:\> Get-NCScheduledTaskStatus -taskId "12345"
PS C:\> Get-NCScheduledTaskStatus -TaskId "12345"
Retrieves the aggregated status for the task with ID 12345.

.EXAMPLE
PS C:\> Get-NCScheduledTaskStatus -taskId "12345" -details
PS C:\> Get-NCScheduledTaskStatus -TaskId "12345" -Details
Retrieves the detailed status for the task with ID 12345.

.EXAMPLE
PS C:\> Get-NCScheduledTaskStatus -taskId "12345" -Verbose
PS C:\> Get-NCScheduledTaskStatus -TaskId "12345" -Verbose
Retrieves the aggregated status for the task with ID 12345 with verbose output enabled.

.EXAMPLE
PS C:\> Get-NCScheduledTaskStatus -taskId "12345" -details -Verbose
PS C:\> Get-NCScheduledTaskStatus -TaskId "12345" -Details -Verbose
Retrieves the detailed status for the task with ID 12345 with verbose output enabled.

.INPUTS
Expand Down
43 changes: 9 additions & 34 deletions Public/Get-NCScheduledTasks.ps1
Original file line number Diff line number Diff line change
@@ -1,55 +1,30 @@
<#
.SYNOPSIS
Retrieves scheduled tasks from the N-central API.
Retrieves a scheduled task by ID from the N-central API.

.DESCRIPTION
Returns all scheduled tasks, or a specific task by ID. Supports `-All` auto-pagination
and pipeline input.
N-central does not expose a bulk "list all scheduled tasks" endpoint.
Use Get-NCDeviceScheduledTasks to enumerate tasks per device.

.PARAMETER TaskId
Specific scheduled task to retrieve.

.PARAMETER All
Auto-paginate across all scheduled tasks.

.EXAMPLE
Get-NCScheduledTasks -TaskId abc123

.EXAMPLE
Get-NCScheduledTasks -All
#>
function Get-NCScheduledTasks {
[CmdletBinding(DefaultParameterSetName = 'Page')]
[CmdletBinding()]
[OutputType([pscustomobject])]
param (
[Parameter(ValueFromPipelineByPropertyName)]
[string]$TaskId,

[Parameter(ParameterSetName = 'All')]
[switch]$All,

[Parameter(ParameterSetName = 'Page')]
[int]$PageNumber,

[Parameter(ParameterSetName = 'Page')]
[int]$PageSize,

[string]$SortBy,
[ValidateSet('asc', 'desc')]
[string]$SortOrder = 'asc'
[Parameter(Mandatory, ValueFromPipelineByPropertyName)]
[ValidateNotNullOrEmpty()]
[string]$TaskId
)

begin { $api = Get-NCRestApiInstance }

process {

Write-Verbose "[FUNCTION] Get-NCScheduledTasks: invoked."
if ($TaskId) {
return $api.Get("api/scheduled-tasks/$TaskId")
}
# N-central has no bulk "list all scheduled tasks" endpoint. /api/scheduled-tasks
# is a hypermedia navigation (returns only _links). Callers must fetch tasks per
# device via Get-NCDeviceScheduledTasks, or look up a known TaskId.
throw "Get-NCScheduledTasks requires -TaskId. N-central does not expose a bulk-list endpoint; use Get-NCDeviceScheduledTasks -DeviceId X to enumerate a device's tasks, or pipe devices in: Get-NCDevices -All | Get-NCDeviceScheduledTasks."
Write-Verbose "[FUNCTION] Get-NCScheduledTasks: api/scheduled-tasks/$TaskId"
$api.Get("api/scheduled-tasks/$TaskId")
}
}
6 changes: 3 additions & 3 deletions Public/Get-NCStandardPsaCustomerMapping.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Retrieves standard-PSA customer mappings for a given customer.

.DESCRIPTION
GET /api/standard-psa/customer-mapping/{customerId}.
GET /api/standard-psa/customer/{customerId}/mappings.

.EXAMPLE
Get-NCStandardPsaCustomerMapping -CustomerId 100
Expand All @@ -18,7 +18,7 @@ function Get-NCStandardPsaCustomerMapping {
)
begin { $api = Get-NCRestApiInstance }
process {
Write-Verbose "[FUNCTION] Get-NCStandardPsaCustomerMapping: invoked."
$api.Get("api/standard-psa/customer-mapping/$CustomerId")
Write-Verbose "[FUNCTION] Get-NCStandardPsaCustomerMapping: api/standard-psa/customer/$CustomerId/mappings"
$api.Get("api/standard-psa/customer/$CustomerId/mappings")
}
}
Loading