mirror of
https://github.com/apache/superset.git
synced 2026-07-12 09:45:43 +00:00
62 lines
2.4 KiB
Python
62 lines
2.4 KiB
Python
# Licensed to the Apache Software Foundation (ASF) under one
|
|
# or more contributor license agreements. See the NOTICE file
|
|
# distributed with this work for additional information
|
|
# regarding copyright ownership. The ASF licenses this file
|
|
# to you under the Apache License, Version 2.0 (the
|
|
# "License"); you may not use this file except in compliance
|
|
# with the License. You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing,
|
|
# software distributed under the License is distributed on an
|
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
# KIND, either express or implied. See the License for the
|
|
# specific language governing permissions and limitations
|
|
# under the License.
|
|
from __future__ import annotations
|
|
|
|
from typing import NamedTuple
|
|
|
|
from superset.utils.backports import StrEnum
|
|
|
|
|
|
class FixedExecutor(NamedTuple):
|
|
username: str
|
|
|
|
|
|
class ExecutorType(StrEnum):
|
|
"""
|
|
Which user should async tasks be executed as. Used as follows:
|
|
For Alerts & Reports: the "model" refers to the AlertSchedule object
|
|
For Thumbnails: The "model" refers to the Slice or Dashboard object
|
|
"""
|
|
|
|
# A fixed user account. Note that for assigning a fixed user you should use the
|
|
# FixedExecutor class.
|
|
FIXED_USER = "fixed_user"
|
|
# The creator of the model
|
|
CREATOR = "creator"
|
|
# The creator of the model, if they are an editor directly (user-type subject)
|
|
# or indirectly (their role or group is an editor subject)
|
|
CREATOR_EDITOR = "creator_editor"
|
|
# The currently logged in user. In the case of Alerts & Reports, this is always
|
|
# None. For Thumbnails, this is the user that requested the thumbnail
|
|
CURRENT_USER = "current_user"
|
|
# The last modifier of the model
|
|
MODIFIER = "modifier"
|
|
# The last modifier of the model, if they are an editor directly (user-type subject)
|
|
# or indirectly (their role or group is an editor subject)
|
|
MODIFIER_EDITOR = "modifier_editor"
|
|
# An editor of the model. Resolves to a user who is an editor either directly
|
|
# or through role/group membership. Prioritizes: modifier -> creator -> first
|
|
# direct user-type editor -> deterministic user from role/group editors.
|
|
EDITOR = "editor"
|
|
|
|
|
|
Executor = FixedExecutor | ExecutorType
|
|
|
|
|
|
# Alias type to represent the executor that was chosen from a list of Executors
|
|
ChosenExecutor = tuple[ExecutorType, str]
|