-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from teamviewer/Predefined_Roles
Predefined roles
- Loading branch information
Showing
13 changed files
with
432 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
function ConvertTo-TeamViewerPredefinedRole { | ||
param( | ||
[Parameter(ValueFromPipeline = $true)] | ||
[PSObject] | ||
$InputObject | ||
) | ||
process { | ||
if($InputObject){ | ||
$properties = @{ | ||
PredefinedRoleId = $InputObject.PredefineduserRoleId | ||
} | ||
} | ||
|
||
$result = New-Object -TypeName PSObject -Property $properties | ||
$result.PSObject.TypeNames.Insert(0, 'TeamViewerPS.PredefinedRole') | ||
$result | Add-Member -MemberType ScriptMethod -Name 'ToString' -Force -Value { | ||
Write-Output "[$($this.PredefinedRoleID)]" | ||
} | ||
Write-Output $result | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
function Get-TeamViewerPredefinedRole { | ||
param( | ||
[Parameter(Mandatory = $true)] | ||
[securestring] | ||
$ApiToken | ||
) | ||
|
||
|
||
Begin { | ||
$parameters = @{} | ||
$resourceUri = "$(Get-TeamViewerApiUri)/userroles/predefined" | ||
} | ||
|
||
Process { | ||
$response = Invoke-TeamViewerRestMethod ` | ||
-ApiToken $ApiToken ` | ||
-Uri $resourceUri ` | ||
-Method Get ` | ||
-Body $parameters ` | ||
-WriteErrorTo $PSCmdlet ` | ||
-ErrorAction Stop | ||
Write-Output ($response | ConvertTo-TeamViewerPredefinedRole) | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
function Remove-TeamViewerPredefinedRole { | ||
[CmdletBinding(SupportsShouldProcess = $true)] | ||
param( | ||
[Parameter(Mandatory = $true)] | ||
[securestring] | ||
$ApiToken | ||
) | ||
|
||
|
||
Begin { | ||
$parameters = @{} | ||
$resourceUri = "$(Get-TeamViewerApiUri)/userroles/predefined" | ||
} | ||
|
||
Process { | ||
if ($PSCmdlet.ShouldProcess('PredefinedRole', 'Remove Predefined role')) { | ||
Invoke-TeamViewerRestMethod ` | ||
-ApiToken $ApiToken ` | ||
-Uri $resourceUri ` | ||
-Method DELETE ` | ||
-Body $parameters ` | ||
-WriteErrorTo $PSCmdlet ` | ||
-ErrorAction Stop | ` | ||
Out-Null | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
function Set-TeamViewerPredefinedRole { | ||
[CmdletBinding(SupportsShouldProcess = $true)] | ||
param( | ||
[Parameter(Mandatory = $true)] | ||
[securestring] | ||
$ApiToken, | ||
|
||
[Parameter(Mandatory = $true, ValueFromPipeline = $true )] | ||
[ValidateScript({ $_ | Resolve-TeamViewerUserRoleId })] | ||
[object] | ||
$RoleId | ||
) | ||
|
||
Process { | ||
$Role = $RoleId | Resolve-TeamViewerUserRoleId | ||
$resourceUri = "$(Get-TeamViewerApiUri)/userroles/$Role/predefined" | ||
if ($PSCmdlet.ShouldProcess($Role, 'Set Predefined Role')) { | ||
Invoke-TeamViewerRestMethod ` | ||
-ApiToken $ApiToken ` | ||
-Uri $resourceUri ` | ||
-Method Put ` | ||
-ContentType 'application/json; charset=utf-8' ` | ||
-WriteErrorTo $PSCmdlet ` | ||
-ErrorAction Stop | ` | ||
Out-Null | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
--- | ||
external help file: TeamViewerPS-help.xml | ||
Module Name: TeamViewerPS | ||
online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Get-TeamViewerPredefinedRole.md | ||
schema: 2.0.0 | ||
--- | ||
|
||
# Get-TeamViewerPredefinedRole | ||
|
||
## SYNOPSIS | ||
|
||
Retrieve the Predefine Role in a TeamViewer company. | ||
|
||
## SYNTAX | ||
|
||
```powershell | ||
Get-TeamViewerPredefinedRole [-ApiToken] <SecureString> [<CommonParameters>] | ||
``` | ||
|
||
## DESCRIPTION | ||
|
||
Retrieves the Predefined role among the existing roles in the TeamViewer company associated with the API access token. | ||
|
||
## EXAMPLES | ||
|
||
### Example 1 | ||
|
||
```powershell | ||
PS /> Get-TeamViewerPredefinedRole | ||
``` | ||
|
||
Retrieves the Predefined Role ID. | ||
|
||
### Example 2 | ||
|
||
```powershell | ||
PS /> forEach-Object { Get-TeamViewerUserRole | Where-Object { $_.RoleID -eq (Get-TeamViewerPredefinedRole).PredefinedRoleID } } | ||
``` | ||
|
||
Retrieves the complete information about the predefined role. | ||
|
||
## PARAMETERS | ||
|
||
### -ApiToken | ||
|
||
The TeamViewer API access token. | ||
|
||
```yaml | ||
Type: SecureString | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: True | ||
Position: 0 | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
### CommonParameters | ||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). | ||
## INPUTS | ||
### None | ||
## OUTPUTS | ||
### System.Object | ||
An array of `TeamViewerPS.PredefinedRole` objects. | ||
|
||
## NOTES | ||
|
||
## RELATED LINKS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
--- | ||
external help file: TeamViewerPS-help.xml | ||
Module Name: TeamViewerPS | ||
online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Remove-TeamViewerPredefinedRole.md | ||
schema: 2.0.0 | ||
--- | ||
|
||
# Remove-TeamViewerPredefinedRole | ||
|
||
## SYNOPSIS | ||
|
||
Remove existing Predefined Role. | ||
|
||
## SYNTAX | ||
|
||
```powershell | ||
Remove-TeamViewerPredefinedRole [-ApiToken] <SecureString> [-UserRoleId] <Object> [-WhatIf] [-Confirm] | ||
[<CommonParameters>] | ||
``` | ||
|
||
## DESCRIPTION | ||
|
||
Sets the existing Predefined Role not as Predefined. The role is still available under User Roles. | ||
Existing User assignments to this role are unaffected. | ||
|
||
## EXAMPLES | ||
|
||
### Example 1 | ||
|
||
```powershell | ||
PS /> Remove-TeamViewerPredefinedRole | ||
``` | ||
|
||
Removes the Predefined Role tag from the Existing Predefined Role. | ||
|
||
## PARAMETERS | ||
|
||
### -ApiToken | ||
|
||
The TeamViewer API access token. | ||
|
||
```yaml | ||
Type: SecureString | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: True | ||
Position: 0 | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
### CommonParameters | ||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). | ||
## INPUTS | ||
### None | ||
## OUTPUTS | ||
## NOTES | ||
## RELATED LINKS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
--- | ||
external help file: TeamViewerPS-help.xml | ||
Module Name: TeamViewerPS | ||
online version: https://github.com/teamviewer/TeamViewerPS/blob/main/Docs/Help/Set-TeamViewerPredefinedRole.md | ||
schema: 2.0.0 | ||
--- | ||
|
||
# Set-TeamViewerPredefinedRole | ||
|
||
## SYNOPSIS | ||
|
||
Add Predefined User Role. | ||
|
||
## SYNTAX | ||
|
||
```powershell | ||
Set-TeamViewerPredefinedRole [-ApiToken] <SecureString> [-RoleId] <Object> [<CommonParameters>] | ||
``` | ||
|
||
## DESCRIPTION | ||
|
||
Set an existing role as Predefined Role. It allows user creation with Predefined role assigned to the new user. | ||
|
||
## EXAMPLES | ||
|
||
### Example 1 | ||
|
||
```powershell | ||
PS /> Set-TeamViewerPredefinedRole -RoleId '9b465ea2-2f75-4101-a057-58a81ed0e57b' | ||
``` | ||
|
||
Sets user role with id `9b465ea2-2f75-4101-a057-58a81ed0e57b` as Predefined Role. | ||
|
||
### Example 1 | ||
|
||
```powershell | ||
PS /> Get-TeamViewerUserRole | where-Object { ($_.RoleName -eq 'Test Role') } | Set-TeamViewerPredefinedRole | ||
``` | ||
|
||
Sets user role with name `Test Role` as Predefined Role. | ||
|
||
## PARAMETERS | ||
|
||
### -ApiToken | ||
|
||
The TeamViewer API access token. | ||
|
||
```yaml | ||
Type: SecureString | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: True | ||
Position: 0 | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
### -RoleId | ||
The user role to be set as Predefined Role. | ||
```yaml | ||
Type: Object | ||
Parameter Sets: (All) | ||
Aliases: UserRole | ||
|
||
Required: True | ||
Position: 1 | ||
Default value: None | ||
Accept pipeline input: True | ||
Accept wildcard characters: False | ||
``` | ||
### CommonParameters | ||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). | ||
## INPUTS | ||
### None | ||
## OUTPUTS | ||
## NOTES | ||
## RELATED LINKS |
Oops, something went wrong.