def get(self): page = request.args.get("page", 1, type=int) page_size = request.args.get("page_size", 25, type=int) groups = {group.id: group for group in models.Group.all(self.current_org)} def serialize_user(user): d = user.to_dict() user_groups = [] for group_id in set(d["groups"]): group = groups.get(group_id) if group: user_groups.append({"id": group.id, "name": group.name}) d["groups"] = user_groups return d search_term = request.args.get("q", "") disabled = request.args.get("disabled", "false") # get enabled users by default disabled = parse_boolean(disabled) pending = request.args.get( "pending", None ) # get both active and pending by default if pending is not None: pending = parse_boolean(pending) users = self.get_users(disabled, pending, search_term) return paginate(users, page, page_size, serialize_user)
def get(self): page = request.args.get('page', 1, type=int) page_size = request.args.get('page_size', 25, type=int) groups = {group.id: group for group in models.Group.all(self.current_org)} def serialize_user(user): d = user.to_dict() user_groups = [] for group_id in set(d['groups']): group = groups.get(group_id) if group: user_groups.append({'id': group.id, 'name': group.name}) d['groups'] = user_groups return d search_term = request.args.get('q', '') disabled = request.args.get('disabled', 'false') # get enabled users by default disabled = parse_boolean(disabled) pending = request.args.get('pending', None) # get both active and pending by default if pending is not None: pending = parse_boolean(pending) users = self.get_users(disabled, pending, search_term) return paginate(users, page, page_size, serialize_user)
def configuration_schema(cls): show_ssl_settings = parse_boolean(os.environ.get('MYSQL_SHOW_SSL_SETTINGS', 'true')) schema = { 'type': 'object', 'properties': cls.configuration_properties, "order": ['host', 'port', 'user', 'passwd', 'db'], 'required': ['db'], 'secret': ['passwd'] } if show_ssl_settings: schema['properties'].update({ 'use_ssl': { 'type': 'boolean', 'title': 'Use SSL' }, 'ssl_cacert': { 'type': 'string', 'title': 'Path to CA certificate file to verify peer against (SSL)' }, 'ssl_cert': { 'type': 'string', 'title': 'Path to client certificate file (SSL)' }, 'ssl_key': { 'type': 'string', 'title': 'Path to private key file (SSL)' }, }) return schema
def configuration_schema(cls): show_ssl_settings = parse_boolean( os.environ.get("MYSQL_SHOW_SSL_SETTINGS", "true")) schema = { "type": "object", "properties": { "host": { "type": "string", "default": "127.0.0.1" }, "user": { "type": "string" }, "passwd": { "type": "string", "title": "Password" }, "db": { "type": "string", "title": "Database name" }, "port": { "type": "number", "default": 3306 }, "initial_query": { "type": "string", "title": "Initial sql query" } }, "order": ["host", "port", "user", "passwd", "db", "initial_query"], "required": ["db"], "secret": ["passwd"], } if show_ssl_settings: schema["properties"].update({ "use_ssl": { "type": "boolean", "title": "Use SSL" }, "ssl_cacert": { "type": "string", "title": "Path to CA certificate file to verify peer against (SSL)", }, "ssl_cert": { "type": "string", "title": "Path to client certificate file (SSL)", }, "ssl_key": { "type": "string", "title": "Path to private key file (SSL)", }, }) return schema
def configuration_schema(cls): show_ssl_settings = parse_boolean( os.environ.get("MYSQL_SHOW_SSL_SETTINGS", "true")) schema = { "type": "object", "properties": { "host": { "type": "string", "title": "服务器", "default": "127.0.0.1" }, "user": { "type": "string", "title": "用户" }, "passwd": { "type": "string", "title": "密码" }, "db": { "type": "string", "title": "数据库" }, "port": { "type": "number", "title": "端口", "default": 3306 }, }, "order": ["host", "port", "user", "passwd", "db"], "required": ["db"], "secret": ["passwd"], } if show_ssl_settings: schema["properties"].update({ "use_ssl": { "type": "boolean", "title": "使用 SSL" }, "ssl_cacert": { "type": "string", "title": "服务器证书文件路径 (SSL)", }, "ssl_cert": { "type": "string", "title": "客户端证书文件路径 (SSL)", }, "ssl_key": { "type": "string", "title": "私钥文件路径 (SSL)", }, }) return schema
def configuration_schema(cls): show_ssl_settings = parse_boolean( os.environ.get('MYSQL_SHOW_SSL_SETTINGS', 'true')) schema = { 'type': 'object', 'properties': { 'host': { 'type': 'string', 'default': '127.0.0.1', 'title': 'Host' }, 'user': { 'type': 'string', 'title': 'User' }, 'passwd': { 'type': 'string', 'title': 'Password' }, 'db': { 'type': 'string', 'title': 'Database Name' }, 'port': { 'type': 'number', 'default': 3306, 'title': 'Port' } }, "order": ['host', 'port', 'user', 'passwd', 'db'], 'required': ['db'], 'secret': ['passwd'] } if show_ssl_settings: schema['properties'].update({ 'use_ssl': { 'type': 'boolean', 'title': 'Use SSL' }, 'ssl_cacert': { 'type': 'string', 'title': 'Path to SSL Cacert' }, 'ssl_cert': { 'type': 'string', 'title': 'Path to SSL Cert' }, 'ssl_key': { 'type': 'string', 'title': 'Path to SSL Key' } }) return schema
def configuration_schema(cls): show_ssl_settings = parse_boolean(os.environ.get('MYSQL_SHOW_SSL_SETTINGS', 'true')) schema = { 'type': 'object', 'properties': { 'host': { 'type': 'string', 'default': '127.0.0.1', "title": zh.get("Host", "Host") }, 'user': { 'type': 'string', "title": zh.get("Username", "Username") }, 'passwd': { 'type': 'string', "title": zh.get("Password", "Password") }, 'db': { 'type': 'string', "title": zh.get("Database Name", "Database Name") }, 'port': { 'type': 'number', 'default': 3306, "title": zh.get("Port", "Port") } }, "order": ['host', 'port', 'user', 'passwd', 'db'], 'required': ['db'], 'secret': ['passwd'] } if show_ssl_settings: schema['properties'].update({ 'use_ssl': { 'type': 'boolean', 'title': zh.get('Use SSL', 'Use SSL') }, 'ssl_cacert': { 'type': 'string', 'title': zh.get('Path to CA certificate file to verify peer against (SSL)', 'Path to CA certificate file to verify peer against (SSL)') }, 'ssl_cert': { 'type': 'string', 'title': zh.get('Path to client certificate file (SSL)', 'Path to client certificate file (SSL)') }, 'ssl_key': { 'type': 'string', 'title': zh.get('Path to private key file (SSL)', 'Path to private key file (SSL)') } }) return schema
def configuration_schema(cls): show_ssl_settings = parse_boolean(os.environ.get('MYSQL_SHOW_SSL_SETTINGS', 'true')) schema = { 'type': 'object', 'properties': { 'host': { 'type': 'string', 'default': '127.0.0.1' }, 'user': { 'type': 'string' }, 'passwd': { 'type': 'string', 'title': 'Password' }, 'db': { 'type': 'string', 'title': 'Database name' }, 'port': { 'type': 'number', 'default': 3306, } }, "order": ['host', 'port', 'user', 'passwd', 'db'], 'required': ['db'], 'secret': ['passwd'] } if show_ssl_settings: schema['properties'].update({ 'use_ssl': { 'type': 'boolean', 'title': 'Use SSL' }, 'ssl_cacert': { 'type': 'string', 'title': 'Path to CA certificate file to verify peer against (SSL)' }, 'ssl_cert': { 'type': 'string', 'title': 'Path to client certificate file (SSL)' }, 'ssl_key': { 'type': 'string', 'title': 'Path to private key file (SSL)' } }) return schema
import json import logging import os from redash.query_runner import * from redash.settings import parse_boolean from redash.utils import JSONEncoder logger = logging.getLogger(__name__) ANNOTATE_QUERY = parse_boolean(os.environ.get('ATHENA_ANNOTATE_QUERY', 'true')) SHOW_EXTRA_SETTINGS = parse_boolean( os.environ.get('ATHENA_SHOW_EXTRA_SETTINGS', 'true')) OPTIONAL_CREDENTIALS = parse_boolean( os.environ.get('ATHENA_OPTIONAL_CREDENTIALS', 'true')) try: import pyathena import boto3 enabled = True except ImportError: enabled = False _TYPE_MAPPINGS = { 'boolean': TYPE_BOOLEAN, 'tinyint': TYPE_INTEGER, 'smallint': TYPE_INTEGER, 'integer': TYPE_INTEGER, 'bigint': TYPE_INTEGER, 'double': TYPE_FLOAT, 'varchar': TYPE_STRING, 'timestamp': TYPE_DATETIME,
import json import os import requests from redash.query_runner import BaseQueryRunner, register from redash.settings import parse_boolean PROXY_URL = os.environ.get('ATHENA_PROXY_URL') ANNOTATE_QUERY = parse_boolean(os.environ.get('ATHENA_ANNOTATE_QUERY', 'true')) class Athena(BaseQueryRunner): noop_query = 'SELECT 1' @classmethod def name(cls): return "Amazon Athena" @classmethod def configuration_schema(cls): return { 'type': 'object', 'properties': { 'region': { 'type': 'string', 'title': 'AWS Region' }, 'aws_access_key': { 'type': 'string',
import json import os import requests from redash.query_runner import BaseQueryRunner, register from redash.settings import parse_boolean PROXY_URL = os.environ.get('ATHENA_PROXY_URL') ANNOTATE_QUERY = parse_boolean(os.environ.get('ATHENA_ANNOTATE_QUERY', 'true')) class Athena(BaseQueryRunner): noop_query = 'SELECT 1' @classmethod def name(cls): return "Amazon Athena" @classmethod def configuration_schema(cls): return { 'type': 'object', 'properties': { 'region': { 'type': 'string', 'title': 'AWS Region' }, 'aws_access_key': { 'type': 'string', 'title': 'AWS Access Key' },
def configuration_schema(cls): show_ssl_settings = parse_boolean(os.environ.get('MYSQL_SHOW_SSL_SETTINGS', 'true')) schema = { 'type': 'object', 'properties': { 'host': { 'type': 'string', 'default': '127.0.0.1' }, 'user': { 'type': 'string' }, 'passwd': { 'type': 'string', 'title': 'Password' }, 'db': { 'type': 'string', 'title': 'Database name' }, 'port': { 'type': 'number', 'default': 3306, }, "toggle_table_string": { "type": "string", "title": "Toggle Table String", "default": "_v", "info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight." } }, "order": ['host', 'port', 'user', 'passwd', 'db'], 'required': ['db'], 'secret': ['passwd'] } if show_ssl_settings: schema['properties'].update({ 'use_ssl': { 'type': 'boolean', 'title': 'Use SSL' }, 'ssl_cacert': { 'type': 'string', 'title': 'Path to CA certificate file to verify peer against (SSL)' }, 'ssl_cert': { 'type': 'string', 'title': 'Path to client certificate file (SSL)' }, 'ssl_key': { 'type': 'string', 'title': 'Path to private key file (SSL)' }, "doc_url": { "type": "string", "title": "Documentation URL", "default": cls.default_doc_url } }) return schema
import logging import os from redash.query_runner import * from redash.settings import parse_boolean from redash.utils import json_dumps, json_loads logger = logging.getLogger(__name__) ANNOTATE_QUERY = parse_boolean(os.environ.get("ATHENA_ANNOTATE_QUERY", "true")) SHOW_EXTRA_SETTINGS = parse_boolean( os.environ.get("ATHENA_SHOW_EXTRA_SETTINGS", "true") ) ASSUME_ROLE = parse_boolean(os.environ.get("ATHENA_ASSUME_ROLE", "false")) OPTIONAL_CREDENTIALS = parse_boolean( os.environ.get("ATHENA_OPTIONAL_CREDENTIALS", "true") ) try: import pyathena import boto3 enabled = True except ImportError: enabled = False _TYPE_MAPPINGS = { "boolean": TYPE_BOOLEAN, "tinyint": TYPE_INTEGER, "smallint": TYPE_INTEGER, "integer": TYPE_INTEGER,
def is_public(self): return settings.parse_boolean(self.settings.get(self.SETTING_IS_PUBLIC, 'false'))
import json import logging import os from redash.query_runner import * from redash.settings import parse_boolean from redash.utils import JSONEncoder logger = logging.getLogger(__name__) ANNOTATE_QUERY = parse_boolean(os.environ.get('ATHENA_ANNOTATE_QUERY', 'true')) SHOW_EXTRA_SETTINGS = parse_boolean(os.environ.get('ATHENA_SHOW_EXTRA_SETTINGS', 'true')) OPTIONAL_CREDENTIALS = parse_boolean(os.environ.get('ATHENA_OPTIONAL_CREDENTIALS', 'true')) try: import pyathena enabled = True except ImportError: enabled = False _TYPE_MAPPINGS = { 'boolean': TYPE_BOOLEAN, 'tinyint': TYPE_INTEGER, 'smallint': TYPE_INTEGER, 'integer': TYPE_INTEGER, 'bigint': TYPE_INTEGER, 'double': TYPE_FLOAT, 'varchar': TYPE_STRING, 'timestamp': TYPE_DATETIME, 'date': TYPE_DATE, 'varbinary': TYPE_STRING,
def configuration_schema(cls): show_ssl_settings = parse_boolean( os.environ.get('MYSQL_SHOW_SSL_SETTINGS', 'true')) schema = { 'type': 'object', 'properties': { 'params': { 'type': 'string', 'default': 'shard1, shard2, shard3', 'title': 'Shard Parameter (Replace on {param})' }, 'show_params': { 'type': 'boolean', 'title': 'Display database names in the first column' }, 'host': { 'type': 'string', 'default': '127.0.0.1' }, 'user': { 'type': 'string' }, 'passwd': { 'type': 'string', 'title': 'Password' }, 'db': { 'type': 'string', 'title': 'Database name', 'default': 'test_{param}' }, 'port': { 'type': 'string', 'default': '3306', } }, "order": ['params', 'show_params', 'host', 'port', 'user', 'passwd', 'db'], 'required': ['db'], 'secret': ['passwd'] } if show_ssl_settings: schema['properties'].update({ 'use_ssl': { 'type': 'boolean', 'title': 'Use SSL' }, 'ssl_cacert': { 'type': 'string', 'title': 'Path to CA certificate file to verify peer against (SSL)' }, 'ssl_cert': { 'type': 'string', 'title': 'Path to client certificate file (SSL)' }, 'ssl_key': { 'type': 'string', 'title': 'Path to private key file (SSL)' } }) return schema
def configuration_schema(cls): show_ssl_settings = parse_boolean( os.environ.get("MYSQL_SHOW_SSL_SETTINGS", "true")) schema = { "type": "object", "properties": { "host": { "type": "string", "default": "127.0.0.1" }, "user": { "type": "string" }, "passwd": { "type": "string", "title": "Password" }, "db": { "type": "string", "title": "Database name" }, "port": { "type": "number", "default": 3306 }, "toggle_table_string": { "type": "string", "title": "Toggle Table String", "default": "_v", "info": "This string will be used to toggle visibility of tables in the schema browser when editing a query in order to remove non-useful tables from sight.", }, "samples": { "type": "boolean", "title": "Show Data Samples" }, }, "order": ["host", "port", "user", "passwd", "db"], "required": ["db"], "secret": ["passwd"], } if show_ssl_settings: schema["properties"].update({ "use_ssl": { "type": "boolean", "title": "Use SSL" }, "ssl_cacert": { "type": "string", "title": "Path to CA certificate file to verify peer against (SSL)", }, "ssl_cert": { "type": "string", "title": "Path to client certificate file (SSL)", }, "ssl_key": { "type": "string", "title": "Path to private key file (SSL)", }, }) return schema