mirror of
https://github.com/apache/superset.git
synced 2026-04-20 08:34:37 +00:00
feat: Add Private Google Sheets to dynamic form (#16628)
* first pass private gsheets * made encrypted extra into string, refactored onParametersChanged * private sheets working, credential_info errors * all but test connection working * first pass private gsheets * made encrypted extra into string, refactored onParametersChanged * private sheets working, credential_info errors * all but test connection working * Regenerate package-lock.json Co-authored-by: Beto Dealmeida <roberto@dealmeida.net>
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import json
|
||||
import re
|
||||
import urllib
|
||||
from datetime import datetime
|
||||
@@ -30,7 +31,7 @@ from sqlalchemy.engine.url import make_url
|
||||
from sqlalchemy.sql.expression import ColumnClause
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
from superset.databases.schemas import encrypted_field_properties, EncryptedField
|
||||
from superset.databases.schemas import encrypted_field_properties, EncryptedString
|
||||
from superset.db_engine_specs.base import BaseEngineSpec
|
||||
from superset.db_engine_specs.exceptions import SupersetDBAPIDisconnectionError
|
||||
from superset.errors import SupersetError, SupersetErrorType
|
||||
@@ -69,7 +70,7 @@ ma_plugin = MarshmallowPlugin()
|
||||
|
||||
|
||||
class BigQueryParametersSchema(Schema):
|
||||
credentials_info = EncryptedField(
|
||||
credentials_info = EncryptedString(
|
||||
required=False, description="Contents of BigQuery JSON credentials.",
|
||||
)
|
||||
query = fields.Dict(required=False)
|
||||
@@ -367,11 +368,14 @@ class BigQueryEngineSpec(BaseEngineSpec):
|
||||
query = parameters.get("query", {})
|
||||
query_params = urllib.parse.urlencode(query)
|
||||
|
||||
if encrypted_extra:
|
||||
credentials_info = encrypted_extra.get("credentials_info")
|
||||
if isinstance(credentials_info, str):
|
||||
credentials_info = json.loads(credentials_info)
|
||||
project_id = credentials_info.get("project_id")
|
||||
if not encrypted_extra:
|
||||
raise ValidationError("Missing service credentials")
|
||||
|
||||
project_id = encrypted_extra.get("credentials_info", {}).get("project_id")
|
||||
|
||||
if project_id:
|
||||
return f"{cls.default_driver}://{project_id}/?{query_params}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user