Skip to content

Commit

Permalink
Moved functions into module-based folder structure
Browse files Browse the repository at this point in the history
to group cmdlets for review and modification.

Added missing workspace help identified in build errors

Updated tests failing with object schema changes for Workspaces
  • Loading branch information
rasimmers committed Oct 19, 2023
1 parent eedf819 commit 3fd9686
Show file tree
Hide file tree
Showing 189 changed files with 337 additions and 364 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ todo.md
# Ignore Release directory generated by local builds
Output/
Test*.xml

enhancements.md

#######
# Excerpts from https://www.gitignore.io
Expand Down
13 changes: 8 additions & 5 deletions FreshservicePS/FreshservicePS.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ else {
}

# Dot source public/private functions
$public = @(Get-ChildItem -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Public/*.ps1') -Recurse -ErrorAction Stop)
$private = @(Get-ChildItem -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Private/*.ps1') -Recurse -ErrorAction Stop)
foreach ($import in @($public + $private)) {
# $public = @(Get-ChildItem -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Public/*.ps1') -Recurse -ErrorAction Stop)
# $private = @(Get-ChildItem -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Private/*.ps1') -Recurse -ErrorAction Stop)

$FunctionFiles = $("$PSScriptRoot\Public\","$PSScriptRoot\Private\")| Get-Childitem -File -Recurse -Include "*.ps1" -ErrorAction SilentlyContinue

foreach ($import in $FunctionFiles) {
try {
. $import.FullName
if ($import.BaseName -like '*FreshService*') {
Expand All @@ -34,8 +37,8 @@ if (Test-Path -Path $FreshServiceConfigPath) {
Where-Object -FilterScript {$_.Default -eq $true}

if ($defaultConnection) {
Write-Warning -Message ('*** Automatically connecting to default Freshservice tenant {0}. ***' -f $defaultConnection.Tenant)
Connect-Freshservice -Name $defaultConnection.Name -NoBanner
Write-Warning -Message ('*** Automatically connecting to default Freshservice tenant {0}. ***' -f ($defaultConnection | Select-Object -First 1 -ExpandProperty Tenant))
Connect-Freshservice -Name ($defaultConnection | Select-Object -First 1 -ExpandProperty Name) -NoBanner
}
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
.PARAMETER groups
Unique IDs of Groups in which the permissions granted by the role applies. Mandatory only when the assignment_scope is specified_groups, and should be ignored otherwise.
.PARAMETER workspace_id
Workspace ID to assign permissions. The attribute is applicable only for accounts with the Workspaces feature enabled. The default value is the ID of the primary workspace of the account.
.EXAMPLE
$newFreshServiceAgentRoleConfigSplat1 = @{
role_id = 21000150301 #IT Ops Agent - Get-FreshServiceAgentRole
Expand Down Expand Up @@ -75,7 +78,14 @@ function New-FreshServiceAgentRoleConfig {
Mandatory = $false,
HelpMessage = 'Unique IDs of Groups in which the permissions granted by the role applies. Mandatory only when the assignment_scope is specified_groups, and should be ignored otherwise.'
)]
[long[]]$groups
[long[]]$groups,
[Parameter(
Mandatory = $false,
HelpMessage = 'Workspace id is applicable only for accounts with Workspaces feature enabled.',
ParameterSetName = 'default',
Position = 0
)]
[int]$workspace_id
)
begin {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@
.PARAMETER custom_fields
Key-value pair containing the names and values of the (custom) agent fields.
.PARAMETER workspace_ids
Workspace Ids the agent will be a member of.
.EXAMPLE
$newFreshServiceAgentRoleConfigSplat1 = @{
role_id = 21000150301 #IT Ops Agent - Get-FreshServiceAgentRole
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@
Each individual role is a hash in the roles array that contains the attributes.role_id: Unique ID of the role assigned"assignment_scope:
The scope in which the agent can use the permissions granted by this role. Possible values include entire_helpdesk (all plans)
.PARAMETER license_type
The type of license, IT or Business.
.PARAMETER signature
Signature of the agent in HTML format.
Expand All @@ -89,6 +92,9 @@
.PARAMETER reactivate
This operation allows you to reactivate a particular deactivated requester.
.PARAMETER workspace_ids
Workspace Ids the agent will be a member of.
.EXAMPLE
Set-FreshServiceAgent -Id 21001392937 -scoreboard_level_id 2 -address '123 Anywhere Ln'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
IMPORTANT: These type fields vary on every Freshservice tenant and are represented by the layer id. See Get-FreshServiceAssetType.
.PARAMETER workspace_id
Workspace ID to create asset. The attribute is applicable only for accounts with the Workspaces feature enabled. The default value is the ID of the primary workspace of the account.
.EXAMPLE
New-FreshServiceAsset -name 'Laptop123' -description 'Apple Laptop' -asset_type_id 21000855304 -type_fields @{product_21000855267 = 21000056898;asset_state_21000855267 = 'In Use'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
.PARAMETER type_fields
Key-value pair containing the names and values of the asset type fields.
.PARAMETER workspace_id
Workspace ID to move asset. The attribute is applicable only for accounts with the Workspaces feature enabled. The default value is the ID of the primary workspace of the account.
.EXAMPLE
Set-FreshServiceAsset -display_id 1 -description 'Updated description'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,10 @@ function Set-FreshServiceChange {
})]
[System.IO.FileInfo[]]$attachments,
[Parameter(
Mandatory = $true,
Mandatory = $false,
HelpMessage = 'Workspace ID to move Change. The attribute is applicable only for accounts with the Workspaces feature enabled. The default value is the ID of the primary workspace of the account.',
ValueFromPipelineByPropertyName = $true,
ParameterSetName = 'workspace',
ParameterSetName = 'default',
Position = 1
)]
[int]$workspace_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
Note: Important! This filter requires spaces between the key\value pairs. Using category_dd1:'Hardware' will fail, the API requires the spacing category_dd1 : 'Hardware'.
.PARAMETER sort_field
Name of the object field\header to be used for sorting the records.
Name of the object field\header to be used for sorting the records.
.PARAMETER sort_order
Order of sorting the records (ASC or DESC).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,10 @@ function Set-FreshServiceProblem {
)]
[string]$problem_impact,
[Parameter(
Mandatory = $true,
Mandatory = $false,
HelpMessage = 'Workspace ID to move Problem. The attribute is applicable only for accounts with the Workspaces feature enabled. The default value is the ID of the primary workspace of the account.',
ValueFromPipelineByPropertyName = $true,
ParameterSetName = 'workspace',
ParameterSetName = 'default',
Position = 1
)]
[int]$workspace_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,10 @@ function Set-FreshServiceRelease {
)]
[string]$test_plan,
[Parameter(
Mandatory = $true,
Mandatory = $false,
HelpMessage = 'Workspace ID to move Change. The attribute is applicable only for accounts with the Workspaces feature enabled. The default value is the ID of the primary workspace of the account.',
ValueFromPipelineByPropertyName = $true,
ParameterSetName = 'workspace',
ParameterSetName = 'default',
Position = 1
)]
[int]$workspace_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ function Set-FreshServiceTicket {
)]
[long]$id,
[Parameter(
Mandatory = $true,
Mandatory = $false,
HelpMessage = 'Workspace ID to move ticket. The attribute is applicable only for accounts with the Workspaces feature enabled. The default value is the ID of the primary workspace of the account.',
ValueFromPipelineByPropertyName = $true
)]
Expand Down
22 changes: 1 addition & 21 deletions docs/en-US/Get-FreshServiceAsset.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ Returns a Freshservice Asset.

### default (Default)
```
Get-FreshServiceAsset [[-workspace_id] <Int32[]>] [-IncludeTypeFields] [[-per_page] <Int32>] [[-page] <Int32>]
[<CommonParameters>]
Get-FreshServiceAsset [-IncludeTypeFields] [[-per_page] <Int32>] [[-page] <Int32>] [<CommonParameters>]
```

### relationships
Expand Down Expand Up @@ -267,25 +266,6 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -workspace_id
Workspace id filter is applicable only for accounts with Workspaces feature enabled. Providing a Workspace_id will return tickets from a specific workspace.
If the workspace_id(s) parameter is NOT provided, data will only be returned for the Default\Primary Workspace.
If the workspace_id(s) parameter is provided, data will be returned from the specified Workspaces.
If the workspace_id value is 0, data will be returned from all workspaces (the user has access to), with only global level fields.
```yaml
Type: Int32[]
Parameter Sets: default
Aliases:

Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -filter
Custom filters supported by the api can be found here: https://api.freshservice.com/#filter_assets.
The filter is automatically url encoded at runtime.
Expand Down
26 changes: 3 additions & 23 deletions docs/en-US/Get-FreshServiceBusinessHour.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ Returns a Freshservice Business Hours.

### default (Default)
```
Get-FreshServiceBusinessHour [[-workspace_id] <Int32[]>] [[-per_page] <Int32>] [[-page] <Int32>]
[<CommonParameters>]
Get-FreshServiceBusinessHour [[-per_page] <Int32>] [[-page] <Int32>] [<CommonParameters>]
```

### id
Expand Down Expand Up @@ -85,25 +84,6 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -workspace_id
Workspace id filter is applicable only for accounts with Workspaces feature enabled. Providing a Workspace_id will return tickets from a specific workspace.
If the workspace_id(s) parameter is NOT provided, data will only be returned for the Default\Primary Workspace.
If the workspace_id(s) parameter is provided, data will be returned from the specified Workspaces.
If the workspace_id value is 0, data will be returned from all workspaces (the user has access to), with only global level fields.
```yaml
Type: Int32[]
Parameter Sets: default
Aliases:

Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -per_page
Number of records to return per page during pagination.
Maximum of 100 records.
Expand All @@ -114,7 +94,7 @@ Parameter Sets: default
Aliases:

Required: False
Position: 2
Position: 1
Default value: 100
Accept pipeline input: False
Accept wildcard characters: False
Expand All @@ -129,7 +109,7 @@ Parameter Sets: default
Aliases:

Required: False
Position: 3
Position: 2
Default value: 1
Accept pipeline input: False
Accept wildcard characters: False
Expand Down
26 changes: 3 additions & 23 deletions docs/en-US/Get-FreshServiceCatalogCategory.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ Returns a Freshservice Service Catalog Category.

### default (Default)
```
Get-FreshServiceCatalogCategory [[-workspace_id] <Int32[]>] [[-per_page] <Int32>] [[-page] <Int32>]
[<CommonParameters>]
Get-FreshServiceCatalogCategory [[-per_page] <Int32>] [[-page] <Int32>] [<CommonParameters>]
```

### Id
Expand Down Expand Up @@ -96,25 +95,6 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -workspace_id
Workspace id filter is applicable only for accounts with Workspaces feature enabled. Providing a Workspace_id will return tickets from a specific workspace.
If the workspace_id(s) parameter is NOT provided, data will only be returned for the Default\Primary Workspace.
If the workspace_id(s) parameter is provided, data will be returned from the specified Workspaces.
If the workspace_id value is 0, data will be returned from all workspaces (the user has access to), with only global level fields.
```yaml
Type: Int32[]
Parameter Sets: default
Aliases:

Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -per_page
Number of records to return per page during pagination.
Maximum of 100 records.
Expand All @@ -125,7 +105,7 @@ Parameter Sets: default
Aliases:

Required: False
Position: 2
Position: 3
Default value: 100
Accept pipeline input: False
Accept wildcard characters: False
Expand All @@ -140,7 +120,7 @@ Parameter Sets: default
Aliases:

Required: False
Position: 3
Position: 4
Default value: 1
Accept pipeline input: False
Accept wildcard characters: False
Expand Down
26 changes: 3 additions & 23 deletions docs/en-US/Get-FreshServiceCatalogItem.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ Returns a Freshservice Service Catalog Item.

### default (Default)
```
Get-FreshServiceCatalogItem [[-workspace_id] <Int32[]>] [[-per_page] <Int32>] [[-page] <Int32>]
[<CommonParameters>]
Get-FreshServiceCatalogItem [[-per_page] <Int32>] [[-page] <Int32>] [<CommonParameters>]
```

### id
Expand Down Expand Up @@ -192,25 +191,6 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -workspace_id
Workspace id filter is applicable only for accounts with Workspaces feature enabled. Providing a Workspace_id will return tickets from a specific workspace.
If the workspace_id(s) parameter is NOT provided, data will only be returned for the Default\Primary Workspace.
If the workspace_id(s) parameter is provided, data will be returned from the specified Workspaces.
If the workspace_id value is 0, data will be returned from all workspaces (the user has access to), with only global level fields.
```yaml
Type: Int32[]
Parameter Sets: default
Aliases:

Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -per_page
Number of records to return per page during pagination.
Maximum of 100 records.
Expand All @@ -221,7 +201,7 @@ Parameter Sets: default
Aliases:

Required: False
Position: 2
Position: 3
Default value: 100
Accept pipeline input: False
Accept wildcard characters: False
Expand All @@ -236,7 +216,7 @@ Parameter Sets: default
Aliases:

Required: False
Position: 3
Position: 4
Default value: 1
Accept pipeline input: False
Accept wildcard characters: False
Expand Down
Loading

0 comments on commit 3fd9686

Please sign in to comment.