From 14a0fee70a130d3add4cf21ed5ec46f8db040cd0 Mon Sep 17 00:00:00 2001 From: nl_0 Date: Thu, 19 Dec 2024 13:12:06 +0100 Subject: [PATCH] quilt3.admin.tabulator: get/set open query --- api/python/quilt3-admin/queries.graphql | 14 ++++++ .../quilt3/admin/_graphql_client/__init__.py | 11 +++++ .../quilt3/admin/_graphql_client/client.py | 46 +++++++++++++++++++ .../tabulator_get_open_query.py | 17 +++++++ .../tabulator_set_open_query.py | 24 ++++++++++ api/python/quilt3/admin/tabulator.py | 14 ++++++ 6 files changed, 126 insertions(+) create mode 100644 api/python/quilt3/admin/_graphql_client/tabulator_get_open_query.py create mode 100644 api/python/quilt3/admin/_graphql_client/tabulator_set_open_query.py diff --git a/api/python/quilt3-admin/queries.graphql b/api/python/quilt3-admin/queries.graphql index 0fb50433554..872fef0a6c3 100644 --- a/api/python/quilt3-admin/queries.graphql +++ b/api/python/quilt3-admin/queries.graphql @@ -241,3 +241,17 @@ mutation bucketTabulatorTableRename($bucketName: String!, $tableName: String!, $ } } } + +query tabulatorGetOpenQuery { + admin { + tabulatorOpenQuery + } +} + +mutation tabulatorSetOpenQuery($enabled: Boolean!) { + admin { + setTabulatorOpenQuery(enabled: $enabled) { + tabulatorOpenQuery + } + } +} diff --git a/api/python/quilt3/admin/_graphql_client/__init__.py b/api/python/quilt3/admin/_graphql_client/__init__.py index 717f43537df..30a00d0566f 100644 --- a/api/python/quilt3/admin/_graphql_client/__init__.py +++ b/api/python/quilt3/admin/_graphql_client/__init__.py @@ -50,6 +50,12 @@ SsoConfigSetAdminSetSsoConfigOperationError, SsoConfigSetAdminSetSsoConfigSsoConfig, ) +from .tabulator_get_open_query import TabulatorGetOpenQuery, TabulatorGetOpenQueryAdmin +from .tabulator_set_open_query import ( + TabulatorSetOpenQuery, + TabulatorSetOpenQueryAdmin, + TabulatorSetOpenQueryAdminSetTabulatorOpenQuery, +) from .users_add_roles import ( UsersAddRoles, UsersAddRolesAdmin, @@ -172,6 +178,11 @@ "SsoConfigSetAdminSetSsoConfigInvalidInput", "SsoConfigSetAdminSetSsoConfigOperationError", "SsoConfigSetAdminSetSsoConfigSsoConfig", + "TabulatorGetOpenQuery", + "TabulatorGetOpenQueryAdmin", + "TabulatorSetOpenQuery", + "TabulatorSetOpenQueryAdmin", + "TabulatorSetOpenQueryAdminSetTabulatorOpenQuery", "UnmanagedRoleSelection", "Upload", "UserInput", diff --git a/api/python/quilt3/admin/_graphql_client/client.py b/api/python/quilt3/admin/_graphql_client/client.py index e4ef1dac7e7..857225e1937 100644 --- a/api/python/quilt3/admin/_graphql_client/client.py +++ b/api/python/quilt3/admin/_graphql_client/client.py @@ -34,6 +34,8 @@ SsoConfigSetAdminSetSsoConfigOperationError, SsoConfigSetAdminSetSsoConfigSsoConfig, ) +from .tabulator_get_open_query import TabulatorGetOpenQuery +from .tabulator_set_open_query import TabulatorSetOpenQuery from .users_add_roles import UsersAddRoles, UsersAddRolesAdminUserMutate from .users_create import ( UsersCreate, @@ -1164,3 +1166,47 @@ def bucket_tabulator_table_rename( return BucketTabulatorTableRename.model_validate( data ).admin.bucket_rename_tabulator_table + + def tabulator_get_open_query(self, **kwargs: Any) -> bool: + query = gql( + """ + query tabulatorGetOpenQuery { + admin { + tabulatorOpenQuery + } + } + """ + ) + variables: Dict[str, object] = {} + response = self.execute( + query=query, + operation_name="tabulatorGetOpenQuery", + variables=variables, + **kwargs + ) + data = self.get_data(response) + return TabulatorGetOpenQuery.model_validate(data).admin.tabulator_open_query + + def tabulator_set_open_query(self, enabled: bool, **kwargs: Any) -> bool: + query = gql( + """ + mutation tabulatorSetOpenQuery($enabled: Boolean!) { + admin { + setTabulatorOpenQuery(enabled: $enabled) { + tabulatorOpenQuery + } + } + } + """ + ) + variables: Dict[str, object] = {"enabled": enabled} + response = self.execute( + query=query, + operation_name="tabulatorSetOpenQuery", + variables=variables, + **kwargs + ) + data = self.get_data(response) + return TabulatorSetOpenQuery.model_validate( + data + ).admin.set_tabulator_open_query.tabulator_open_query diff --git a/api/python/quilt3/admin/_graphql_client/tabulator_get_open_query.py b/api/python/quilt3/admin/_graphql_client/tabulator_get_open_query.py new file mode 100644 index 00000000000..295223ccb13 --- /dev/null +++ b/api/python/quilt3/admin/_graphql_client/tabulator_get_open_query.py @@ -0,0 +1,17 @@ +# Generated by ariadne-codegen +# Source: queries.graphql + +from pydantic import Field + +from .base_model import BaseModel + + +class TabulatorGetOpenQuery(BaseModel): + admin: "TabulatorGetOpenQueryAdmin" + + +class TabulatorGetOpenQueryAdmin(BaseModel): + tabulator_open_query: bool = Field(alias="tabulatorOpenQuery") + + +TabulatorGetOpenQuery.model_rebuild() diff --git a/api/python/quilt3/admin/_graphql_client/tabulator_set_open_query.py b/api/python/quilt3/admin/_graphql_client/tabulator_set_open_query.py new file mode 100644 index 00000000000..7bd8518062e --- /dev/null +++ b/api/python/quilt3/admin/_graphql_client/tabulator_set_open_query.py @@ -0,0 +1,24 @@ +# Generated by ariadne-codegen +# Source: queries.graphql + +from pydantic import Field + +from .base_model import BaseModel + + +class TabulatorSetOpenQuery(BaseModel): + admin: "TabulatorSetOpenQueryAdmin" + + +class TabulatorSetOpenQueryAdmin(BaseModel): + set_tabulator_open_query: "TabulatorSetOpenQueryAdminSetTabulatorOpenQuery" = Field( + alias="setTabulatorOpenQuery" + ) + + +class TabulatorSetOpenQueryAdminSetTabulatorOpenQuery(BaseModel): + tabulator_open_query: bool = Field(alias="tabulatorOpenQuery") + + +TabulatorSetOpenQuery.model_rebuild() +TabulatorSetOpenQueryAdmin.model_rebuild() diff --git a/api/python/quilt3/admin/tabulator.py b/api/python/quilt3/admin/tabulator.py index e6e2188a3d6..c1a6e1991f7 100644 --- a/api/python/quilt3/admin/tabulator.py +++ b/api/python/quilt3/admin/tabulator.py @@ -27,3 +27,17 @@ def rename_table(bucket_name: str, table_name: str, new_table_name: str) -> None """ result = util.get_client().bucket_tabulator_table_rename(bucket_name, table_name, new_table_name) util.handle_errors(result) + + +def get_open_query() -> bool: + """ + Get the **open query** status. + """ + return util.get_client().tabulator_get_open_query() + + +def set_open_query(enabled: bool) -> None: + """ + Set the **open query** status. + """ + util.get_client().tabulator_set_open_query(enabled)