Exemplo n.º 1
0
    def get_connection_form_widgets() -> Dict[str, Any]:
        """Returns connection widgets to add to connection form"""
        from flask_appbuilder.fieldwidgets import BS3PasswordFieldWidget, BS3TextFieldWidget
        from flask_babel import lazy_gettext
        from wtforms import IntegerField, PasswordField, StringField
        from wtforms.validators import NumberRange

        return {
            "extra__google_cloud_platform__project": StringField(
                lazy_gettext('Project Id'), widget=BS3TextFieldWidget()
            ),
            "extra__google_cloud_platform__key_path": StringField(
                lazy_gettext('Keyfile Path'), widget=BS3TextFieldWidget()
            ),
            "extra__google_cloud_platform__keyfile_dict": PasswordField(
                lazy_gettext('Keyfile JSON'), widget=BS3PasswordFieldWidget()
            ),
            "extra__google_cloud_platform__scope": StringField(
                lazy_gettext('Scopes (comma separated)'), widget=BS3TextFieldWidget()
            ),
            "extra__google_cloud_platform__key_secret_name": StringField(
                lazy_gettext('Keyfile Secret Name (in GCP Secret Manager)'), widget=BS3TextFieldWidget()
            ),
            "extra__google_cloud_platform__num_retries": IntegerField(
                lazy_gettext('Number of Retries'),
                validators=[NumberRange(min=0)],
                widget=BS3TextFieldWidget(),
                default=5,
            ),
        }
Exemplo n.º 2
0
    def get_connection_form_widgets() -> Dict[str, Any]:
        """Returns connection widgets to add to connection form"""
        from flask_appbuilder.fieldwidgets import BS3PasswordFieldWidget, BS3TextFieldWidget
        from flask_babel import lazy_gettext
        from wtforms import PasswordField, StringField

        return {
            "extra__snowflake__account":
            StringField(lazy_gettext('Account'), widget=BS3TextFieldWidget()),
            "extra__snowflake__warehouse":
            StringField(lazy_gettext('Warehouse'),
                        widget=BS3TextFieldWidget()),
            "extra__snowflake__database":
            StringField(lazy_gettext('Database'), widget=BS3TextFieldWidget()),
            "extra__snowflake__region":
            StringField(lazy_gettext('Region'), widget=BS3TextFieldWidget()),
            "extra__snowflake__aws_access_key_id":
            StringField(lazy_gettext('AWS Access Key'),
                        widget=BS3TextFieldWidget()),
            "extra__snowflake__aws_secret_access_key":
            PasswordField(lazy_gettext('AWS Secret Key'),
                          widget=BS3PasswordFieldWidget()),
            "extra__snowflake__role":
            StringField(lazy_gettext('Role'), widget=BS3TextFieldWidget()),
        }
Exemplo n.º 3
0
    def get_connection_form_widgets() -> Dict[str, Any]:
        """Returns connection widgets to add to connection form"""
        from flask_appbuilder.fieldwidgets import BS3PasswordFieldWidget, BS3TextFieldWidget
        from flask_babel import lazy_gettext
        from wtforms import PasswordField, StringField

        return {
            "extra__yandexcloud__service_account_json":
            PasswordField(
                lazy_gettext('Service account auth JSON'),
                widget=BS3PasswordFieldWidget(),
                description='Service account auth JSON. Looks like '
                '{"id", "...", "service_account_id": "...", "private_key": "..."}. '
                'Will be used instead of OAuth token and SA JSON file path field if specified.',
            ),
            "extra__yandexcloud__service_account_json_path":
            StringField(
                lazy_gettext('Service account auth JSON file path'),
                widget=BS3TextFieldWidget(),
                description=
                'Service account auth JSON file path. File content looks like '
                '{"id", "...", "service_account_id": "...", "private_key": "..."}. '
                'Will be used instead of OAuth token if specified.',
            ),
            "extra__yandexcloud__oauth":
            PasswordField(
                lazy_gettext('OAuth Token'),
                widget=BS3PasswordFieldWidget(),
                description='User account OAuth token. '
                'Either this or service account JSON must be specified.',
            ),
            "extra__yandexcloud__folder_id":
            StringField(
                lazy_gettext('Default folder ID'),
                widget=BS3TextFieldWidget(),
                description='Optional. This folder will be used '
                'to create all new clusters and nodes by default',
            ),
            "extra__yandexcloud__public_ssh_key":
            StringField(
                lazy_gettext('Public SSH key'),
                widget=BS3TextFieldWidget(),
                description=
                'Optional. This key will be placed to all created Compute nodes'
                'to let you have a root shell there',
            ),
        }
Exemplo n.º 4
0
class ConnectionForm(DynamicForm):
    conn_id = StringField(lazy_gettext('Conn Id'),
                          validators=[validators.DataRequired()],
                          widget=BS3TextFieldWidget())
    conn_type = SelectField(lazy_gettext('Conn Type'),
                            choices=sorted(Connection._types,
                                           key=itemgetter(1)),
                            widget=Select2Widget())
    host = StringField(lazy_gettext('Host'), widget=BS3TextFieldWidget())
    schema = StringField(lazy_gettext('Schema'), widget=BS3TextFieldWidget())
    login = StringField(lazy_gettext('Login'), widget=BS3TextFieldWidget())
    password = PasswordField(lazy_gettext('Password'),
                             widget=BS3PasswordFieldWidget())
    port = IntegerField(lazy_gettext('Port'),
                        validators=[validators.Optional()],
                        widget=BS3TextFieldWidget())
    extra = TextAreaField(lazy_gettext('Extra'),
                          widget=BS3TextAreaFieldWidget())

    # Used to customized the form, the forms elements get rendered
    # and results are stored in the extra field as json. All of these
    # need to be prefixed with extra__ and then the conn_type ___ as in
    # extra__{conn_type}__name. You can also hide form elements and rename
    # others from the connection_form.js file
    extra__jdbc__drv_path = StringField(lazy_gettext('Driver Path'),
                                        widget=BS3TextFieldWidget())
    extra__jdbc__drv_clsname = StringField(lazy_gettext('Driver Class'),
                                           widget=BS3TextFieldWidget())
    extra__google_cloud_platform__project = StringField(
        lazy_gettext('Project Id'), widget=BS3TextFieldWidget())
    extra__google_cloud_platform__key_path = StringField(
        lazy_gettext('Keyfile Path'), widget=BS3TextFieldWidget())
    extra__google_cloud_platform__keyfile_dict = PasswordField(
        lazy_gettext('Keyfile JSON'), widget=BS3PasswordFieldWidget())
    extra__google_cloud_platform__scope = StringField(
        lazy_gettext('Scopes (comma separated)'), widget=BS3TextFieldWidget())
    extra__google_cloud_platform__num_retries = IntegerField(
        lazy_gettext('Number of Retries'),
        validators=[validators.NumberRange(min=0)],
        widget=BS3TextFieldWidget(),
        default=5)
    extra__grpc__auth_type = StringField(lazy_gettext('Grpc Auth Type'),
                                         widget=BS3TextFieldWidget())
    extra__grpc__credential_pem_file = StringField(
        lazy_gettext('Credential Keyfile Path'), widget=BS3TextFieldWidget())
    extra__grpc__scopes = StringField(lazy_gettext('Scopes (comma separated)'),
                                      widget=BS3TextFieldWidget())
Exemplo n.º 5
0
    def get_connection_form_widgets() -> dict:
        """Returns connection widgets to add to connection form"""
        from wtforms import StringField
        from flask_appbuilder.fieldwidgets import BS3PasswordFieldWidget

        return {
            "extra__ewah_facebook__access_token": StringField(
                "Access Token", widget=BS3PasswordFieldWidget()
            ),
        }
    def get_connection_form_widgets() -> Dict[str, Any]:
        """Returns connection widgets to add to connection form"""
        from flask_appbuilder.fieldwidgets import BS3PasswordFieldWidget
        from flask_babel import lazy_gettext
        from wtforms import PasswordField

        return {
            "extra__azure_container_volume__connection_string": PasswordField(
                lazy_gettext('Blob Storage Connection String (optional)'), widget=BS3PasswordFieldWidget()
            ),
        }
Exemplo n.º 7
0
    def get_connection_form_widgets() -> Dict[str, Any]:
        """Returns connection widgets to add to connection form"""
        from flask_appbuilder.fieldwidgets import BS3PasswordFieldWidget, BS3TextFieldWidget
        from flask_babel import lazy_gettext
        from wtforms import PasswordField, StringField

        return {
            "extra__azure_data_explorer__tenant":
            StringField(lazy_gettext('Tenant ID'),
                        widget=BS3TextFieldWidget()),
            "extra__azure_data_explorer__auth_method":
            StringField(lazy_gettext('Authentication Method'),
                        widget=BS3TextFieldWidget()),
            "extra__azure_data_explorer__certificate":
            PasswordField(lazy_gettext('Application PEM Certificate'),
                          widget=BS3PasswordFieldWidget()),
            "extra__azure_data_explorer__thumbprint":
            PasswordField(lazy_gettext('Application Certificate Thumbprint'),
                          widget=BS3PasswordFieldWidget()),
        }
Exemplo n.º 8
0
    def get_connection_form_widgets() -> Dict[str, Any]:
        """Returns connection widgets to add to connection form"""
        from flask_appbuilder.fieldwidgets import BS3PasswordFieldWidget, BS3TextFieldWidget
        from flask_babel import lazy_gettext
        from wtforms import PasswordField, StringField

        return {
            "extra__wasb__connection_string": PasswordField(
                lazy_gettext('Blob Storage Connection String (optional)'), widget=BS3PasswordFieldWidget()
            ),
            "extra__wasb__shared_access_key": PasswordField(
                lazy_gettext('Blob Storage Shared Access Key (optional)'), widget=BS3PasswordFieldWidget()
            ),
            "extra__wasb__tenant_id": StringField(
                lazy_gettext('Tenant Id (Active Directory Auth)'), widget=BS3TextFieldWidget()
            ),
            "extra__wasb__sas_token": PasswordField(
                lazy_gettext('SAS Token (optional)'), widget=BS3PasswordFieldWidget()
            ),
        }
Exemplo n.º 9
0
    def get_connection_form_widgets() -> Dict[str, Any]:
        """Returns connection widgets to add to connection form"""
        from flask_appbuilder.fieldwidgets import BS3PasswordFieldWidget, BS3TextFieldWidget
        from flask_babel import lazy_gettext
        from wtforms import PasswordField, StringField

        return {
            "extra__salesforce__security_token":
            PasswordField(lazy_gettext("Security Token"),
                          widget=BS3PasswordFieldWidget()),
            "extra__salesforce__domain":
            StringField(lazy_gettext("Domain"), widget=BS3TextFieldWidget()),
            "extra__salesforce__consumer_key":
            StringField(lazy_gettext("Consumer Key"),
                        widget=BS3TextFieldWidget()),
            "extra__salesforce__private_key_file_path":
            PasswordField(lazy_gettext("Private Key File Path"),
                          widget=BS3PasswordFieldWidget()),
            "extra__salesforce__private_key":
            PasswordField(lazy_gettext("Private Key"),
                          widget=BS3PasswordFieldWidget()),
            "extra__salesforce__organization_id":
            StringField(lazy_gettext("Organization ID"),
                        widget=BS3TextFieldWidget()),
            "extra__salesforce__instance":
            StringField(lazy_gettext("Instance"), widget=BS3TextFieldWidget()),
            "extra__salesforce__instance_url":
            StringField(lazy_gettext("Instance URL"),
                        widget=BS3TextFieldWidget()),
            "extra__salesforce__proxies":
            StringField(lazy_gettext("Proxies"), widget=BS3TextFieldWidget()),
            "extra__salesforce__version":
            StringField(lazy_gettext("API Version"),
                        widget=BS3TextFieldWidget()),
            "extra__salesforce__client_id":
            StringField(lazy_gettext("Client ID"),
                        widget=BS3TextFieldWidget()),
        }
Exemplo n.º 10
0
    def get_connection_form_widgets() -> dict:
        """Returns connection widgets to add to connection form"""
        from flask_appbuilder.fieldwidgets import (
            BS3TextFieldWidget,
            BS3PasswordFieldWidget,
        )
        from wtforms import StringField, PasswordField
        from ewah.utils.widgets import EWAHTextAreaWidget

        return {
            "extra__ewah_mongodb__conn_style":
            StringField(
                "Connection Style (one of: uri, credentials)",
                default="uri",
                widget=BS3TextFieldWidget(),
            ),
            "extra__ewah_mongodb__tls":
            StringField(
                "SSL / TLS?",
                default="no",
                widget=BS3TextFieldWidget(),
            ),
            "extra__ewah_mongodb__tls_insecure":
            StringField(
                "TLS: Allow insecure connections? Aka 'tlsInsecure'",
                default="no",
                widget=BS3TextFieldWidget(),
            ),
            "extra__ewah_mongodb__ssl_cert":
            StringField(
                "SSL Certificate",
                widget=EWAHTextAreaWidget(rows=12),
            ),
            "extra__ewah_mongodb__ssl_private":
            StringField(
                "SSL Private Key",
                widget=EWAHTextAreaWidget(rows=12),
            ),
            "extra__ewah_mongodb__ssl_password":
            StringField(
                "SSL Certificate / Private Key Password",
                widget=BS3PasswordFieldWidget(),
            ),
            "extra__ewah_mongodb__auth_source":
            StringField("Auth Source", widget=BS3TextFieldWidget()),
            "extra__ewah_mongodb__auth_mechanism":
            StringField("Auth Mechanism", widget=BS3TextFieldWidget()),
            "extra__ewah_mongodb__ssh_conn_id":
            StringField("SSH Connection ID", widget=BS3TextFieldWidget()),
        }
Exemplo n.º 11
0
    def get_connection_form_widgets() -> Dict[str, Any]:
        """Returns connection widgets to add to connection form"""
        from flask_appbuilder.fieldwidgets import BS3PasswordFieldWidget, BS3TextFieldWidget
        from flask_babel import lazy_gettext
        from wtforms import PasswordField, StringField

        return {
            "extra__azure_fileshare__sas_token": PasswordField(
                lazy_gettext('SAS Token (optional)'), widget=BS3PasswordFieldWidget()
            ),
            "extra__azure_fileshare__connection_string": StringField(
                lazy_gettext('Connection String (optional)'), widget=BS3TextFieldWidget()
            ),
            "extra__azure_fileshare__protocol": StringField(
                lazy_gettext('Account URL or token (optional)'), widget=BS3TextFieldWidget()
            ),
        }
Exemplo n.º 12
0
class ConnectionForm(DynamicForm):
    """Form for editing and adding Connection"""

    conn_id = StringField(lazy_gettext('Conn Id'),
                          validators=[InputRequired()],
                          widget=BS3TextFieldWidget())
    description = StringField(lazy_gettext('Description'),
                              widget=BS3TextAreaFieldWidget())
    host = StringField(lazy_gettext('Host'), widget=BS3TextFieldWidget())
    schema = StringField(lazy_gettext('Schema'), widget=BS3TextFieldWidget())
    login = StringField(lazy_gettext('Login'), widget=BS3TextFieldWidget())
    password = PasswordField(lazy_gettext('Password'),
                             widget=BS3PasswordFieldWidget())
    port = IntegerField(lazy_gettext('Port'),
                        validators=[Optional()],
                        widget=BS3TextFieldWidget())
    extra = TextAreaField(lazy_gettext('Extra'),
                          widget=BS3TextAreaFieldWidget())
Exemplo n.º 13
0
class DAGRepoForm(DynamicForm):
    """
    Custom form needed to render the Password field
    """
    name = StringField(lazy_gettext('Repo Name'),
                       widget=BS3TextFieldWidget(),
                       validators=[DataRequired()])
    enabled = BooleanField(lazy_gettext('Repo Enabled'))
    remote_url = StringField(lazy_gettext('Repo URL'),
                             widget=BS3TextFieldWidget(),
                             validators=[DataRequired()])
    remote_branch = StringField(lazy_gettext('Repo Branch'),
                                widget=BS3TextFieldWidget(),
                                validators=[DataRequired()])
    remote_user = StringField(lazy_gettext('Repo Username'),
                              widget=BS3TextFieldWidget(),
                              validators=[Optional()])
    remote_pass = PasswordField(lazy_gettext('Repo Password'),
                                widget=BS3PasswordFieldWidget(),
                                validators=[Optional()])
    interval = IntegerField(lazy_gettext('Refresh Interval'),
                            widget=BS3TextFieldWidget(),
                            validators=[NumberRange(min=0)])
Exemplo n.º 14
0
class Repository_ModelView_Base():
    datamodel = SQLAInterface(Repository)

    label_title = '仓库'
    check_redirect_list_url = '/repository_modelview/list/'
    base_permissions = [
        'can_add', 'can_edit', 'can_delete', 'can_list', 'can_show'
    ]  # 默认为这些
    base_order = ('id', 'desc')
    order_columns = ['id']
    list_columns = ['name', 'hubsecret', 'creator', 'modified']
    show_exclude_columns = ['password']
    add_columns = ['name', 'server', 'user', 'password', 'hubsecret']
    edit_columns = add_columns

    add_form_extra_fields = {
        "password":
        StringField(
            _(datamodel.obj.lab('password')),
            widget=BS3PasswordFieldWidget(
            )  # 传给widget函数的是外层的field对象,以及widget函数的参数
        )
    }
    edit_form_extra_fields = add_form_extra_fields

    # @pysnooper.snoop()
    def set_column(self):
        self.add_form_extra_fields['name'] = StringField(
            _(self.datamodel.obj.lab('name')),
            default=g.user.username + "-",
            widget=BS3TextFieldWidget()  # 传给widget函数的是外层的field对象,以及widget函数的参数
        )

        self.add_form_extra_fields['hubsecret'] = StringField(
            _(self.datamodel.obj.lab('hubsecret')),
            default=g.user.username + "-",
            widget=BS3TextFieldWidget()  # 传给widget函数的是外层的field对象,以及widget函数的参数
        )

    pre_add_get = set_column

    # 直接创建hubsecret
    # @pysnooper.snoop()
    def apply_hubsecret(self, hubsecret):
        from myapp.utils.py.py_k8s import K8s
        all_cluster = conf.get('CLUSTERS', {})
        all_kubeconfig = [
            all_cluster[cluster].get('KUBECONFIG', '')
            for cluster in all_cluster
        ] + ['']
        all_kubeconfig = list(set(all_kubeconfig))
        for kubeconfig in all_kubeconfig:
            k8s = K8s(kubeconfig)
            namespaces = conf.get('HUBSECRET_NAMESPACE')
            for namespace in namespaces:
                k8s.apply_hubsecret(namespace=namespace,
                                    name=hubsecret.hubsecret,
                                    user=hubsecret.user,
                                    password=hubsecret.password,
                                    server=hubsecret.server)

    def post_add(self, item):
        self.apply_hubsecret(item)

    def post_update(self, item):
        self.apply_hubsecret(item)
Exemplo n.º 15
0
class UserDBModelView(UserModelView):
    """
    View that add DB specifics to User view.
    Override to implement your own custom view.
    Then override userdbmodelview property on SecurityManager
    """

    add_form_extra_fields = {
        "password": PasswordField(
            lazy_gettext("Password"),
            description=lazy_gettext("The user's password for authentication"),
            validators=[validators.DataRequired(), PasswordComplexityValidator()],
            widget=BS3PasswordFieldWidget(),
        ),
        "conf_password": PasswordField(
            lazy_gettext("Confirm Password"),
            description=lazy_gettext("Please rewrite the user's password to confirm"),
            validators=[
                validators.DataRequired(),
                EqualTo("password", message=lazy_gettext("Passwords must match")),
            ],
            widget=BS3PasswordFieldWidget(),
        ),
    }

    add_columns = [
        "first_name",
        "last_name",
        "username",
        "active",
        "email",
        "roles",
        "password",
        "conf_password",
    ]

    validators_columns = {"roles": [SelectDataRequired()]}

    @expose("/show/<pk>", methods=["GET"])
    @has_access
    def show(self, pk: Any) -> WerkzeugResponse:
        actions = dict()
        actions["resetpasswords"] = self.actions.get("resetpasswords")
        item = self.datamodel.get(pk, self._base_filters)
        if not item:
            abort(404)
        widgets = self._get_show_widget(pk, item, actions=actions)
        self.update_redirect()
        return self.render_template(
            self.show_template,
            pk=pk,
            title=self.show_title,
            widgets=widgets,
            appbuilder=self.appbuilder,
            related_views=self._related_views,
        )

    @expose("/userinfo/")
    @has_access
    def userinfo(self) -> WerkzeugResponse:
        actions = dict()
        actions["resetmypassword"] = self.actions.get("resetmypassword")
        actions["userinfoedit"] = self.actions.get("userinfoedit")

        item = self.datamodel.get(g.user.id, self._base_filters)
        widgets = self._get_show_widget(
            g.user.id, item, actions=actions, show_fieldsets=self.user_show_fieldsets
        )
        self.update_redirect()
        return self.render_template(
            self.show_template,
            title=self.user_info_title,
            widgets=widgets,
            appbuilder=self.appbuilder,
        )

    @action(
        "resetmypassword",
        lazy_gettext("Reset my password"),
        "",
        "fa-lock",
        multiple=False,
    )
    def resetmypassword(self, item: Any):
        return redirect(
            url_for(self.appbuilder.sm.resetmypasswordview.__name__ + ".this_form_get")
        )

    @action(
        "resetpasswords", lazy_gettext("Reset Password"), "", "fa-lock", multiple=False
    )
    def resetpasswords(self, item: Any) -> WerkzeugResponse:
        return redirect(
            url_for(
                self.appbuilder.sm.resetpasswordview.__name__ + ".this_form_get",
                pk=item.id,
            )
        )

    def pre_update(self, item: Any) -> None:
        item.changed_on = datetime.datetime.now()
        item.changed_by_fk = g.user.id

    def pre_add(self, item: Any) -> None:
        item.password = generate_password_hash(item.password)
Exemplo n.º 16
0
class MyUserDBModelView(UserDBModelView):
    """
        View that add DB specifics to User view.
        Override to implement your own custom view.
        Then override userdbmodelview property on SecurityManager
    """
    login_template = 'login.html'
    label_columns = {'activeformat':'Está activo?','cuilformat':'Cuil'}
    show_fieldsets = [
        (lazy_gettext('User info'),
         {'fields': ['username', 'active', 'roles', 'login_count', 'cuil']}),
        (lazy_gettext('Personal Info'),
         {'fields': ['first_name', 'last_name', 'email'], 'expanded': True}),
        (lazy_gettext('Audit Info'),
         {'fields': ['last_login', 'fail_login_count', 'created_on',
                     'created_by', 'changed_on', 'changed_by'], 'expanded': False}),
    ]

    user_show_fieldsets = [
        (lazy_gettext('Informacion de Usuario'),
         {'fields': ['username', 'active', 'roles', 'login_count', 'cuil']}),
        (lazy_gettext('Informacion Personal'),
         {'fields': ['first_name', 'last_name', 'email'], 'expanded': True}),
    ]

    add_columns = [
        'username',
        'first_name',
        'last_name',
        'email',
        'cuil',
        'password',
        'conf_password'
    ]
    list_columns = [
        'first_name',
        'last_name',
        'username',
        'email',
        'cuilformat',
        'activeformat',
        'roles'
    ]
    edit_columns = [
        'first_name',
        'last_name',
        'username',
        'cuil',
        'active',
        'roles'
    ]

    validators_columns ={
        'cuil':[InputRequired(),cuitvalidatorProveedores]
    }
    add_form_extra_fields = {

        'roles':  QuerySelectMultipleField(
                            'Rol',
                            query_factory=cuil_query,
                            widget=Select2ManyWidget()
                       ),
        "password": PasswordField(
            lazy_gettext("Password"),
            description=lazy_gettext(
                "Utilice una buena política de contraseñas, esta aplicación no verifica esto por usted"
            ),
            validators=[validators.DataRequired()],
            widget=BS3PasswordFieldWidget(),
        ),
        "conf_password": PasswordField(
            lazy_gettext("Confirmar Password"),
            description=lazy_gettext("Vuelva a escribir la contraseña del usuario para confirmar"),
            validators=[
                EqualTo("password", message=lazy_gettext("Passwords deben coincidir"))
            ],
            widget=BS3PasswordFieldWidget(),
        ),
    }

    edit_form_extra_fields = {
        'roles':  QuerySelectMultipleField(
                            'Rol',
                            query_factory=cuil_query,
                            widget=Select2ManyWidget()
                       ),

        'first_name': StringField(
            'Nombre',
            validators=[validators.DataRequired()]
        ),
        'last_name': StringField(
            'Apellidos',
            validators=[validators.DataRequired()]
        ),
        'username': StringField(
            'Nombre de usuario',
            validators=[validators.DataRequired()]
        ),
        'cuil': StringField(
            'Cuil',
            validators=[InputRequired(),cuitvalidatorProveedores]
        )

    }
Exemplo n.º 17
0
class ConnectionForm(DynamicForm):
    conn_id = StringField(lazy_gettext('Conn Id'), widget=BS3TextFieldWidget())
    conn_type = SelectField(lazy_gettext('Conn Type'),
                            choices=sorted(Connection._types,
                                           key=itemgetter(1)),
                            widget=Select2Widget())
    host = StringField(lazy_gettext('Host'), widget=BS3TextFieldWidget())
    schema = StringField(lazy_gettext('Schema'), widget=BS3TextFieldWidget())
    login = StringField(lazy_gettext('Login'), widget=BS3TextFieldWidget())
    password = PasswordField(lazy_gettext('Password'),
                             widget=BS3PasswordFieldWidget())
    port = IntegerField(lazy_gettext('Port'),
                        validators=[validators.Optional()],
                        widget=BS3TextFieldWidget())
    extra = TextAreaField(lazy_gettext('Extra'),
                          widget=BS3TextAreaFieldWidget())

    # Used to customized the form, the forms elements get rendered
    # and results are stored in the extra field as json. All of these
    # need to be prefixed with extra__ and then the conn_type ___ as in
    # extra__{conn_type}__name. You can also hide form elements and rename
    # others from the connection_form.js file
    extra__jdbc__drv_path = StringField(lazy_gettext('Driver Path'),
                                        widget=BS3TextFieldWidget())
    extra__jdbc__drv_clsname = StringField(lazy_gettext('Driver Class'),
                                           widget=BS3TextFieldWidget())
    extra__google_cloud_platform__project = StringField(
        lazy_gettext('Project Id'), widget=BS3TextFieldWidget())
    extra__google_cloud_platform__key_path = StringField(
        lazy_gettext('Keyfile Path'), widget=BS3TextFieldWidget())
    extra__google_cloud_platform__keyfile_dict = PasswordField(
        lazy_gettext('Keyfile JSON'), widget=BS3PasswordFieldWidget())
    extra__google_cloud_platform__scope = StringField(
        lazy_gettext('Scopes (comma separated)'), widget=BS3TextFieldWidget())
    extra__google_cloud_platform__num_retries = IntegerField(
        lazy_gettext('Number of Retries'),
        validators=[validators.NumberRange(min=0)],
        widget=BS3TextFieldWidget(),
        default=5)
    extra__grpc__auth_type = StringField(lazy_gettext('Grpc Auth Type'),
                                         widget=BS3TextFieldWidget())
    extra__grpc__credential_pem_file = StringField(
        lazy_gettext('Credential Keyfile Path'), widget=BS3TextFieldWidget())
    extra__grpc__scopes = StringField(lazy_gettext('Scopes (comma separated)'),
                                      widget=BS3TextFieldWidget())
    extra__yandexcloud__service_account_json = PasswordField(
        lazy_gettext('Service account auth JSON'),
        widget=BS3PasswordFieldWidget(),
        description='Service account auth JSON. Looks like '
        '{"id", "...", "service_account_id": "...", "private_key": "..."}. '
        'Will be used instead of OAuth token and SA JSON file path field if specified.',
    )
    extra__yandexcloud__service_account_json_path = StringField(
        lazy_gettext('Service account auth JSON file path'),
        widget=BS3TextFieldWidget(),
        description=
        'Service account auth JSON file path. File content looks like '
        '{"id", "...", "service_account_id": "...", "private_key": "..."}. '
        'Will be used instead of OAuth token if specified.',
    )
    extra__yandexcloud__oauth = PasswordField(
        lazy_gettext('OAuth Token'),
        widget=BS3PasswordFieldWidget(),
        description=
        'User account OAuth token. Either this or service account JSON must be specified.',
    )
    extra__yandexcloud__folder_id = StringField(
        lazy_gettext('Default folder ID'),
        widget=BS3TextFieldWidget(),
        description=
        'Optional. This folder will be used to create all new clusters and nodes by default',
    )
    extra__yandexcloud__public_ssh_key = StringField(
        lazy_gettext('Public SSH key'),
        widget=BS3TextFieldWidget(),
        description=
        'Optional. This key will be placed to all created Compute nodes'
        'to let you have a root shell there',
    )
    extra__kubernetes__in_cluster = BooleanField(
        lazy_gettext('In cluster configuration'))
    extra__kubernetes__kube_config = StringField(
        lazy_gettext('Kube config (JSON format)'), widget=BS3TextFieldWidget())
    extra__kubernetes__namespace = StringField(lazy_gettext('Namespace'),
                                               widget=BS3TextFieldWidget())