mage-ai 0.8.97__py3-none-any.whl → 0.8.99__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of mage-ai might be problematic. Click here for more details.
- mage_ai/api/policies/AutocompleteItemPolicy.py +2 -1
- mage_ai/api/policies/BasePolicy.py +2 -2
- mage_ai/api/policies/BlockTemplatePolicy.py +2 -1
- mage_ai/api/policies/ClusterPolicy.py +2 -1
- mage_ai/api/policies/DataProviderPolicy.py +2 -1
- mage_ai/api/policies/EventRulePolicy.py +2 -1
- mage_ai/api/policies/ExtensionOptionPolicy.py +2 -1
- mage_ai/api/policies/FileVersionPolicy.py +2 -1
- mage_ai/api/policies/GitBranchPolicy.py +9 -0
- mage_ai/api/policies/KernelPolicy.py +2 -1
- mage_ai/api/policies/LogPolicy.py +2 -2
- mage_ai/api/policies/OauthPolicy.py +15 -0
- mage_ai/api/policies/OutputPolicy.py +2 -2
- mage_ai/api/policies/PipelinePolicy.py +2 -2
- mage_ai/api/policies/PipelineRunPolicy.py +2 -2
- mage_ai/api/policies/PipelineSchedulePolicy.py +2 -2
- mage_ai/api/policies/PullRequestPolicy.py +64 -0
- mage_ai/api/policies/SessionPolicy.py +4 -1
- mage_ai/api/policies/VariablePolicy.py +2 -2
- mage_ai/api/policies/WidgetPolicy.py +2 -2
- mage_ai/api/policies/WorkspacePolicy.py +3 -3
- mage_ai/api/presenters/PipelinePresenter.py +1 -0
- mage_ai/api/presenters/PullRequestPresenter.py +16 -0
- mage_ai/api/presenters/StatusPresenter.py +2 -0
- mage_ai/api/presenters/SyncPresenter.py +1 -0
- mage_ai/api/presenters/WorkspacePresenter.py +2 -0
- mage_ai/api/resources/GitBranchResource.py +81 -26
- mage_ai/api/resources/OauthResource.py +31 -4
- mage_ai/api/resources/PipelineResource.py +8 -1
- mage_ai/api/resources/PullRequestResource.py +87 -0
- mage_ai/api/resources/RoleResource.py +6 -3
- mage_ai/api/resources/SecretResource.py +2 -5
- mage_ai/api/resources/SessionResource.py +18 -0
- mage_ai/api/resources/StatusResource.py +7 -3
- mage_ai/api/resources/UserResource.py +11 -16
- mage_ai/api/resources/WorkspaceResource.py +83 -53
- mage_ai/authentication/oauth/active_directory.py +17 -0
- mage_ai/authentication/oauth/constants.py +9 -0
- mage_ai/authentication/oauth/utils.py +2 -1
- mage_ai/authentication/oauth2.py +9 -3
- mage_ai/cli/main.py +94 -51
- mage_ai/cluster_manager/kubernetes/workload_manager.py +141 -45
- mage_ai/data_preparation/git/__init__.py +86 -16
- mage_ai/data_preparation/git/api.py +175 -0
- mage_ai/data_preparation/models/block/dbt/utils/__init__.py +49 -14
- mage_ai/data_preparation/models/block/sql/__init__.py +3 -2
- mage_ai/data_preparation/models/pipeline.py +4 -1
- mage_ai/data_preparation/models/pipelines/integration_pipeline.py +7 -3
- mage_ai/data_preparation/preferences.py +4 -2
- mage_ai/data_preparation/repo_manager.py +41 -10
- mage_ai/data_preparation/shared/secrets.py +5 -6
- mage_ai/data_preparation/sync/__init__.py +2 -1
- mage_ai/data_preparation/sync/git_sync.py +2 -5
- mage_ai/data_preparation/templates/utils.py +2 -0
- mage_ai/orchestration/db/models/oauth.py +22 -4
- mage_ai/orchestration/pipeline_scheduler.py +19 -8
- mage_ai/orchestration/queue/process_queue.py +15 -12
- mage_ai/server/api/clusters.py +21 -11
- mage_ai/server/constants.py +1 -1
- mage_ai/server/frontend_dist/404.html +2 -2
- mage_ai/server/frontend_dist/404.html.html +2 -2
- mage_ai/server/frontend_dist/_next/static/WRxCTOtmZhTqQws_7OJZD/_buildManifest.js +1 -0
- mage_ai/server/frontend_dist/_next/static/chunks/{1286-993725c925c56a98.js → 1286-b90bd4b7f8abfc3a.js} +1 -1
- mage_ai/server/frontend_dist/_next/static/chunks/{1424-f475cae42f8a7fca.js → 1424-90c0f66ba2f86b88.js} +1 -1
- mage_ai/server/frontend_dist/_next/static/chunks/3883-c95563b9f60ae526.js +1 -0
- mage_ai/server/frontend_dist/_next/static/chunks/6694-c8f2a68074420906.js +1 -0
- mage_ai/server/frontend_dist/_next/static/chunks/{9350-1ff50f1d7b9ee754.js → 9350-5191c83a8d0cf454.js} +1 -1
- mage_ai/server/frontend_dist/_next/static/chunks/pages/{_app-3527178abd99bc87.js → _app-171846e16d26855a.js} +1 -1
- mage_ai/server/frontend_dist/_next/static/chunks/pages/files-e4e778f8f5e1bf2e.js +1 -0
- mage_ai/server/frontend_dist/_next/static/chunks/pages/manage/settings-c788c1b127999825.js +1 -0
- mage_ai/server/frontend_dist/_next/static/chunks/pages/manage/users/[user]-b4650224a19e8fe6.js +1 -0
- mage_ai/server/frontend_dist/_next/static/chunks/pages/manage/users/new-931eb719e3fae29c.js +1 -0
- mage_ai/server/frontend_dist/_next/static/chunks/pages/manage/users-d3724bde0b186dd9.js +1 -0
- mage_ai/server/frontend_dist/_next/static/chunks/pages/manage-af11f9cf94024ac0.js +1 -0
- mage_ai/server/frontend_dist/_next/static/chunks/pages/pipelines/[pipeline]/backfills/{[...slug]-3ec5eb9562e4bff4.js → [...slug]-34326db259f922d1.js} +1 -1
- mage_ai/server/frontend_dist/_next/static/chunks/pages/pipelines/[pipeline]/edit-503ecb7a72257b79.js +1 -0
- mage_ai/server/frontend_dist/_next/static/chunks/pages/pipelines/[pipeline]/runs/{[run]-7667080098731e30.js → [run]-2994b8ab7862c07b.js} +1 -1
- mage_ai/server/frontend_dist/_next/static/chunks/pages/pipelines/[pipeline]/runs-7b31b851e2544b42.js +1 -0
- mage_ai/server/frontend_dist/_next/static/chunks/pages/pipelines/[pipeline]/triggers/{[...slug]-e18058e13882b20d.js → [...slug]-4445619d4eabe065.js} +1 -1
- mage_ai/server/frontend_dist/_next/static/chunks/pages/pipelines/[pipeline]/{triggers-6854c10d5589d394.js → triggers-b7db0b682fadb840.js} +1 -1
- mage_ai/server/frontend_dist/_next/static/chunks/pages/settings/account/profile-ee0931af3abb55b3.js +1 -0
- mage_ai/server/frontend_dist/_next/static/chunks/pages/settings/workspace/preferences-f8a59d718751be9a.js +1 -0
- mage_ai/server/frontend_dist/_next/static/chunks/pages/settings/workspace/sync-data-90f8830890036eb2.js +1 -0
- mage_ai/server/frontend_dist/_next/static/chunks/pages/settings/workspace/users-9f82673fc438ea83.js +1 -0
- mage_ai/server/frontend_dist/_next/static/chunks/pages/sign-in-a1871b8a537d823c.js +1 -0
- mage_ai/server/frontend_dist/_next/static/chunks/pages/version-control-48859b4e9c846212.js +1 -0
- mage_ai/server/frontend_dist/files.html +2 -2
- mage_ai/server/frontend_dist/index.html +2 -2
- mage_ai/server/frontend_dist/manage/settings.html +24 -0
- mage_ai/server/frontend_dist/manage/users/[user].html +2 -2
- mage_ai/server/frontend_dist/manage/users/new.html +24 -0
- mage_ai/server/frontend_dist/manage/users.html +2 -2
- mage_ai/server/frontend_dist/manage.html +2 -2
- mage_ai/server/frontend_dist/pipeline-runs.html +2 -2
- mage_ai/server/frontend_dist/pipelines/[pipeline]/backfills/[...slug].html +2 -2
- mage_ai/server/frontend_dist/pipelines/[pipeline]/backfills.html +2 -2
- mage_ai/server/frontend_dist/pipelines/[pipeline]/edit.html +2 -2
- mage_ai/server/frontend_dist/pipelines/[pipeline]/logs.html +2 -2
- mage_ai/server/frontend_dist/pipelines/[pipeline]/monitors/block-runs.html +2 -2
- mage_ai/server/frontend_dist/pipelines/[pipeline]/monitors/block-runtime.html +2 -2
- mage_ai/server/frontend_dist/pipelines/[pipeline]/monitors.html +2 -2
- mage_ai/server/frontend_dist/pipelines/[pipeline]/runs/[run].html +2 -2
- mage_ai/server/frontend_dist/pipelines/[pipeline]/runs.html +2 -2
- mage_ai/server/frontend_dist/pipelines/[pipeline]/settings.html +2 -2
- mage_ai/server/frontend_dist/pipelines/[pipeline]/syncs.html +2 -2
- mage_ai/server/frontend_dist/pipelines/[pipeline]/triggers/[...slug].html +2 -2
- mage_ai/server/frontend_dist/pipelines/[pipeline]/triggers.html +2 -2
- mage_ai/server/frontend_dist/pipelines/[pipeline].html +2 -2
- mage_ai/server/frontend_dist/pipelines.html +2 -2
- mage_ai/server/frontend_dist/settings/account/profile.html +2 -2
- mage_ai/server/frontend_dist/settings/workspace/preferences.html +2 -2
- mage_ai/server/frontend_dist/settings/workspace/sync-data.html +2 -2
- mage_ai/server/frontend_dist/settings/workspace/users.html +2 -2
- mage_ai/server/frontend_dist/settings.html +2 -2
- mage_ai/server/frontend_dist/sign-in.html +2 -2
- mage_ai/server/frontend_dist/terminal.html +2 -2
- mage_ai/server/frontend_dist/test.html +2 -2
- mage_ai/server/frontend_dist/triggers.html +2 -2
- mage_ai/server/frontend_dist/version-control.html +2 -2
- mage_ai/server/scheduler_manager.py +7 -2
- mage_ai/server/server.py +37 -3
- mage_ai/server/terminal_server.py +2 -2
- mage_ai/server/websocket_server.py +6 -2
- mage_ai/services/newrelic/__init__.py +21 -0
- mage_ai/settings/__init__.py +32 -0
- mage_ai/shared/hash.py +2 -0
- mage_ai/tests/api/test_utils.py +29 -2
- mage_ai/tests/data_preparation/models/test_pipeline.py +5 -0
- {mage_ai-0.8.97.dist-info → mage_ai-0.8.99.dist-info}/METADATA +8 -3
- {mage_ai-0.8.97.dist-info → mage_ai-0.8.99.dist-info}/RECORD +136 -127
- mage_ai/data_preparation/templates/main/projects/__init__.py +0 -0
- mage_ai/server/frontend_dist/_next/static/YLZRSrQ0aqtl-GGePfsMB/_buildManifest.js +0 -1
- mage_ai/server/frontend_dist/_next/static/chunks/3077-d58f18ed770e5137.js +0 -1
- mage_ai/server/frontend_dist/_next/static/chunks/3714-b676173cd4d8d86c.js +0 -1
- mage_ai/server/frontend_dist/_next/static/chunks/pages/files-82b5409dac9564f4.js +0 -1
- mage_ai/server/frontend_dist/_next/static/chunks/pages/manage/users/[user]-bb6aaa23e92a5add.js +0 -1
- mage_ai/server/frontend_dist/_next/static/chunks/pages/manage/users-c91ee702a4cd7a6f.js +0 -1
- mage_ai/server/frontend_dist/_next/static/chunks/pages/manage-7961010cb0fb9abd.js +0 -1
- mage_ai/server/frontend_dist/_next/static/chunks/pages/pipelines/[pipeline]/edit-7b8ce89f0d717465.js +0 -1
- mage_ai/server/frontend_dist/_next/static/chunks/pages/pipelines/[pipeline]/runs-5bd17a8f3f3d57ef.js +0 -1
- mage_ai/server/frontend_dist/_next/static/chunks/pages/settings/account/profile-7d75e42d5f4936bb.js +0 -1
- mage_ai/server/frontend_dist/_next/static/chunks/pages/settings/workspace/preferences-8220c1200472bf70.js +0 -1
- mage_ai/server/frontend_dist/_next/static/chunks/pages/settings/workspace/sync-data-b602fa9b6ffabd12.js +0 -1
- mage_ai/server/frontend_dist/_next/static/chunks/pages/settings/workspace/users-3f9d5800f268a263.js +0 -1
- mage_ai/server/frontend_dist/_next/static/chunks/pages/sign-in-2925c2c1b0c5559a.js +0 -1
- mage_ai/server/frontend_dist/_next/static/chunks/pages/version-control-5ffc663cfb0ec81e.js +0 -1
- /mage_ai/server/frontend_dist/_next/static/{YLZRSrQ0aqtl-GGePfsMB → WRxCTOtmZhTqQws_7OJZD}/_middlewareManifest.js +0 -0
- /mage_ai/server/frontend_dist/_next/static/{YLZRSrQ0aqtl-GGePfsMB → WRxCTOtmZhTqQws_7OJZD}/_ssgManifest.js +0 -0
- {mage_ai-0.8.97.dist-info → mage_ai-0.8.99.dist-info}/LICENSE +0 -0
- {mage_ai-0.8.97.dist-info → mage_ai-0.8.99.dist-info}/WHEEL +0 -0
- {mage_ai-0.8.97.dist-info → mage_ai-0.8.99.dist-info}/entry_points.txt +0 -0
- {mage_ai-0.8.97.dist-info → mage_ai-0.8.99.dist-info}/top_level.txt +0 -0
|
@@ -2,12 +2,13 @@ from mage_ai.api.oauth_scope import OauthScope
|
|
|
2
2
|
from mage_ai.api.operations import constants
|
|
3
3
|
from mage_ai.api.policies.BasePolicy import BasePolicy
|
|
4
4
|
from mage_ai.api.presenters.AutocompleteItemPresenter import AutocompleteItemPresenter
|
|
5
|
+
from mage_ai.orchestration.db.models.oauth import Permission
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
class AutocompleteItemPolicy(BasePolicy):
|
|
8
9
|
@property
|
|
9
10
|
def entity(self):
|
|
10
|
-
return
|
|
11
|
+
return Permission.Entity.ANY, None
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
AutocompleteItemPolicy.allow_actions([
|
|
@@ -15,7 +15,7 @@ from mage_ai.api.utils import (
|
|
|
15
15
|
has_at_least_viewer_role,
|
|
16
16
|
is_owner,
|
|
17
17
|
)
|
|
18
|
-
from mage_ai.data_preparation.repo_manager import
|
|
18
|
+
from mage_ai.data_preparation.repo_manager import get_project_uuid
|
|
19
19
|
from mage_ai.orchestration.db.models.oauth import Permission
|
|
20
20
|
from mage_ai.services.tracking.metrics import increment
|
|
21
21
|
from mage_ai.settings import DISABLE_NOTEBOOK_EDIT_ACCESS, REQUIRE_USER_AUTHENTICATION
|
|
@@ -43,7 +43,7 @@ class BasePolicy():
|
|
|
43
43
|
|
|
44
44
|
@property
|
|
45
45
|
def entity(self) -> Tuple[Union[Permission.Entity, None], Union[str, None]]:
|
|
46
|
-
return Permission.Entity.PROJECT,
|
|
46
|
+
return Permission.Entity.PROJECT, get_project_uuid()
|
|
47
47
|
|
|
48
48
|
@classmethod
|
|
49
49
|
def action_rule(self, action):
|
|
@@ -2,12 +2,13 @@ from mage_ai.api.oauth_scope import OauthScope
|
|
|
2
2
|
from mage_ai.api.operations import constants
|
|
3
3
|
from mage_ai.api.policies.BasePolicy import BasePolicy
|
|
4
4
|
from mage_ai.api.presenters.BlockTemplatePresenter import BlockTemplatePresenter
|
|
5
|
+
from mage_ai.orchestration.db.models.oauth import Permission
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
class BlockTemplatePolicy(BasePolicy):
|
|
8
9
|
@property
|
|
9
10
|
def entity(self):
|
|
10
|
-
return
|
|
11
|
+
return Permission.Entity.ANY, None
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
BlockTemplatePolicy.allow_actions([
|
|
@@ -2,12 +2,13 @@ from mage_ai.api.oauth_scope import OauthScope
|
|
|
2
2
|
from mage_ai.api.operations import constants
|
|
3
3
|
from mage_ai.api.policies.BasePolicy import BasePolicy
|
|
4
4
|
from mage_ai.api.presenters.ClusterPresenter import ClusterPresenter
|
|
5
|
+
from mage_ai.orchestration.db.models.oauth import Permission
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
class ClusterPolicy(BasePolicy):
|
|
8
9
|
@property
|
|
9
10
|
def entity(self):
|
|
10
|
-
return
|
|
11
|
+
return Permission.Entity.ANY, None
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
ClusterPolicy.allow_actions([
|
|
@@ -2,12 +2,13 @@ from mage_ai.api.oauth_scope import OauthScope
|
|
|
2
2
|
from mage_ai.api.operations import constants
|
|
3
3
|
from mage_ai.api.policies.BasePolicy import BasePolicy
|
|
4
4
|
from mage_ai.api.presenters.DataProviderPresenter import DataProviderPresenter
|
|
5
|
+
from mage_ai.orchestration.db.models.oauth import Permission
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
class DataProviderPolicy(BasePolicy):
|
|
8
9
|
@property
|
|
9
10
|
def entity(self):
|
|
10
|
-
return
|
|
11
|
+
return Permission.Entity.ANY, None
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
DataProviderPolicy.allow_actions([
|
|
@@ -2,12 +2,13 @@ from mage_ai.api.oauth_scope import OauthScope
|
|
|
2
2
|
from mage_ai.api.operations import constants
|
|
3
3
|
from mage_ai.api.policies.BasePolicy import BasePolicy
|
|
4
4
|
from mage_ai.api.presenters.EventRulePresenter import EventRulePresenter
|
|
5
|
+
from mage_ai.orchestration.db.models.oauth import Permission
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
class EventRulePolicy(BasePolicy):
|
|
8
9
|
@property
|
|
9
10
|
def entity(self):
|
|
10
|
-
return
|
|
11
|
+
return Permission.Entity.ANY, None
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
EventRulePolicy.allow_actions([
|
|
@@ -2,12 +2,13 @@ from mage_ai.api.oauth_scope import OauthScope
|
|
|
2
2
|
from mage_ai.api.operations import constants
|
|
3
3
|
from mage_ai.api.policies.BasePolicy import BasePolicy
|
|
4
4
|
from mage_ai.api.presenters.ExtensionOptionPresenter import ExtensionOptionPresenter
|
|
5
|
+
from mage_ai.orchestration.db.models.oauth import Permission
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
class ExtensionOptionPolicy(BasePolicy):
|
|
8
9
|
@property
|
|
9
10
|
def entity(self):
|
|
10
|
-
return
|
|
11
|
+
return Permission.Entity.ANY, None
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
ExtensionOptionPolicy.allow_actions([
|
|
@@ -2,12 +2,13 @@ from mage_ai.api.oauth_scope import OauthScope
|
|
|
2
2
|
from mage_ai.api.operations import constants
|
|
3
3
|
from mage_ai.api.policies.BasePolicy import BasePolicy
|
|
4
4
|
from mage_ai.api.presenters.FileVersionPresenter import FileVersionPresenter
|
|
5
|
+
from mage_ai.orchestration.db.models.oauth import Permission
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
class FileVersionPolicy(BasePolicy):
|
|
8
9
|
@property
|
|
9
10
|
def entity(self):
|
|
10
|
-
return
|
|
11
|
+
return Permission.Entity.ANY, None
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
FileVersionPolicy.allow_actions([
|
|
@@ -53,3 +53,12 @@ GitBranchPolicy.allow_write(GitBranchPresenter.default_attributes + [
|
|
|
53
53
|
], on_action=[
|
|
54
54
|
constants.UPDATE,
|
|
55
55
|
], condition=lambda policy: policy.has_at_least_editor_role())
|
|
56
|
+
|
|
57
|
+
GitBranchPolicy.allow_query([
|
|
58
|
+
'include_remote_branches',
|
|
59
|
+
'repository',
|
|
60
|
+
], scopes=[
|
|
61
|
+
OauthScope.CLIENT_PRIVATE,
|
|
62
|
+
], on_action=[
|
|
63
|
+
constants.LIST,
|
|
64
|
+
], condition=lambda policy: policy.has_at_least_viewer_role())
|
|
@@ -2,12 +2,13 @@ from mage_ai.api.oauth_scope import OauthScope
|
|
|
2
2
|
from mage_ai.api.operations import constants
|
|
3
3
|
from mage_ai.api.policies.BasePolicy import BasePolicy
|
|
4
4
|
from mage_ai.api.presenters.KernelPresenter import KernelPresenter
|
|
5
|
+
from mage_ai.orchestration.db.models.oauth import Permission
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
class KernelPolicy(BasePolicy):
|
|
8
9
|
@property
|
|
9
10
|
def entity(self):
|
|
10
|
-
return
|
|
11
|
+
return Permission.Entity.ANY, None
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
KernelPolicy.allow_actions([
|
|
@@ -3,7 +3,7 @@ from mage_ai.api.operations import constants
|
|
|
3
3
|
from mage_ai.api.policies.BasePolicy import BasePolicy
|
|
4
4
|
from mage_ai.api.presenters.LogPresenter import LogPresenter
|
|
5
5
|
from mage_ai.data_preparation.models.pipeline import Pipeline
|
|
6
|
-
from mage_ai.data_preparation.repo_manager import
|
|
6
|
+
from mage_ai.data_preparation.repo_manager import get_project_uuid
|
|
7
7
|
from mage_ai.orchestration.db.models.oauth import Permission
|
|
8
8
|
from mage_ai.orchestration.db.models.schedules import BlockRun
|
|
9
9
|
|
|
@@ -18,7 +18,7 @@ class LogPolicy(BasePolicy):
|
|
|
18
18
|
elif issubclass(parent_model.__class__, Pipeline):
|
|
19
19
|
return Permission.Entity.PIPELINE, parent_model.uuid
|
|
20
20
|
|
|
21
|
-
return Permission.Entity.PROJECT,
|
|
21
|
+
return Permission.Entity.PROJECT, get_project_uuid()
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
LogPolicy.allow_actions([
|
|
@@ -10,9 +10,16 @@ class OauthPolicy(BasePolicy):
|
|
|
10
10
|
|
|
11
11
|
OauthPolicy.allow_actions([
|
|
12
12
|
constants.CREATE,
|
|
13
|
+
], scopes=[
|
|
14
|
+
OauthScope.CLIENT_PRIVATE,
|
|
15
|
+
], condition=lambda policy: policy.has_at_least_viewer_role())
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
OauthPolicy.allow_actions([
|
|
13
19
|
constants.DETAIL,
|
|
14
20
|
], scopes=[
|
|
15
21
|
OauthScope.CLIENT_PRIVATE,
|
|
22
|
+
OauthScope.CLIENT_PUBLIC,
|
|
16
23
|
], condition=lambda policy: policy.has_at_least_viewer_role())
|
|
17
24
|
|
|
18
25
|
|
|
@@ -20,6 +27,13 @@ OauthPolicy.allow_read(OauthPresenter.default_attributes, scopes=[
|
|
|
20
27
|
OauthScope.CLIENT_PRIVATE,
|
|
21
28
|
], on_action=[
|
|
22
29
|
constants.CREATE,
|
|
30
|
+
], condition=lambda policy: policy.has_at_least_viewer_role())
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
OauthPolicy.allow_read(OauthPresenter.default_attributes, scopes=[
|
|
34
|
+
OauthScope.CLIENT_PRIVATE,
|
|
35
|
+
OauthScope.CLIENT_PUBLIC,
|
|
36
|
+
], on_action=[
|
|
23
37
|
constants.DETAIL,
|
|
24
38
|
], condition=lambda policy: policy.has_at_least_viewer_role())
|
|
25
39
|
|
|
@@ -40,4 +54,5 @@ OauthPolicy.allow_query([
|
|
|
40
54
|
constants.DETAIL,
|
|
41
55
|
], scopes=[
|
|
42
56
|
OauthScope.CLIENT_PRIVATE,
|
|
57
|
+
OauthScope.CLIENT_PUBLIC,
|
|
43
58
|
], condition=lambda policy: policy.has_at_least_viewer_role())
|
|
@@ -2,7 +2,7 @@ from mage_ai.api.oauth_scope import OauthScope
|
|
|
2
2
|
from mage_ai.api.operations import constants
|
|
3
3
|
from mage_ai.api.policies.BasePolicy import BasePolicy
|
|
4
4
|
from mage_ai.api.presenters.OutputPresenter import OutputPresenter
|
|
5
|
-
from mage_ai.data_preparation.repo_manager import
|
|
5
|
+
from mage_ai.data_preparation.repo_manager import get_project_uuid
|
|
6
6
|
from mage_ai.orchestration.db.models.oauth import Permission
|
|
7
7
|
from mage_ai.orchestration.db.models.schedules import BlockRun
|
|
8
8
|
|
|
@@ -15,7 +15,7 @@ class OutputPolicy(BasePolicy):
|
|
|
15
15
|
if type(parent_model) is BlockRun:
|
|
16
16
|
return Permission.Entity.PIPELINE, parent_model.pipeline_run.pipeline_uuid
|
|
17
17
|
|
|
18
|
-
return Permission.Entity.PROJECT,
|
|
18
|
+
return Permission.Entity.PROJECT, get_project_uuid()
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
OutputPolicy.allow_actions([
|
|
@@ -2,7 +2,7 @@ from mage_ai.api.oauth_scope import OauthScope
|
|
|
2
2
|
from mage_ai.api.operations import constants
|
|
3
3
|
from mage_ai.api.policies.BasePolicy import BasePolicy
|
|
4
4
|
from mage_ai.api.presenters.PipelinePresenter import PipelinePresenter
|
|
5
|
-
from mage_ai.data_preparation.repo_manager import
|
|
5
|
+
from mage_ai.data_preparation.repo_manager import get_project_uuid
|
|
6
6
|
from mage_ai.orchestration.db.models.oauth import Permission
|
|
7
7
|
|
|
8
8
|
|
|
@@ -12,7 +12,7 @@ class PipelinePolicy(BasePolicy):
|
|
|
12
12
|
if self.resource and self.resource.model:
|
|
13
13
|
return Permission.Entity.PIPELINE, self.resource.model.uuid
|
|
14
14
|
|
|
15
|
-
return Permission.Entity.PROJECT,
|
|
15
|
+
return Permission.Entity.PROJECT, get_project_uuid()
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
PipelinePolicy.allow_actions([
|
|
@@ -2,7 +2,7 @@ from mage_ai.api.oauth_scope import OauthScope
|
|
|
2
2
|
from mage_ai.api.operations import constants
|
|
3
3
|
from mage_ai.api.policies.BasePolicy import BasePolicy
|
|
4
4
|
from mage_ai.api.presenters.PipelineRunPresenter import PipelineRunPresenter
|
|
5
|
-
from mage_ai.data_preparation.repo_manager import
|
|
5
|
+
from mage_ai.data_preparation.repo_manager import get_project_uuid
|
|
6
6
|
from mage_ai.orchestration.db.models.oauth import Permission
|
|
7
7
|
|
|
8
8
|
|
|
@@ -19,7 +19,7 @@ class PipelineRunPolicy(BasePolicy):
|
|
|
19
19
|
if self.resource and self.resource.model:
|
|
20
20
|
return Permission.Entity.PIPELINE, self.resource.model.pipeline_uuid
|
|
21
21
|
|
|
22
|
-
return Permission.Entity.PROJECT,
|
|
22
|
+
return Permission.Entity.PROJECT, get_project_uuid()
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
PipelineRunPolicy.allow_actions([
|
|
@@ -2,7 +2,7 @@ from mage_ai.api.oauth_scope import OauthScope
|
|
|
2
2
|
from mage_ai.api.operations import constants
|
|
3
3
|
from mage_ai.api.policies.BasePolicy import BasePolicy
|
|
4
4
|
from mage_ai.api.presenters.PipelineSchedulePresenter import PipelineSchedulePresenter
|
|
5
|
-
from mage_ai.data_preparation.repo_manager import
|
|
5
|
+
from mage_ai.data_preparation.repo_manager import get_project_uuid
|
|
6
6
|
from mage_ai.orchestration.db.models.oauth import Permission
|
|
7
7
|
|
|
8
8
|
|
|
@@ -12,7 +12,7 @@ class PipelineSchedulePolicy(BasePolicy):
|
|
|
12
12
|
if self.resource and self.resource.model:
|
|
13
13
|
return Permission.Entity.PIPELINE, self.resource.model.pipeline_uuid
|
|
14
14
|
|
|
15
|
-
return Permission.Entity.PROJECT,
|
|
15
|
+
return Permission.Entity.PROJECT, get_project_uuid()
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
PipelineSchedulePolicy.allow_actions([
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
from mage_ai.api.oauth_scope import OauthScope
|
|
2
|
+
from mage_ai.api.operations import constants
|
|
3
|
+
from mage_ai.api.policies.BasePolicy import BasePolicy
|
|
4
|
+
from mage_ai.api.presenters.PullRequestPresenter import PullRequestPresenter
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class PullRequestPolicy(BasePolicy):
|
|
8
|
+
pass
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
PullRequestPolicy.allow_actions([
|
|
12
|
+
constants.DETAIL,
|
|
13
|
+
constants.LIST,
|
|
14
|
+
], scopes=[
|
|
15
|
+
OauthScope.CLIENT_PRIVATE,
|
|
16
|
+
], condition=lambda policy: policy.has_at_least_viewer_role())
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
PullRequestPolicy.allow_actions([
|
|
20
|
+
constants.DETAIL,
|
|
21
|
+
constants.LIST,
|
|
22
|
+
constants.CREATE,
|
|
23
|
+
], scopes=[
|
|
24
|
+
OauthScope.CLIENT_PRIVATE,
|
|
25
|
+
], condition=lambda policy: policy.has_at_least_editor_role())
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
PullRequestPolicy.allow_read(PullRequestPresenter.default_attributes + [
|
|
29
|
+
], scopes=[
|
|
30
|
+
OauthScope.CLIENT_PRIVATE
|
|
31
|
+
], on_action=[
|
|
32
|
+
constants.DETAIL,
|
|
33
|
+
constants.LIST,
|
|
34
|
+
], condition=lambda policy: policy.has_at_least_viewer_role())
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
PullRequestPolicy.allow_read(PullRequestPresenter.default_attributes + [
|
|
38
|
+
], scopes=[
|
|
39
|
+
OauthScope.CLIENT_PRIVATE
|
|
40
|
+
], on_action=[
|
|
41
|
+
constants.CREATE,
|
|
42
|
+
], condition=lambda policy: policy.has_at_least_editor_role())
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
PullRequestPolicy.allow_write([
|
|
46
|
+
'base_branch',
|
|
47
|
+
'body',
|
|
48
|
+
'compare_branch',
|
|
49
|
+
'repository',
|
|
50
|
+
'title',
|
|
51
|
+
], scopes=[
|
|
52
|
+
OauthScope.CLIENT_PRIVATE
|
|
53
|
+
], on_action=[
|
|
54
|
+
constants.CREATE,
|
|
55
|
+
], condition=lambda policy: policy.has_at_least_editor_role())
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
PullRequestPolicy.allow_query([
|
|
59
|
+
'repository',
|
|
60
|
+
], scopes=[
|
|
61
|
+
OauthScope.CLIENT_PRIVATE,
|
|
62
|
+
], on_action=[
|
|
63
|
+
constants.LIST,
|
|
64
|
+
], condition=lambda policy: policy.has_at_least_viewer_role())
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
from mage_ai.api.oauth_scope import OauthScope
|
|
2
2
|
from mage_ai.api.operations import constants
|
|
3
3
|
from mage_ai.api.policies.BasePolicy import BasePolicy
|
|
4
|
+
from mage_ai.orchestration.db.models.oauth import Permission
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
class SessionPolicy(BasePolicy):
|
|
7
8
|
@property
|
|
8
9
|
def entity(self):
|
|
9
|
-
return
|
|
10
|
+
return Permission.Entity.ANY, None
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
SessionPolicy.allow_actions([
|
|
@@ -45,6 +46,8 @@ SessionPolicy.allow_write([
|
|
|
45
46
|
'email',
|
|
46
47
|
'password',
|
|
47
48
|
'username',
|
|
49
|
+
'token',
|
|
50
|
+
'provider',
|
|
48
51
|
], scopes=[
|
|
49
52
|
OauthScope.CLIENT_PUBLIC,
|
|
50
53
|
], on_action=[
|
|
@@ -2,7 +2,7 @@ from mage_ai.api.oauth_scope import OauthScope
|
|
|
2
2
|
from mage_ai.api.operations import constants
|
|
3
3
|
from mage_ai.api.policies.BasePolicy import BasePolicy
|
|
4
4
|
from mage_ai.api.presenters.VariablePresenter import VariablePresenter
|
|
5
|
-
from mage_ai.data_preparation.repo_manager import
|
|
5
|
+
from mage_ai.data_preparation.repo_manager import get_project_uuid
|
|
6
6
|
from mage_ai.orchestration.db.models.oauth import Permission
|
|
7
7
|
|
|
8
8
|
|
|
@@ -13,7 +13,7 @@ class VariablePolicy(BasePolicy):
|
|
|
13
13
|
if parent_model:
|
|
14
14
|
return Permission.Entity.PIPELINE, parent_model.uuid
|
|
15
15
|
|
|
16
|
-
return Permission.Entity.PROJECT,
|
|
16
|
+
return Permission.Entity.PROJECT, get_project_uuid()
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
VariablePolicy.allow_actions([
|
|
@@ -2,7 +2,7 @@ from mage_ai.api.oauth_scope import OauthScope
|
|
|
2
2
|
from mage_ai.api.operations import constants
|
|
3
3
|
from mage_ai.api.policies.BasePolicy import BasePolicy
|
|
4
4
|
from mage_ai.api.presenters.WidgetPresenter import WidgetPresenter
|
|
5
|
-
from mage_ai.data_preparation.repo_manager import
|
|
5
|
+
from mage_ai.data_preparation.repo_manager import get_project_uuid
|
|
6
6
|
from mage_ai.orchestration.db.models.oauth import Permission
|
|
7
7
|
|
|
8
8
|
|
|
@@ -13,7 +13,7 @@ class WidgetPolicy(BasePolicy):
|
|
|
13
13
|
if parent_model:
|
|
14
14
|
return Permission.Entity.PIPELINE, parent_model.uuid
|
|
15
15
|
|
|
16
|
-
return Permission.Entity.PROJECT,
|
|
16
|
+
return Permission.Entity.PROJECT, get_project_uuid()
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
WidgetPolicy.allow_actions([
|
|
@@ -33,9 +33,7 @@ WorkspacePolicy.allow_read(WorkspacePresenter.default_attributes, scopes=[
|
|
|
33
33
|
constants.LIST,
|
|
34
34
|
], condition=lambda policy: policy.has_at_least_admin_role())
|
|
35
35
|
|
|
36
|
-
WorkspacePolicy.allow_read(WorkspacePresenter.default_attributes
|
|
37
|
-
'success',
|
|
38
|
-
], scopes=[
|
|
36
|
+
WorkspacePolicy.allow_read(WorkspacePresenter.default_attributes, scopes=[
|
|
39
37
|
OauthScope.CLIENT_PRIVATE,
|
|
40
38
|
], on_action=[
|
|
41
39
|
constants.CREATE,
|
|
@@ -50,6 +48,8 @@ WorkspacePolicy.allow_write([
|
|
|
50
48
|
'storage_class_name',
|
|
51
49
|
'service_account_name',
|
|
52
50
|
'container_config',
|
|
51
|
+
'storage_access_mode',
|
|
52
|
+
'storage_request_size',
|
|
53
53
|
'cluster_name',
|
|
54
54
|
'task_definition',
|
|
55
55
|
'container_name',
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from mage_ai.api.presenters.BasePresenter import BasePresenter
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class PullRequestPresenter(BasePresenter):
|
|
5
|
+
default_attributes = [
|
|
6
|
+
'body',
|
|
7
|
+
'created_at',
|
|
8
|
+
'id',
|
|
9
|
+
'is_merged',
|
|
10
|
+
'last_modified',
|
|
11
|
+
'merged',
|
|
12
|
+
'state',
|
|
13
|
+
'title',
|
|
14
|
+
'url',
|
|
15
|
+
'user',
|
|
16
|
+
]
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from github import Auth, Github
|
|
1
3
|
from mage_ai.api.errors import ApiError
|
|
2
4
|
from mage_ai.api.resources.GenericResource import GenericResource
|
|
3
5
|
from mage_ai.data_preparation.git import Git
|
|
6
|
+
from mage_ai.data_preparation.git import api
|
|
4
7
|
from mage_ai.data_preparation.preferences import get_preferences
|
|
5
8
|
from typing import Dict, List
|
|
6
|
-
import os
|
|
7
9
|
|
|
8
10
|
|
|
9
11
|
def build_file_object(obj):
|
|
@@ -21,9 +23,34 @@ def build_file_object(obj):
|
|
|
21
23
|
class GitBranchResource(GenericResource):
|
|
22
24
|
@classmethod
|
|
23
25
|
def collection(self, query, meta, user, **kwargs):
|
|
24
|
-
|
|
26
|
+
arr = []
|
|
27
|
+
|
|
28
|
+
include_remote_branches = query.get('include_remote_branches', None)
|
|
29
|
+
if include_remote_branches:
|
|
30
|
+
include_remote_branches = include_remote_branches[0]
|
|
31
|
+
|
|
32
|
+
repository = query.get('repository', None)
|
|
33
|
+
if repository:
|
|
34
|
+
repository = repository[0]
|
|
35
|
+
|
|
36
|
+
access_token = api.get_access_token_for_user(user)
|
|
37
|
+
if access_token:
|
|
38
|
+
auth = Auth.Token(access_token.token)
|
|
39
|
+
g = Github(auth=auth)
|
|
40
|
+
repo = g.get_repo(repository)
|
|
41
|
+
branches = repo.get_branches()
|
|
42
|
+
|
|
43
|
+
for branch in branches:
|
|
44
|
+
arr.append(dict(name=branch.name))
|
|
45
|
+
else:
|
|
46
|
+
git_manager = Git.get_manager(user=user)
|
|
47
|
+
arr += [dict(name=branch) for branch in git_manager.branches]
|
|
48
|
+
|
|
49
|
+
if include_remote_branches:
|
|
50
|
+
pass
|
|
51
|
+
|
|
25
52
|
return self.build_result_set(
|
|
26
|
-
|
|
53
|
+
arr,
|
|
27
54
|
user,
|
|
28
55
|
**kwargs,
|
|
29
56
|
)
|
|
@@ -112,38 +139,66 @@ class GitBranchResource(GenericResource):
|
|
|
112
139
|
push = payload.get('push', None)
|
|
113
140
|
|
|
114
141
|
if push and 'remote' in push and 'branch' in push:
|
|
115
|
-
import
|
|
142
|
+
from git.exc import GitCommandError
|
|
116
143
|
|
|
117
144
|
try:
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
push['
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
145
|
+
access_token = api.get_access_token_for_user(self.current_user)
|
|
146
|
+
if access_token:
|
|
147
|
+
remote = git_manager.repo.remotes[push['remote']]
|
|
148
|
+
custom_progress = api.push(
|
|
149
|
+
remote.name,
|
|
150
|
+
[url for url in remote.urls][0],
|
|
151
|
+
push['branch'],
|
|
152
|
+
access_token.token,
|
|
153
|
+
)
|
|
154
|
+
if custom_progress.other_lines:
|
|
155
|
+
lines = custom_progress.other_lines
|
|
156
|
+
if type(lines) is list:
|
|
157
|
+
lines = '\n'.join(lines)
|
|
158
|
+
self.model['progress'] = lines
|
|
159
|
+
else:
|
|
160
|
+
self.model['error'] = \
|
|
161
|
+
'Please authenticate with GitHub before trying to push.'
|
|
162
|
+
except GitCommandError as err:
|
|
128
163
|
self.model['error'] = str(err)
|
|
129
164
|
else:
|
|
130
165
|
git_manager.push()
|
|
131
166
|
elif action_type == 'pull':
|
|
132
167
|
pull = payload.get('pull', None)
|
|
133
168
|
if pull and 'remote' in pull:
|
|
134
|
-
import
|
|
169
|
+
from git.exc import GitCommandError
|
|
135
170
|
|
|
136
171
|
try:
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
172
|
+
access_token = api.get_access_token_for_user(self.current_user)
|
|
173
|
+
if access_token:
|
|
174
|
+
branch_name = payload.get('branch')
|
|
175
|
+
remote = git_manager.repo.remotes[pull['remote']]
|
|
176
|
+
url = list(remote.urls)[0]
|
|
177
|
+
|
|
178
|
+
custom_progress = None
|
|
179
|
+
if branch_name:
|
|
180
|
+
custom_progress = api.pull(
|
|
181
|
+
remote.name,
|
|
182
|
+
url,
|
|
183
|
+
pull.get('branch'),
|
|
184
|
+
access_token.token,
|
|
185
|
+
)
|
|
186
|
+
else:
|
|
187
|
+
custom_progress = api.fetch(
|
|
188
|
+
remote.name,
|
|
189
|
+
url,
|
|
190
|
+
access_token.token,
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
if custom_progress and custom_progress.other_lines:
|
|
194
|
+
lines = custom_progress.other_lines
|
|
195
|
+
if type(lines) is list:
|
|
196
|
+
lines = '\n'.join(lines)
|
|
197
|
+
self.model['progress'] = lines
|
|
198
|
+
else:
|
|
199
|
+
self.model['error'] = \
|
|
200
|
+
'Please authenticate with GitHub before trying to pull.'
|
|
201
|
+
except GitCommandError as err:
|
|
147
202
|
self.model['error'] = str(err)
|
|
148
203
|
else:
|
|
149
204
|
git_manager.pull()
|
|
@@ -223,4 +278,4 @@ class GitBranchResource(GenericResource):
|
|
|
223
278
|
|
|
224
279
|
def remotes(self, limit: int = None) -> List[Dict]:
|
|
225
280
|
git_manager = Git.get_manager(user=self.current_user)
|
|
226
|
-
return git_manager.remotes(limit=limit)
|
|
281
|
+
return git_manager.remotes(limit=limit, user=self.current_user)
|