Skip to content

Commit

Permalink
add connection permission helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
techBeck03 committed Jan 11, 2021
1 parent e46c37b commit 8ed9a0b
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion permissions.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package guacamole

import "github.com/techBeck03/guacamole-api-client/types"
import (
"fmt"

"github.com/techBeck03/guacamole-api-client/types"
)

const (
// ConnectionPermissionsBasePath defines base path for connection permissions
Expand Down Expand Up @@ -52,3 +56,39 @@ func (c *Client) NewRemoveSystemPermission(permission string) types.GuacPermissi
Value: permission,
}
}

// NewRemoveConnectionPermission creates a formatted guac permission item for removing a user connection permission
func (c *Client) NewRemoveConnectionPermission(identifier string) types.GuacPermissionItem {
return types.GuacPermissionItem{
Op: "remove",
Path: fmt.Sprintf("%s/%s", ConnectionPermissionsBasePath, identifier),
Value: "READ",
}
}

// NewAddConnectionPermission creates a formatted guac permission item for adding a user connection permission
func (c *Client) NewAddConnectionPermission(identifier string) types.GuacPermissionItem {
return types.GuacPermissionItem{
Op: "add",
Path: fmt.Sprintf("%s/%s", ConnectionPermissionsBasePath, identifier),
Value: "READ",
}
}

// NewRemoveConnectionGroupPermission creates a formatted guac permission item for removing a user connection permission
func (c *Client) NewRemoveConnectionGroupPermission(identifier string) types.GuacPermissionItem {
return types.GuacPermissionItem{
Op: "remove",
Path: fmt.Sprintf("%s/%s", ConnectionGroupPermissionsBasePath, identifier),
Value: "READ",
}
}

// NewAddConnectionGroupPermission creates a formatted guac permission item for adding a user connection permission
func (c *Client) NewAddConnectionGroupPermission(identifier string) types.GuacPermissionItem {
return types.GuacPermissionItem{
Op: "add",
Path: fmt.Sprintf("%s/%s", ConnectionGroupPermissionsBasePath, identifier),
Value: "READ",
}
}

0 comments on commit 8ed9a0b

Please sign in to comment.