<commit_before>package chronograf

import (
	"bytes"
	"context"
	"encoding/json"
	"errors"
	"fmt"
	"io"
	"net/http"
	"regexp"
	"strconv"
	"strings"
	"time"
	"unicode"
	"unicode/utf8"

	"github.com/influxdata/influxdb/influxql"
)

// Chronograf User Roles
const (
	ViewerRoleName = "Viewer"
	EditorRoleName = "Editor"
	AdminRoleName  = "Admin"
)

// Chronograf User Permissions
var (
	// Read Permissions
	ReadDashboardsPermission = Permission{
		Scope:   "dashboards",
		Name:    "Read Dashboards",
		Allowed: Allowances{"read"},
	}
	ReadSourcesPermission = Permission{
		Scope:   "sources",
		Name:    "Read Sources",
		Allowed: Allowances{"read"},
	}
	ReadRulesPermission = Permission{
		Scope:   "rules",
		Name:    "Read Rules",
		Allowed: Allowances{"read"},
	}
	ReadUsersPermission = Permission{
		Scope:   "users",
		Name:    "Read Users",
		Allowed: Allowances{"read"},
	}

	// Write Permissions
	WriteDashboardsPermission = Permission{
		Scope:   "dashboards",
		Name:    "Write Dashboards",
		Allowed: Allowances{"write"},
	}
	WriteSourcesPermission = Permission{
		Scope:   "sources",
		Name:    "Write Sources",
		Allowed: Allowances{"write"},
	}
	WriteRulesPermission = Permission{
		Scope:   "rules",
		Name:    "Write Rules",
		Allowed: Allowances{"write"},
	}
	WriteUsersPermission = Permission{
		Scope:   "users",
		Name:    "Write Users",
		Allowed: Allowances{"write"},
	}
)

// Default roles for chronograf Users
var (
	ViewerRole = Role{
		Name: ViewerRoleName,
		Permissions: Permissions{
			ReadDashboardsPermission,
			ReadSourcesPermission,
			ReadRulesPermission,
		},
	}

	EditorRole = Role{
		Name: EditorRoleName,
		Permissions: Permissions{
			ReadDashboardsPermission,
			ReadSourcesPermission,
			ReadRulesPermission,
			WriteDashboardsPermission,
			WriteSourcesPermission,
			WriteRulesPermission,
		},
	}

	AdminRole = Role{
		Name: AdminRoleName,
		Permissions: Permissions{
			ReadDashboardsPermission,
			ReadSourcesPermission,
			ReadRulesPermission,
			ReadUsersPermission,
			WriteDashboardsPermission,
			WriteSourcesPermission,
			WriteRulesPermission,
			WriteUsersPermission,
		},
	}
)

// General errors.
const (
	ErrUpstreamTimeout   = Error("request to backend timed out")
	ErrSourceNotFound    = Error("source not found")
	ErrServerNotFound    = Error("server not found")
	ErrLayoutNotFound    = Error("layout not found")
	ErrDashboardNotFound = Error("dashboard not found")
	ErrUserNotFound      = Error("user not found")
	ErrLayoutInvalid     = Error("layout is invalid")
	ErrAlertNotFound     = Error("alert not found")
	ErrAuthentication    = Error("user not authenticated")
	ErrUninitialized     = Error("client uninitialized. Call Open() method")
	ErrInvalidAxis       = Error("Unexpected axis in cell. Valid axes are 'x', 'y', and 'y2'")
)

// Error is a domain error encountered while processing chronograf requests
type Error string

func (e Error) Error() string {
	return string(e)
}

// Logger represents an abstracted structured logging implementation. It<commit_msg>Remove explicit chronograf user permisions<commit_after>package chronograf

import (
	"bytes"
	"context"
	"encoding/json"
	"errors"
	"fmt"
	"io"
	"net/http"
	"regexp"
	"strconv"
	"strings"
	"time"
	"unicode"
	"unicode/utf8"

	"github.com/influxdata/influxdb/influxql"
)

// Chronograf User Roles
const (
	ViewerRoleName = "Viewer"
	EditorRoleName = "Editor"
	AdminRoleName  = "Admin"
)

// Default roles for chronograf Users
var (
	ViewerRole = Role{
		Name: ViewerRoleName,
	}

	EditorRole = Role{
		Name: EditorRoleName,
	}

	AdminRole = Role{
		Name: AdminRoleName,
	}
)

// General errors.
const (
	ErrUpstreamTimeout   = Error("request to backend timed out")
	ErrSourceNotFound    = Error("source not found")
	ErrServerNotFound    = Error("server not found")
	ErrLayoutNotFound    = Error("layout not found")
	ErrDashboardNotFound = Error("dashboard not found")
	ErrUserNotFound      = Error("user not found")
	ErrLayoutInvalid     = Error("layout is invalid")
	ErrAlertNotFound     = Error("alert not found")
	ErrAuthentication    = Error("user not authenticated")
	ErrUninitialized     = Error("client uninitialized. Call Open() method")
	ErrInvalidAxis       = Error("Unexpected axis in cell. Valid axes are 'x', 'y', and 'y2'")
)

// Error is a domain error encountered while processing chronograf requests
type Error string

func (e Error) Error() string {
	return string(e)
}

// Logger represents an abstracted structured logging implementation. It
{'fraction_non_alphanumeric': 0.10846325167037862, 'fraction_numerical': 0.0008908685968819599, 'mean_word_length': 4.2160278745644595, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3458301', 'n_tokens_mistral': 1481, 'n_tokens_neox': 1400, 'n_words': 370}