From a03aa71e174eeb865d60e7c873527a87a2859f3b Mon Sep 17 00:00:00 2001 From: Sergey Fedoseev Date: Mon, 17 Jun 2024 16:29:28 +0400 Subject: [PATCH] split API into namespaces --- api/python/quilt3-admin/queries.graphql | 24 +- api/python/quilt3/admin/__init__.py | 236 +------------ .../quilt3/admin/_graphql_client/__init__.py | 309 +++++++++--------- .../quilt3/admin/_graphql_client/add_roles.py | 47 --- .../quilt3/admin/_graphql_client/client.py | 161 ++++----- .../admin/_graphql_client/create_user.py | 42 --- .../admin/_graphql_client/delete_user.py | 47 --- .../quilt3/admin/_graphql_client/get_user.py | 28 -- .../quilt3/admin/_graphql_client/get_users.py | 28 -- .../admin/_graphql_client/remove_roles.py | 47 --- .../_graphql_client/reset_user_password.py | 49 --- .../{get_roles.py => roles_list.py} | 10 +- .../quilt3/admin/_graphql_client/set_role.py | 47 --- .../admin/_graphql_client/set_user_active.py | 47 --- .../admin/_graphql_client/set_user_admin.py | 47 --- .../admin/_graphql_client/set_user_email.py | 47 --- .../admin/_graphql_client/users_add_roles.py | 47 +++ .../admin/_graphql_client/users_create.py | 42 +++ .../admin/_graphql_client/users_delete.py | 47 +++ .../quilt3/admin/_graphql_client/users_get.py | 28 ++ .../admin/_graphql_client/users_list.py | 28 ++ .../_graphql_client/users_remove_roles.py | 47 +++ .../_graphql_client/users_reset_password.py | 49 +++ .../admin/_graphql_client/users_set_active.py | 47 +++ .../admin/_graphql_client/users_set_admin.py | 47 +++ .../admin/_graphql_client/users_set_email.py | 47 +++ .../admin/_graphql_client/users_set_role.py | 47 +++ api/python/quilt3/admin/exceptions.py | 9 + api/python/quilt3/admin/roles.py | 10 + api/python/quilt3/admin/types.py | 39 +++ api/python/quilt3/admin/users.py | 165 ++++++++++ api/python/quilt3/admin/util.py | 15 + api/python/tests/test_admin_api.py | 67 ++-- docs/api-reference/Admin.md | 36 +- gendocs/pydocmd.yml | 4 +- 35 files changed, 1034 insertions(+), 1003 deletions(-) delete mode 100644 api/python/quilt3/admin/_graphql_client/add_roles.py delete mode 100644 api/python/quilt3/admin/_graphql_client/create_user.py delete mode 100644 api/python/quilt3/admin/_graphql_client/delete_user.py delete mode 100644 api/python/quilt3/admin/_graphql_client/get_user.py delete mode 100644 api/python/quilt3/admin/_graphql_client/get_users.py delete mode 100644 api/python/quilt3/admin/_graphql_client/remove_roles.py delete mode 100644 api/python/quilt3/admin/_graphql_client/reset_user_password.py rename api/python/quilt3/admin/_graphql_client/{get_roles.py => roles_list.py} (66%) delete mode 100644 api/python/quilt3/admin/_graphql_client/set_role.py delete mode 100644 api/python/quilt3/admin/_graphql_client/set_user_active.py delete mode 100644 api/python/quilt3/admin/_graphql_client/set_user_admin.py delete mode 100644 api/python/quilt3/admin/_graphql_client/set_user_email.py create mode 100644 api/python/quilt3/admin/_graphql_client/users_add_roles.py create mode 100644 api/python/quilt3/admin/_graphql_client/users_create.py create mode 100644 api/python/quilt3/admin/_graphql_client/users_delete.py create mode 100644 api/python/quilt3/admin/_graphql_client/users_get.py create mode 100644 api/python/quilt3/admin/_graphql_client/users_list.py create mode 100644 api/python/quilt3/admin/_graphql_client/users_remove_roles.py create mode 100644 api/python/quilt3/admin/_graphql_client/users_reset_password.py create mode 100644 api/python/quilt3/admin/_graphql_client/users_set_active.py create mode 100644 api/python/quilt3/admin/_graphql_client/users_set_admin.py create mode 100644 api/python/quilt3/admin/_graphql_client/users_set_email.py create mode 100644 api/python/quilt3/admin/_graphql_client/users_set_role.py create mode 100644 api/python/quilt3/admin/exceptions.py create mode 100644 api/python/quilt3/admin/roles.py create mode 100644 api/python/quilt3/admin/types.py create mode 100644 api/python/quilt3/admin/users.py create mode 100644 api/python/quilt3/admin/util.py diff --git a/api/python/quilt3-admin/queries.graphql b/api/python/quilt3-admin/queries.graphql index 7ce6ff1af6d..4947f7f53ba 100644 --- a/api/python/quilt3-admin/queries.graphql +++ b/api/python/quilt3-admin/queries.graphql @@ -48,13 +48,13 @@ fragment OperationErrorSelection on OperationError { context } -query getRoles { +query rolesList { roles { ...RoleSelection } } -query getUser($name: String!) { +query usersGet($name: String!) { admin { user { get(name: $name) { @@ -64,7 +64,7 @@ query getUser($name: String!) { } } -query getUsers { +query usersList { admin { user { list { @@ -74,7 +74,7 @@ query getUsers { } } -mutation createUser($input: UserInput!) { +mutation usersCreate($input: UserInput!) { admin { user { create(input: $input) { @@ -84,7 +84,7 @@ mutation createUser($input: UserInput!) { } } -mutation deleteUser($name: String!) { +mutation usersDelete($name: String!) { admin { user { mutate(name: $name) { @@ -97,7 +97,7 @@ mutation deleteUser($name: String!) { } } -mutation setUserEmail($email: String!, $name: String!) { +mutation usersSetEmail($email: String!, $name: String!) { admin { user { mutate(name: $name) { @@ -109,7 +109,7 @@ mutation setUserEmail($email: String!, $name: String!) { } } -mutation setUserAdmin($name: String!, $admin: Boolean!) { +mutation usersSetAdmin($name: String!, $admin: Boolean!) { admin { user { mutate(name: $name) { @@ -121,7 +121,7 @@ mutation setUserAdmin($name: String!, $admin: Boolean!) { } } -mutation setUserActive($active: Boolean!, $name: String!) { +mutation usersSetActive($active: Boolean!, $name: String!) { admin { user { mutate(name: $name) { @@ -133,7 +133,7 @@ mutation setUserActive($active: Boolean!, $name: String!) { } } -mutation resetUserPassword($name: String!) { +mutation usersResetPassword($name: String!) { admin { user { mutate(name: $name) { @@ -146,7 +146,7 @@ mutation resetUserPassword($name: String!) { } } -mutation setRole($name: String!, $role: String!, $extraRoles: [String!], $append: Boolean!) { +mutation usersSetRole($name: String!, $role: String!, $extraRoles: [String!], $append: Boolean!) { admin { user { mutate(name: $name) { @@ -160,7 +160,7 @@ mutation setRole($name: String!, $role: String!, $extraRoles: [String!], $append } } -mutation addRoles($name: String!, $roles: [String!]!) { +mutation usersAddRoles($name: String!, $roles: [String!]!) { admin { user { mutate(name: $name) { @@ -174,7 +174,7 @@ mutation addRoles($name: String!, $roles: [String!]!) { } } -mutation removeRoles($name: String!, $roles: [String!]!, $fallback: String) { +mutation usersRemoveRoles($name: String!, $roles: [String!]!, $fallback: String) { admin { user { mutate(name: $name) { diff --git a/api/python/quilt3/admin/__init__.py b/api/python/quilt3/admin/__init__.py index 148604cd29e..3f70b0f7777 100644 --- a/api/python/quilt3/admin/__init__.py +++ b/api/python/quilt3/admin/__init__.py @@ -3,237 +3,7 @@ """ # This wraps code generated by aridne-codegen to provide a more user-friendly API. -from datetime import datetime -from typing import Annotated, Any, List, Literal, Optional, Union -import pydantic - -from . import _graphql_client - - -@pydantic.dataclasses.dataclass -class ManagedRole: - id: str - name: str - arn: str - typename__: Literal["ManagedRole"] - - -@pydantic.dataclasses.dataclass -class UnmanagedRole: - id: str - name: str - arn: str - typename__: Literal["UnmanagedRole"] - - -Role = Union[ManagedRole, UnmanagedRole] -AnnotatedRole = Annotated[Role, pydantic.Field(discriminator="typename__")] -role_adapter = pydantic.TypeAdapter(AnnotatedRole) - - -@pydantic.dataclasses.dataclass -class User: - name: str - email: str - date_joined: datetime - last_login: datetime - is_active: bool - is_admin: bool - is_sso_only: bool - is_service: bool - role: Optional[AnnotatedRole] - extra_roles: List[AnnotatedRole] - - -class Quilt3AdminError(Exception): - def __init__(self, details): - super().__init__(details) - self.details = details - - -class UserNotFoundError(Quilt3AdminError): - def __init__(self): - super().__init__(None) - - -def _handle_errors(result: _graphql_client.BaseModel) -> _graphql_client.BaseModel: - if isinstance(result, (_graphql_client.InvalidInputSelection, _graphql_client.OperationErrorSelection)): - raise Quilt3AdminError(result) - return result - - -def _handle_user_mutation(result: _graphql_client.BaseModel) -> User: - return User(**_handle_errors(result).model_dump()) - - -def _get_client(): - return _graphql_client.Client() - - -def get_roles() -> List[Role]: - """ - Get a list of all roles in the registry. - """ - return [role_adapter.validate_python(r.model_dump()) for r in _get_client().get_roles()] - - -def get_user(name: str) -> Optional[User]: - """ - Get a specific user from the registry. Return `None` if the user does not exist. - - Args: - name: Username of user to get. - """ - result = _get_client().get_user(name=name) - if result is None: - return None - return User(**result.model_dump()) - - -def get_users() -> List[User]: - """ - Get a list of all users in the registry. - """ - return [User(**u.model_dump()) for u in _get_client().get_users()] - - -def create_user(name: str, email: str, role: str, extra_roles: Optional[List[str]] = None) -> User: - """ - Create a new user in the registry. - - Args: - name: Username of user to create. - email: Email of user to create. - role: Active role of the user. - extra_roles: Additional roles to assign to the user. - """ - - return _handle_user_mutation( - _get_client().create_user( - input=_graphql_client.UserInput(name=name, email=email, role=role, extraRoles=extra_roles) - ) - ) - - -def delete_user(name: str) -> None: - """ - Delete user from the registry. - - Args: - name: Username of user to delete. - """ - result = _get_client().delete_user(name=name) - if result is None: - raise UserNotFoundError - _handle_errors(result.delete) - - -def set_user_email(name: str, email: str) -> User: - """ - Set the email for a user. - - Args: - name: Username of user to update. - email: Email to set for the user. - """ - result = _get_client().set_user_email(name=name, email=email) - if result is None: - raise UserNotFoundError - return _handle_user_mutation(result.set_email) - - -def set_user_admin(name: str, admin: bool) -> User: - """ - Set the admin status for a user. - - Args: - name: Username of user to update. - admin: Admin status to set for the user. - """ - result = _get_client().set_user_admin(name=name, admin=admin) - if result is None: - raise UserNotFoundError - return _handle_user_mutation(result.set_admin) - - -def set_user_active(name: str, active: bool) -> User: - """ - Set the active status for a user. - - Args: - name: Username of user to update. - active: Active status to set for the user. - """ - result = _get_client().set_user_active(name=name, active=active) - if result is None: - raise UserNotFoundError - return _handle_user_mutation(result.set_active) - - -def reset_user_password(name: str) -> None: - """ - Reset the password for a user. - - Args: - name: Username of user to update. - """ - result = _get_client().reset_user_password(name=name) - if result is None: - raise UserNotFoundError - _handle_errors(result.reset_password) - - -def set_role( - name: str, - role: str, - extra_roles: Optional[List[str]] = None, - *, - append: bool = False, -) -> User: - """ - Set the active and extra roles for a user. - - Args: - name: Username of user to update. - role: Role to be set as the active role. - extra_roles: Additional roles to assign to the user. - append: If True, append the extra roles to the existing roles. If False, replace the existing roles. - """ - result = _get_client().set_role(name=name, role=role, extra_roles=extra_roles, append=append) - if result is None: - raise UserNotFoundError - return _handle_user_mutation(result.set_role) - - -def add_roles(name: str, roles: List[str]) -> User: - """ - Add roles to a user. - - Args: - name: Username of user to update. - roles: Roles to add to the user. - """ - result = _get_client().add_roles(name=name, roles=roles) - if result is None: - raise UserNotFoundError - return _handle_user_mutation(result.add_roles) - - -def remove_roles( - name: str, - roles: List[str], - fallback: Optional[str] = None, -) -> User: - """ - Remove roles from a user. - - Args: - name: Username of user to update. - roles: Roles to remove from the user. - fallback: If set, the role to assign to the user if the active role is removed. - """ - result = _get_client().remove_roles(name=name, roles=roles, fallback=fallback) - if result is None: - raise UserNotFoundError - return _handle_user_mutation(result.remove_roles) +from . import roles, users +from .exceptions import Quilt3AdminError, UserNotFoundError +from .types import ManagedRole, UnmanagedRole, User diff --git a/api/python/quilt3/admin/_graphql_client/__init__.py b/api/python/quilt3/admin/_graphql_client/__init__.py index 15a154c05ab..399900def00 100644 --- a/api/python/quilt3/admin/_graphql_client/__init__.py +++ b/api/python/quilt3/admin/_graphql_client/__init__.py @@ -1,34 +1,8 @@ # Generated by ariadne-codegen -from .add_roles import ( - AddRoles, - AddRolesAdmin, - AddRolesAdminUser, - AddRolesAdminUserMutate, - AddRolesAdminUserMutateAddRolesInvalidInput, - AddRolesAdminUserMutateAddRolesOperationError, - AddRolesAdminUserMutateAddRolesUser, -) from .base_client import BaseClient from .base_model import BaseModel, Upload from .client import Client -from .create_user import ( - CreateUser, - CreateUserAdmin, - CreateUserAdminUser, - CreateUserAdminUserCreateInvalidInput, - CreateUserAdminUserCreateOperationError, - CreateUserAdminUserCreateUser, -) -from .delete_user import ( - DeleteUser, - DeleteUserAdmin, - DeleteUserAdminUser, - DeleteUserAdminUserMutate, - DeleteUserAdminUserMutateDeleteInvalidInput, - DeleteUserAdminUserMutateDeleteOk, - DeleteUserAdminUserMutateDeleteOperationError, -) from .fragments import ( InvalidInputSelection, InvalidInputSelectionErrors, @@ -41,146 +15,111 @@ UserSelectionRoleManagedRole, UserSelectionRoleUnmanagedRole, ) -from .get_roles import GetRoles, GetRolesRolesManagedRole, GetRolesRolesUnmanagedRole -from .get_user import GetUser, GetUserAdmin, GetUserAdminUser, GetUserAdminUserGet -from .get_users import GetUsers, GetUsersAdmin, GetUsersAdminUser, GetUsersAdminUserList from .input_types import UserInput -from .remove_roles import ( - RemoveRoles, - RemoveRolesAdmin, - RemoveRolesAdminUser, - RemoveRolesAdminUserMutate, - RemoveRolesAdminUserMutateRemoveRolesInvalidInput, - RemoveRolesAdminUserMutateRemoveRolesOperationError, - RemoveRolesAdminUserMutateRemoveRolesUser, +from .roles_list import ( + RolesList, + RolesListRolesManagedRole, + RolesListRolesUnmanagedRole, +) +from .users_add_roles import ( + UsersAddRoles, + UsersAddRolesAdmin, + UsersAddRolesAdminUser, + UsersAddRolesAdminUserMutate, + UsersAddRolesAdminUserMutateAddRolesInvalidInput, + UsersAddRolesAdminUserMutateAddRolesOperationError, + UsersAddRolesAdminUserMutateAddRolesUser, +) +from .users_create import ( + UsersCreate, + UsersCreateAdmin, + UsersCreateAdminUser, + UsersCreateAdminUserCreateInvalidInput, + UsersCreateAdminUserCreateOperationError, + UsersCreateAdminUserCreateUser, +) +from .users_delete import ( + UsersDelete, + UsersDeleteAdmin, + UsersDeleteAdminUser, + UsersDeleteAdminUserMutate, + UsersDeleteAdminUserMutateDeleteInvalidInput, + UsersDeleteAdminUserMutateDeleteOk, + UsersDeleteAdminUserMutateDeleteOperationError, +) +from .users_get import UsersGet, UsersGetAdmin, UsersGetAdminUser, UsersGetAdminUserGet +from .users_list import ( + UsersList, + UsersListAdmin, + UsersListAdminUser, + UsersListAdminUserList, +) +from .users_remove_roles import ( + UsersRemoveRoles, + UsersRemoveRolesAdmin, + UsersRemoveRolesAdminUser, + UsersRemoveRolesAdminUserMutate, + UsersRemoveRolesAdminUserMutateRemoveRolesInvalidInput, + UsersRemoveRolesAdminUserMutateRemoveRolesOperationError, + UsersRemoveRolesAdminUserMutateRemoveRolesUser, ) -from .reset_user_password import ( - ResetUserPassword, - ResetUserPasswordAdmin, - ResetUserPasswordAdminUser, - ResetUserPasswordAdminUserMutate, - ResetUserPasswordAdminUserMutateResetPasswordInvalidInput, - ResetUserPasswordAdminUserMutateResetPasswordOk, - ResetUserPasswordAdminUserMutateResetPasswordOperationError, +from .users_reset_password import ( + UsersResetPassword, + UsersResetPasswordAdmin, + UsersResetPasswordAdminUser, + UsersResetPasswordAdminUserMutate, + UsersResetPasswordAdminUserMutateResetPasswordInvalidInput, + UsersResetPasswordAdminUserMutateResetPasswordOk, + UsersResetPasswordAdminUserMutateResetPasswordOperationError, ) -from .set_role import ( - SetRole, - SetRoleAdmin, - SetRoleAdminUser, - SetRoleAdminUserMutate, - SetRoleAdminUserMutateSetRoleInvalidInput, - SetRoleAdminUserMutateSetRoleOperationError, - SetRoleAdminUserMutateSetRoleUser, +from .users_set_active import ( + UsersSetActive, + UsersSetActiveAdmin, + UsersSetActiveAdminUser, + UsersSetActiveAdminUserMutate, + UsersSetActiveAdminUserMutateSetActiveInvalidInput, + UsersSetActiveAdminUserMutateSetActiveOperationError, + UsersSetActiveAdminUserMutateSetActiveUser, ) -from .set_user_active import ( - SetUserActive, - SetUserActiveAdmin, - SetUserActiveAdminUser, - SetUserActiveAdminUserMutate, - SetUserActiveAdminUserMutateSetActiveInvalidInput, - SetUserActiveAdminUserMutateSetActiveOperationError, - SetUserActiveAdminUserMutateSetActiveUser, +from .users_set_admin import ( + UsersSetAdmin, + UsersSetAdminAdmin, + UsersSetAdminAdminUser, + UsersSetAdminAdminUserMutate, + UsersSetAdminAdminUserMutateSetAdminInvalidInput, + UsersSetAdminAdminUserMutateSetAdminOperationError, + UsersSetAdminAdminUserMutateSetAdminUser, ) -from .set_user_admin import ( - SetUserAdmin, - SetUserAdminAdmin, - SetUserAdminAdminUser, - SetUserAdminAdminUserMutate, - SetUserAdminAdminUserMutateSetAdminInvalidInput, - SetUserAdminAdminUserMutateSetAdminOperationError, - SetUserAdminAdminUserMutateSetAdminUser, +from .users_set_email import ( + UsersSetEmail, + UsersSetEmailAdmin, + UsersSetEmailAdminUser, + UsersSetEmailAdminUserMutate, + UsersSetEmailAdminUserMutateSetEmailInvalidInput, + UsersSetEmailAdminUserMutateSetEmailOperationError, + UsersSetEmailAdminUserMutateSetEmailUser, ) -from .set_user_email import ( - SetUserEmail, - SetUserEmailAdmin, - SetUserEmailAdminUser, - SetUserEmailAdminUserMutate, - SetUserEmailAdminUserMutateSetEmailInvalidInput, - SetUserEmailAdminUserMutateSetEmailOperationError, - SetUserEmailAdminUserMutateSetEmailUser, +from .users_set_role import ( + UsersSetRole, + UsersSetRoleAdmin, + UsersSetRoleAdminUser, + UsersSetRoleAdminUserMutate, + UsersSetRoleAdminUserMutateSetRoleInvalidInput, + UsersSetRoleAdminUserMutateSetRoleOperationError, + UsersSetRoleAdminUserMutateSetRoleUser, ) __all__ = [ - "AddRoles", - "AddRolesAdmin", - "AddRolesAdminUser", - "AddRolesAdminUserMutate", - "AddRolesAdminUserMutateAddRolesInvalidInput", - "AddRolesAdminUserMutateAddRolesOperationError", - "AddRolesAdminUserMutateAddRolesUser", "BaseClient", "BaseModel", "Client", - "CreateUser", - "CreateUserAdmin", - "CreateUserAdminUser", - "CreateUserAdminUserCreateInvalidInput", - "CreateUserAdminUserCreateOperationError", - "CreateUserAdminUserCreateUser", - "DeleteUser", - "DeleteUserAdmin", - "DeleteUserAdminUser", - "DeleteUserAdminUserMutate", - "DeleteUserAdminUserMutateDeleteInvalidInput", - "DeleteUserAdminUserMutateDeleteOk", - "DeleteUserAdminUserMutateDeleteOperationError", - "GetRoles", - "GetRolesRolesManagedRole", - "GetRolesRolesUnmanagedRole", - "GetUser", - "GetUserAdmin", - "GetUserAdminUser", - "GetUserAdminUserGet", - "GetUsers", - "GetUsersAdmin", - "GetUsersAdminUser", - "GetUsersAdminUserList", "InvalidInputSelection", "InvalidInputSelectionErrors", "ManagedRoleSelection", "OperationErrorSelection", - "RemoveRoles", - "RemoveRolesAdmin", - "RemoveRolesAdminUser", - "RemoveRolesAdminUserMutate", - "RemoveRolesAdminUserMutateRemoveRolesInvalidInput", - "RemoveRolesAdminUserMutateRemoveRolesOperationError", - "RemoveRolesAdminUserMutateRemoveRolesUser", - "ResetUserPassword", - "ResetUserPasswordAdmin", - "ResetUserPasswordAdminUser", - "ResetUserPasswordAdminUserMutate", - "ResetUserPasswordAdminUserMutateResetPasswordInvalidInput", - "ResetUserPasswordAdminUserMutateResetPasswordOk", - "ResetUserPasswordAdminUserMutateResetPasswordOperationError", - "SetRole", - "SetRoleAdmin", - "SetRoleAdminUser", - "SetRoleAdminUserMutate", - "SetRoleAdminUserMutateSetRoleInvalidInput", - "SetRoleAdminUserMutateSetRoleOperationError", - "SetRoleAdminUserMutateSetRoleUser", - "SetUserActive", - "SetUserActiveAdmin", - "SetUserActiveAdminUser", - "SetUserActiveAdminUserMutate", - "SetUserActiveAdminUserMutateSetActiveInvalidInput", - "SetUserActiveAdminUserMutateSetActiveOperationError", - "SetUserActiveAdminUserMutateSetActiveUser", - "SetUserAdmin", - "SetUserAdminAdmin", - "SetUserAdminAdminUser", - "SetUserAdminAdminUserMutate", - "SetUserAdminAdminUserMutateSetAdminInvalidInput", - "SetUserAdminAdminUserMutateSetAdminOperationError", - "SetUserAdminAdminUserMutateSetAdminUser", - "SetUserEmail", - "SetUserEmailAdmin", - "SetUserEmailAdminUser", - "SetUserEmailAdminUserMutate", - "SetUserEmailAdminUserMutateSetEmailInvalidInput", - "SetUserEmailAdminUserMutateSetEmailOperationError", - "SetUserEmailAdminUserMutateSetEmailUser", + "RolesList", + "RolesListRolesManagedRole", + "RolesListRolesUnmanagedRole", "UnmanagedRoleSelection", "Upload", "UserInput", @@ -189,4 +128,74 @@ "UserSelectionExtraRolesUnmanagedRole", "UserSelectionRoleManagedRole", "UserSelectionRoleUnmanagedRole", + "UsersAddRoles", + "UsersAddRolesAdmin", + "UsersAddRolesAdminUser", + "UsersAddRolesAdminUserMutate", + "UsersAddRolesAdminUserMutateAddRolesInvalidInput", + "UsersAddRolesAdminUserMutateAddRolesOperationError", + "UsersAddRolesAdminUserMutateAddRolesUser", + "UsersCreate", + "UsersCreateAdmin", + "UsersCreateAdminUser", + "UsersCreateAdminUserCreateInvalidInput", + "UsersCreateAdminUserCreateOperationError", + "UsersCreateAdminUserCreateUser", + "UsersDelete", + "UsersDeleteAdmin", + "UsersDeleteAdminUser", + "UsersDeleteAdminUserMutate", + "UsersDeleteAdminUserMutateDeleteInvalidInput", + "UsersDeleteAdminUserMutateDeleteOk", + "UsersDeleteAdminUserMutateDeleteOperationError", + "UsersGet", + "UsersGetAdmin", + "UsersGetAdminUser", + "UsersGetAdminUserGet", + "UsersList", + "UsersListAdmin", + "UsersListAdminUser", + "UsersListAdminUserList", + "UsersRemoveRoles", + "UsersRemoveRolesAdmin", + "UsersRemoveRolesAdminUser", + "UsersRemoveRolesAdminUserMutate", + "UsersRemoveRolesAdminUserMutateRemoveRolesInvalidInput", + "UsersRemoveRolesAdminUserMutateRemoveRolesOperationError", + "UsersRemoveRolesAdminUserMutateRemoveRolesUser", + "UsersResetPassword", + "UsersResetPasswordAdmin", + "UsersResetPasswordAdminUser", + "UsersResetPasswordAdminUserMutate", + "UsersResetPasswordAdminUserMutateResetPasswordInvalidInput", + "UsersResetPasswordAdminUserMutateResetPasswordOk", + "UsersResetPasswordAdminUserMutateResetPasswordOperationError", + "UsersSetActive", + "UsersSetActiveAdmin", + "UsersSetActiveAdminUser", + "UsersSetActiveAdminUserMutate", + "UsersSetActiveAdminUserMutateSetActiveInvalidInput", + "UsersSetActiveAdminUserMutateSetActiveOperationError", + "UsersSetActiveAdminUserMutateSetActiveUser", + "UsersSetAdmin", + "UsersSetAdminAdmin", + "UsersSetAdminAdminUser", + "UsersSetAdminAdminUserMutate", + "UsersSetAdminAdminUserMutateSetAdminInvalidInput", + "UsersSetAdminAdminUserMutateSetAdminOperationError", + "UsersSetAdminAdminUserMutateSetAdminUser", + "UsersSetEmail", + "UsersSetEmailAdmin", + "UsersSetEmailAdminUser", + "UsersSetEmailAdminUserMutate", + "UsersSetEmailAdminUserMutateSetEmailInvalidInput", + "UsersSetEmailAdminUserMutateSetEmailOperationError", + "UsersSetEmailAdminUserMutateSetEmailUser", + "UsersSetRole", + "UsersSetRoleAdmin", + "UsersSetRoleAdminUser", + "UsersSetRoleAdminUserMutate", + "UsersSetRoleAdminUserMutateSetRoleInvalidInput", + "UsersSetRoleAdminUserMutateSetRoleOperationError", + "UsersSetRoleAdminUserMutateSetRoleUser", ] diff --git a/api/python/quilt3/admin/_graphql_client/add_roles.py b/api/python/quilt3/admin/_graphql_client/add_roles.py deleted file mode 100644 index 04aa9c3952e..00000000000 --- a/api/python/quilt3/admin/_graphql_client/add_roles.py +++ /dev/null @@ -1,47 +0,0 @@ -# Generated by ariadne-codegen -# Source: queries.graphql - -from typing import Literal, Optional, Union - -from pydantic import Field - -from .base_model import BaseModel -from .fragments import InvalidInputSelection, OperationErrorSelection, UserSelection - - -class AddRoles(BaseModel): - admin: "AddRolesAdmin" - - -class AddRolesAdmin(BaseModel): - user: "AddRolesAdminUser" - - -class AddRolesAdminUser(BaseModel): - mutate: Optional["AddRolesAdminUserMutate"] - - -class AddRolesAdminUserMutate(BaseModel): - add_roles: Union[ - "AddRolesAdminUserMutateAddRolesUser", - "AddRolesAdminUserMutateAddRolesInvalidInput", - "AddRolesAdminUserMutateAddRolesOperationError", - ] = Field(alias="addRoles", discriminator="typename__") - - -class AddRolesAdminUserMutateAddRolesUser(UserSelection): - typename__: Literal["User"] = Field(alias="__typename") - - -class AddRolesAdminUserMutateAddRolesInvalidInput(InvalidInputSelection): - typename__: Literal["InvalidInput"] = Field(alias="__typename") - - -class AddRolesAdminUserMutateAddRolesOperationError(OperationErrorSelection): - typename__: Literal["OperationError"] = Field(alias="__typename") - - -AddRoles.model_rebuild() -AddRolesAdmin.model_rebuild() -AddRolesAdminUser.model_rebuild() -AddRolesAdminUserMutate.model_rebuild() diff --git a/api/python/quilt3/admin/_graphql_client/client.py b/api/python/quilt3/admin/_graphql_client/client.py index 648257d2637..12686f8ff48 100644 --- a/api/python/quilt3/admin/_graphql_client/client.py +++ b/api/python/quilt3/admin/_graphql_client/client.py @@ -3,26 +3,30 @@ from typing import Any, Dict, List, Optional, Union -from .add_roles import AddRoles, AddRolesAdminUserMutate from .base_client import BaseClient from .base_model import UNSET, UnsetType -from .create_user import ( - CreateUser, - CreateUserAdminUserCreateInvalidInput, - CreateUserAdminUserCreateOperationError, - CreateUserAdminUserCreateUser, -) -from .delete_user import DeleteUser, DeleteUserAdminUserMutate -from .get_roles import GetRoles, GetRolesRolesManagedRole, GetRolesRolesUnmanagedRole -from .get_user import GetUser, GetUserAdminUserGet -from .get_users import GetUsers, GetUsersAdminUserList from .input_types import UserInput -from .remove_roles import RemoveRoles, RemoveRolesAdminUserMutate -from .reset_user_password import ResetUserPassword, ResetUserPasswordAdminUserMutate -from .set_role import SetRole, SetRoleAdminUserMutate -from .set_user_active import SetUserActive, SetUserActiveAdminUserMutate -from .set_user_admin import SetUserAdmin, SetUserAdminAdminUserMutate -from .set_user_email import SetUserEmail, SetUserEmailAdminUserMutate +from .roles_list import ( + RolesList, + RolesListRolesManagedRole, + RolesListRolesUnmanagedRole, +) +from .users_add_roles import UsersAddRoles, UsersAddRolesAdminUserMutate +from .users_create import ( + UsersCreate, + UsersCreateAdminUserCreateInvalidInput, + UsersCreateAdminUserCreateOperationError, + UsersCreateAdminUserCreateUser, +) +from .users_delete import UsersDelete, UsersDeleteAdminUserMutate +from .users_get import UsersGet, UsersGetAdminUserGet +from .users_list import UsersList, UsersListAdminUserList +from .users_remove_roles import UsersRemoveRoles, UsersRemoveRolesAdminUserMutate +from .users_reset_password import UsersResetPassword, UsersResetPasswordAdminUserMutate +from .users_set_active import UsersSetActive, UsersSetActiveAdminUserMutate +from .users_set_admin import UsersSetAdmin, UsersSetAdminAdminUserMutate +from .users_set_email import UsersSetEmail, UsersSetEmailAdminUserMutate +from .users_set_role import UsersSetRole, UsersSetRoleAdminUserMutate def gql(q: str) -> str: @@ -30,12 +34,12 @@ def gql(q: str) -> str: class Client(BaseClient): - def get_roles( + def roles_list( self, **kwargs: Any - ) -> List[Union[GetRolesRolesUnmanagedRole, GetRolesRolesManagedRole]]: + ) -> List[Union[RolesListRolesUnmanagedRole, RolesListRolesManagedRole]]: query = gql( """ - query getRoles { + query rolesList { roles { ...RoleSelection } @@ -62,15 +66,15 @@ def get_roles( ) variables: Dict[str, object] = {} response = self.execute( - query=query, operation_name="getRoles", variables=variables, **kwargs + query=query, operation_name="rolesList", variables=variables, **kwargs ) data = self.get_data(response) - return GetRoles.model_validate(data).roles + return RolesList.model_validate(data).roles - def get_user(self, name: str, **kwargs: Any) -> Optional[GetUserAdminUserGet]: + def users_get(self, name: str, **kwargs: Any) -> Optional[UsersGetAdminUserGet]: query = gql( """ - query getUser($name: String!) { + query usersGet($name: String!) { admin { user { get(name: $name) { @@ -118,15 +122,15 @@ def get_user(self, name: str, **kwargs: Any) -> Optional[GetUserAdminUserGet]: ) variables: Dict[str, object] = {"name": name} response = self.execute( - query=query, operation_name="getUser", variables=variables, **kwargs + query=query, operation_name="usersGet", variables=variables, **kwargs ) data = self.get_data(response) - return GetUser.model_validate(data).admin.user.get + return UsersGet.model_validate(data).admin.user.get - def get_users(self, **kwargs: Any) -> List[GetUsersAdminUserList]: + def users_list(self, **kwargs: Any) -> List[UsersListAdminUserList]: query = gql( """ - query getUsers { + query usersList { admin { user { list { @@ -174,19 +178,19 @@ def get_users(self, **kwargs: Any) -> List[GetUsersAdminUserList]: ) variables: Dict[str, object] = {} response = self.execute( - query=query, operation_name="getUsers", variables=variables, **kwargs + query=query, operation_name="usersList", variables=variables, **kwargs ) data = self.get_data(response) - return GetUsers.model_validate(data).admin.user.list + return UsersList.model_validate(data).admin.user.list - def create_user(self, input: UserInput, **kwargs: Any) -> Union[ - CreateUserAdminUserCreateUser, - CreateUserAdminUserCreateInvalidInput, - CreateUserAdminUserCreateOperationError, + def users_create(self, input: UserInput, **kwargs: Any) -> Union[ + UsersCreateAdminUserCreateUser, + UsersCreateAdminUserCreateInvalidInput, + UsersCreateAdminUserCreateOperationError, ]: query = gql( """ - mutation createUser($input: UserInput!) { + mutation usersCreate($input: UserInput!) { admin { user { create(input: $input) { @@ -256,17 +260,17 @@ def create_user(self, input: UserInput, **kwargs: Any) -> Union[ ) variables: Dict[str, object] = {"input": input} response = self.execute( - query=query, operation_name="createUser", variables=variables, **kwargs + query=query, operation_name="usersCreate", variables=variables, **kwargs ) data = self.get_data(response) - return CreateUser.model_validate(data).admin.user.create + return UsersCreate.model_validate(data).admin.user.create - def delete_user( + def users_delete( self, name: str, **kwargs: Any - ) -> Optional[DeleteUserAdminUserMutate]: + ) -> Optional[UsersDeleteAdminUserMutate]: query = gql( """ - mutation deleteUser($name: String!) { + mutation usersDelete($name: String!) { admin { user { mutate(name: $name) { @@ -298,17 +302,17 @@ def delete_user( ) variables: Dict[str, object] = {"name": name} response = self.execute( - query=query, operation_name="deleteUser", variables=variables, **kwargs + query=query, operation_name="usersDelete", variables=variables, **kwargs ) data = self.get_data(response) - return DeleteUser.model_validate(data).admin.user.mutate + return UsersDelete.model_validate(data).admin.user.mutate - def set_user_email( + def users_set_email( self, email: str, name: str, **kwargs: Any - ) -> Optional[SetUserEmailAdminUserMutate]: + ) -> Optional[UsersSetEmailAdminUserMutate]: query = gql( """ - mutation setUserEmail($email: String!, $name: String!) { + mutation usersSetEmail($email: String!, $name: String!) { admin { user { mutate(name: $name) { @@ -380,17 +384,17 @@ def set_user_email( ) variables: Dict[str, object] = {"email": email, "name": name} response = self.execute( - query=query, operation_name="setUserEmail", variables=variables, **kwargs + query=query, operation_name="usersSetEmail", variables=variables, **kwargs ) data = self.get_data(response) - return SetUserEmail.model_validate(data).admin.user.mutate + return UsersSetEmail.model_validate(data).admin.user.mutate - def set_user_admin( + def users_set_admin( self, name: str, admin: bool, **kwargs: Any - ) -> Optional[SetUserAdminAdminUserMutate]: + ) -> Optional[UsersSetAdminAdminUserMutate]: query = gql( """ - mutation setUserAdmin($name: String!, $admin: Boolean!) { + mutation usersSetAdmin($name: String!, $admin: Boolean!) { admin { user { mutate(name: $name) { @@ -462,17 +466,17 @@ def set_user_admin( ) variables: Dict[str, object] = {"name": name, "admin": admin} response = self.execute( - query=query, operation_name="setUserAdmin", variables=variables, **kwargs + query=query, operation_name="usersSetAdmin", variables=variables, **kwargs ) data = self.get_data(response) - return SetUserAdmin.model_validate(data).admin.user.mutate + return UsersSetAdmin.model_validate(data).admin.user.mutate - def set_user_active( + def users_set_active( self, active: bool, name: str, **kwargs: Any - ) -> Optional[SetUserActiveAdminUserMutate]: + ) -> Optional[UsersSetActiveAdminUserMutate]: query = gql( """ - mutation setUserActive($active: Boolean!, $name: String!) { + mutation usersSetActive($active: Boolean!, $name: String!) { admin { user { mutate(name: $name) { @@ -544,17 +548,17 @@ def set_user_active( ) variables: Dict[str, object] = {"active": active, "name": name} response = self.execute( - query=query, operation_name="setUserActive", variables=variables, **kwargs + query=query, operation_name="usersSetActive", variables=variables, **kwargs ) data = self.get_data(response) - return SetUserActive.model_validate(data).admin.user.mutate + return UsersSetActive.model_validate(data).admin.user.mutate - def reset_user_password( + def users_reset_password( self, name: str, **kwargs: Any - ) -> Optional[ResetUserPasswordAdminUserMutate]: + ) -> Optional[UsersResetPasswordAdminUserMutate]: query = gql( """ - mutation resetUserPassword($name: String!) { + mutation usersResetPassword($name: String!) { admin { user { mutate(name: $name) { @@ -587,24 +591,24 @@ def reset_user_password( variables: Dict[str, object] = {"name": name} response = self.execute( query=query, - operation_name="resetUserPassword", + operation_name="usersResetPassword", variables=variables, **kwargs ) data = self.get_data(response) - return ResetUserPassword.model_validate(data).admin.user.mutate + return UsersResetPassword.model_validate(data).admin.user.mutate - def set_role( + def users_set_role( self, name: str, role: str, append: bool, extra_roles: Union[Optional[List[str]], UnsetType] = UNSET, **kwargs: Any - ) -> Optional[SetRoleAdminUserMutate]: + ) -> Optional[UsersSetRoleAdminUserMutate]: query = gql( """ - mutation setRole($name: String!, $role: String!, $extraRoles: [String!], $append: Boolean!) { + mutation usersSetRole($name: String!, $role: String!, $extraRoles: [String!], $append: Boolean!) { admin { user { mutate(name: $name) { @@ -677,17 +681,17 @@ def set_role( "append": append, } response = self.execute( - query=query, operation_name="setRole", variables=variables, **kwargs + query=query, operation_name="usersSetRole", variables=variables, **kwargs ) data = self.get_data(response) - return SetRole.model_validate(data).admin.user.mutate + return UsersSetRole.model_validate(data).admin.user.mutate - def add_roles( + def users_add_roles( self, name: str, roles: List[str], **kwargs: Any - ) -> Optional[AddRolesAdminUserMutate]: + ) -> Optional[UsersAddRolesAdminUserMutate]: query = gql( """ - mutation addRoles($name: String!, $roles: [String!]!) { + mutation usersAddRoles($name: String!, $roles: [String!]!) { admin { user { mutate(name: $name) { @@ -755,21 +759,21 @@ def add_roles( ) variables: Dict[str, object] = {"name": name, "roles": roles} response = self.execute( - query=query, operation_name="addRoles", variables=variables, **kwargs + query=query, operation_name="usersAddRoles", variables=variables, **kwargs ) data = self.get_data(response) - return AddRoles.model_validate(data).admin.user.mutate + return UsersAddRoles.model_validate(data).admin.user.mutate - def remove_roles( + def users_remove_roles( self, name: str, roles: List[str], fallback: Union[Optional[str], UnsetType] = UNSET, **kwargs: Any - ) -> Optional[RemoveRolesAdminUserMutate]: + ) -> Optional[UsersRemoveRolesAdminUserMutate]: query = gql( """ - mutation removeRoles($name: String!, $roles: [String!]!, $fallback: String) { + mutation usersRemoveRoles($name: String!, $roles: [String!]!, $fallback: String) { admin { user { mutate(name: $name) { @@ -841,7 +845,10 @@ def remove_roles( "fallback": fallback, } response = self.execute( - query=query, operation_name="removeRoles", variables=variables, **kwargs + query=query, + operation_name="usersRemoveRoles", + variables=variables, + **kwargs ) data = self.get_data(response) - return RemoveRoles.model_validate(data).admin.user.mutate + return UsersRemoveRoles.model_validate(data).admin.user.mutate diff --git a/api/python/quilt3/admin/_graphql_client/create_user.py b/api/python/quilt3/admin/_graphql_client/create_user.py deleted file mode 100644 index 348dafb49cc..00000000000 --- a/api/python/quilt3/admin/_graphql_client/create_user.py +++ /dev/null @@ -1,42 +0,0 @@ -# Generated by ariadne-codegen -# Source: queries.graphql - -from typing import Literal, Union - -from pydantic import Field - -from .base_model import BaseModel -from .fragments import InvalidInputSelection, OperationErrorSelection, UserSelection - - -class CreateUser(BaseModel): - admin: "CreateUserAdmin" - - -class CreateUserAdmin(BaseModel): - user: "CreateUserAdminUser" - - -class CreateUserAdminUser(BaseModel): - create: Union[ - "CreateUserAdminUserCreateUser", - "CreateUserAdminUserCreateInvalidInput", - "CreateUserAdminUserCreateOperationError", - ] = Field(discriminator="typename__") - - -class CreateUserAdminUserCreateUser(UserSelection): - typename__: Literal["User"] = Field(alias="__typename") - - -class CreateUserAdminUserCreateInvalidInput(InvalidInputSelection): - typename__: Literal["InvalidInput"] = Field(alias="__typename") - - -class CreateUserAdminUserCreateOperationError(OperationErrorSelection): - typename__: Literal["OperationError"] = Field(alias="__typename") - - -CreateUser.model_rebuild() -CreateUserAdmin.model_rebuild() -CreateUserAdminUser.model_rebuild() diff --git a/api/python/quilt3/admin/_graphql_client/delete_user.py b/api/python/quilt3/admin/_graphql_client/delete_user.py deleted file mode 100644 index 57db3e41924..00000000000 --- a/api/python/quilt3/admin/_graphql_client/delete_user.py +++ /dev/null @@ -1,47 +0,0 @@ -# Generated by ariadne-codegen -# Source: queries.graphql - -from typing import Literal, Optional, Union - -from pydantic import Field - -from .base_model import BaseModel -from .fragments import InvalidInputSelection, OperationErrorSelection - - -class DeleteUser(BaseModel): - admin: "DeleteUserAdmin" - - -class DeleteUserAdmin(BaseModel): - user: "DeleteUserAdminUser" - - -class DeleteUserAdminUser(BaseModel): - mutate: Optional["DeleteUserAdminUserMutate"] - - -class DeleteUserAdminUserMutate(BaseModel): - delete: Union[ - "DeleteUserAdminUserMutateDeleteOk", - "DeleteUserAdminUserMutateDeleteInvalidInput", - "DeleteUserAdminUserMutateDeleteOperationError", - ] = Field(discriminator="typename__") - - -class DeleteUserAdminUserMutateDeleteOk(BaseModel): - typename__: Literal["Ok"] = Field(alias="__typename") - - -class DeleteUserAdminUserMutateDeleteInvalidInput(InvalidInputSelection): - typename__: Literal["InvalidInput"] = Field(alias="__typename") - - -class DeleteUserAdminUserMutateDeleteOperationError(OperationErrorSelection): - typename__: Literal["OperationError"] = Field(alias="__typename") - - -DeleteUser.model_rebuild() -DeleteUserAdmin.model_rebuild() -DeleteUserAdminUser.model_rebuild() -DeleteUserAdminUserMutate.model_rebuild() diff --git a/api/python/quilt3/admin/_graphql_client/get_user.py b/api/python/quilt3/admin/_graphql_client/get_user.py deleted file mode 100644 index 9988988724d..00000000000 --- a/api/python/quilt3/admin/_graphql_client/get_user.py +++ /dev/null @@ -1,28 +0,0 @@ -# Generated by ariadne-codegen -# Source: queries.graphql - -from typing import Optional - -from .base_model import BaseModel -from .fragments import UserSelection - - -class GetUser(BaseModel): - admin: "GetUserAdmin" - - -class GetUserAdmin(BaseModel): - user: "GetUserAdminUser" - - -class GetUserAdminUser(BaseModel): - get: Optional["GetUserAdminUserGet"] - - -class GetUserAdminUserGet(UserSelection): - pass - - -GetUser.model_rebuild() -GetUserAdmin.model_rebuild() -GetUserAdminUser.model_rebuild() diff --git a/api/python/quilt3/admin/_graphql_client/get_users.py b/api/python/quilt3/admin/_graphql_client/get_users.py deleted file mode 100644 index 05cf0f3201d..00000000000 --- a/api/python/quilt3/admin/_graphql_client/get_users.py +++ /dev/null @@ -1,28 +0,0 @@ -# Generated by ariadne-codegen -# Source: queries.graphql - -from typing import List - -from .base_model import BaseModel -from .fragments import UserSelection - - -class GetUsers(BaseModel): - admin: "GetUsersAdmin" - - -class GetUsersAdmin(BaseModel): - user: "GetUsersAdminUser" - - -class GetUsersAdminUser(BaseModel): - list: List["GetUsersAdminUserList"] - - -class GetUsersAdminUserList(UserSelection): - pass - - -GetUsers.model_rebuild() -GetUsersAdmin.model_rebuild() -GetUsersAdminUser.model_rebuild() diff --git a/api/python/quilt3/admin/_graphql_client/remove_roles.py b/api/python/quilt3/admin/_graphql_client/remove_roles.py deleted file mode 100644 index 62c010f2617..00000000000 --- a/api/python/quilt3/admin/_graphql_client/remove_roles.py +++ /dev/null @@ -1,47 +0,0 @@ -# Generated by ariadne-codegen -# Source: queries.graphql - -from typing import Literal, Optional, Union - -from pydantic import Field - -from .base_model import BaseModel -from .fragments import InvalidInputSelection, OperationErrorSelection, UserSelection - - -class RemoveRoles(BaseModel): - admin: "RemoveRolesAdmin" - - -class RemoveRolesAdmin(BaseModel): - user: "RemoveRolesAdminUser" - - -class RemoveRolesAdminUser(BaseModel): - mutate: Optional["RemoveRolesAdminUserMutate"] - - -class RemoveRolesAdminUserMutate(BaseModel): - remove_roles: Union[ - "RemoveRolesAdminUserMutateRemoveRolesUser", - "RemoveRolesAdminUserMutateRemoveRolesInvalidInput", - "RemoveRolesAdminUserMutateRemoveRolesOperationError", - ] = Field(alias="removeRoles", discriminator="typename__") - - -class RemoveRolesAdminUserMutateRemoveRolesUser(UserSelection): - typename__: Literal["User"] = Field(alias="__typename") - - -class RemoveRolesAdminUserMutateRemoveRolesInvalidInput(InvalidInputSelection): - typename__: Literal["InvalidInput"] = Field(alias="__typename") - - -class RemoveRolesAdminUserMutateRemoveRolesOperationError(OperationErrorSelection): - typename__: Literal["OperationError"] = Field(alias="__typename") - - -RemoveRoles.model_rebuild() -RemoveRolesAdmin.model_rebuild() -RemoveRolesAdminUser.model_rebuild() -RemoveRolesAdminUserMutate.model_rebuild() diff --git a/api/python/quilt3/admin/_graphql_client/reset_user_password.py b/api/python/quilt3/admin/_graphql_client/reset_user_password.py deleted file mode 100644 index 9af8f4c750b..00000000000 --- a/api/python/quilt3/admin/_graphql_client/reset_user_password.py +++ /dev/null @@ -1,49 +0,0 @@ -# Generated by ariadne-codegen -# Source: queries.graphql - -from typing import Literal, Optional, Union - -from pydantic import Field - -from .base_model import BaseModel -from .fragments import InvalidInputSelection, OperationErrorSelection - - -class ResetUserPassword(BaseModel): - admin: "ResetUserPasswordAdmin" - - -class ResetUserPasswordAdmin(BaseModel): - user: "ResetUserPasswordAdminUser" - - -class ResetUserPasswordAdminUser(BaseModel): - mutate: Optional["ResetUserPasswordAdminUserMutate"] - - -class ResetUserPasswordAdminUserMutate(BaseModel): - reset_password: Union[ - "ResetUserPasswordAdminUserMutateResetPasswordOk", - "ResetUserPasswordAdminUserMutateResetPasswordInvalidInput", - "ResetUserPasswordAdminUserMutateResetPasswordOperationError", - ] = Field(alias="resetPassword", discriminator="typename__") - - -class ResetUserPasswordAdminUserMutateResetPasswordOk(BaseModel): - typename__: Literal["Ok"] = Field(alias="__typename") - - -class ResetUserPasswordAdminUserMutateResetPasswordInvalidInput(InvalidInputSelection): - typename__: Literal["InvalidInput"] = Field(alias="__typename") - - -class ResetUserPasswordAdminUserMutateResetPasswordOperationError( - OperationErrorSelection -): - typename__: Literal["OperationError"] = Field(alias="__typename") - - -ResetUserPassword.model_rebuild() -ResetUserPasswordAdmin.model_rebuild() -ResetUserPasswordAdminUser.model_rebuild() -ResetUserPasswordAdminUserMutate.model_rebuild() diff --git a/api/python/quilt3/admin/_graphql_client/get_roles.py b/api/python/quilt3/admin/_graphql_client/roles_list.py similarity index 66% rename from api/python/quilt3/admin/_graphql_client/get_roles.py rename to api/python/quilt3/admin/_graphql_client/roles_list.py index 56ebe120418..37598459172 100644 --- a/api/python/quilt3/admin/_graphql_client/get_roles.py +++ b/api/python/quilt3/admin/_graphql_client/roles_list.py @@ -9,21 +9,21 @@ from .fragments import ManagedRoleSelection, UnmanagedRoleSelection -class GetRoles(BaseModel): +class RolesList(BaseModel): roles: List[ Annotated[ - Union["GetRolesRolesUnmanagedRole", "GetRolesRolesManagedRole"], + Union["RolesListRolesUnmanagedRole", "RolesListRolesManagedRole"], Field(discriminator="typename__"), ] ] -class GetRolesRolesUnmanagedRole(UnmanagedRoleSelection): +class RolesListRolesUnmanagedRole(UnmanagedRoleSelection): typename__: Literal["UnmanagedRole"] = Field(alias="__typename") -class GetRolesRolesManagedRole(ManagedRoleSelection): +class RolesListRolesManagedRole(ManagedRoleSelection): typename__: Literal["ManagedRole"] = Field(alias="__typename") -GetRoles.model_rebuild() +RolesList.model_rebuild() diff --git a/api/python/quilt3/admin/_graphql_client/set_role.py b/api/python/quilt3/admin/_graphql_client/set_role.py deleted file mode 100644 index f28929f830c..00000000000 --- a/api/python/quilt3/admin/_graphql_client/set_role.py +++ /dev/null @@ -1,47 +0,0 @@ -# Generated by ariadne-codegen -# Source: queries.graphql - -from typing import Literal, Optional, Union - -from pydantic import Field - -from .base_model import BaseModel -from .fragments import InvalidInputSelection, OperationErrorSelection, UserSelection - - -class SetRole(BaseModel): - admin: "SetRoleAdmin" - - -class SetRoleAdmin(BaseModel): - user: "SetRoleAdminUser" - - -class SetRoleAdminUser(BaseModel): - mutate: Optional["SetRoleAdminUserMutate"] - - -class SetRoleAdminUserMutate(BaseModel): - set_role: Union[ - "SetRoleAdminUserMutateSetRoleUser", - "SetRoleAdminUserMutateSetRoleInvalidInput", - "SetRoleAdminUserMutateSetRoleOperationError", - ] = Field(alias="setRole", discriminator="typename__") - - -class SetRoleAdminUserMutateSetRoleUser(UserSelection): - typename__: Literal["User"] = Field(alias="__typename") - - -class SetRoleAdminUserMutateSetRoleInvalidInput(InvalidInputSelection): - typename__: Literal["InvalidInput"] = Field(alias="__typename") - - -class SetRoleAdminUserMutateSetRoleOperationError(OperationErrorSelection): - typename__: Literal["OperationError"] = Field(alias="__typename") - - -SetRole.model_rebuild() -SetRoleAdmin.model_rebuild() -SetRoleAdminUser.model_rebuild() -SetRoleAdminUserMutate.model_rebuild() diff --git a/api/python/quilt3/admin/_graphql_client/set_user_active.py b/api/python/quilt3/admin/_graphql_client/set_user_active.py deleted file mode 100644 index 4837abb921f..00000000000 --- a/api/python/quilt3/admin/_graphql_client/set_user_active.py +++ /dev/null @@ -1,47 +0,0 @@ -# Generated by ariadne-codegen -# Source: queries.graphql - -from typing import Literal, Optional, Union - -from pydantic import Field - -from .base_model import BaseModel -from .fragments import InvalidInputSelection, OperationErrorSelection, UserSelection - - -class SetUserActive(BaseModel): - admin: "SetUserActiveAdmin" - - -class SetUserActiveAdmin(BaseModel): - user: "SetUserActiveAdminUser" - - -class SetUserActiveAdminUser(BaseModel): - mutate: Optional["SetUserActiveAdminUserMutate"] - - -class SetUserActiveAdminUserMutate(BaseModel): - set_active: Union[ - "SetUserActiveAdminUserMutateSetActiveUser", - "SetUserActiveAdminUserMutateSetActiveInvalidInput", - "SetUserActiveAdminUserMutateSetActiveOperationError", - ] = Field(alias="setActive", discriminator="typename__") - - -class SetUserActiveAdminUserMutateSetActiveUser(UserSelection): - typename__: Literal["User"] = Field(alias="__typename") - - -class SetUserActiveAdminUserMutateSetActiveInvalidInput(InvalidInputSelection): - typename__: Literal["InvalidInput"] = Field(alias="__typename") - - -class SetUserActiveAdminUserMutateSetActiveOperationError(OperationErrorSelection): - typename__: Literal["OperationError"] = Field(alias="__typename") - - -SetUserActive.model_rebuild() -SetUserActiveAdmin.model_rebuild() -SetUserActiveAdminUser.model_rebuild() -SetUserActiveAdminUserMutate.model_rebuild() diff --git a/api/python/quilt3/admin/_graphql_client/set_user_admin.py b/api/python/quilt3/admin/_graphql_client/set_user_admin.py deleted file mode 100644 index ac3ac14ce2c..00000000000 --- a/api/python/quilt3/admin/_graphql_client/set_user_admin.py +++ /dev/null @@ -1,47 +0,0 @@ -# Generated by ariadne-codegen -# Source: queries.graphql - -from typing import Literal, Optional, Union - -from pydantic import Field - -from .base_model import BaseModel -from .fragments import InvalidInputSelection, OperationErrorSelection, UserSelection - - -class SetUserAdmin(BaseModel): - admin: "SetUserAdminAdmin" - - -class SetUserAdminAdmin(BaseModel): - user: "SetUserAdminAdminUser" - - -class SetUserAdminAdminUser(BaseModel): - mutate: Optional["SetUserAdminAdminUserMutate"] - - -class SetUserAdminAdminUserMutate(BaseModel): - set_admin: Union[ - "SetUserAdminAdminUserMutateSetAdminUser", - "SetUserAdminAdminUserMutateSetAdminInvalidInput", - "SetUserAdminAdminUserMutateSetAdminOperationError", - ] = Field(alias="setAdmin", discriminator="typename__") - - -class SetUserAdminAdminUserMutateSetAdminUser(UserSelection): - typename__: Literal["User"] = Field(alias="__typename") - - -class SetUserAdminAdminUserMutateSetAdminInvalidInput(InvalidInputSelection): - typename__: Literal["InvalidInput"] = Field(alias="__typename") - - -class SetUserAdminAdminUserMutateSetAdminOperationError(OperationErrorSelection): - typename__: Literal["OperationError"] = Field(alias="__typename") - - -SetUserAdmin.model_rebuild() -SetUserAdminAdmin.model_rebuild() -SetUserAdminAdminUser.model_rebuild() -SetUserAdminAdminUserMutate.model_rebuild() diff --git a/api/python/quilt3/admin/_graphql_client/set_user_email.py b/api/python/quilt3/admin/_graphql_client/set_user_email.py deleted file mode 100644 index f6b94005e57..00000000000 --- a/api/python/quilt3/admin/_graphql_client/set_user_email.py +++ /dev/null @@ -1,47 +0,0 @@ -# Generated by ariadne-codegen -# Source: queries.graphql - -from typing import Literal, Optional, Union - -from pydantic import Field - -from .base_model import BaseModel -from .fragments import InvalidInputSelection, OperationErrorSelection, UserSelection - - -class SetUserEmail(BaseModel): - admin: "SetUserEmailAdmin" - - -class SetUserEmailAdmin(BaseModel): - user: "SetUserEmailAdminUser" - - -class SetUserEmailAdminUser(BaseModel): - mutate: Optional["SetUserEmailAdminUserMutate"] - - -class SetUserEmailAdminUserMutate(BaseModel): - set_email: Union[ - "SetUserEmailAdminUserMutateSetEmailUser", - "SetUserEmailAdminUserMutateSetEmailInvalidInput", - "SetUserEmailAdminUserMutateSetEmailOperationError", - ] = Field(alias="setEmail", discriminator="typename__") - - -class SetUserEmailAdminUserMutateSetEmailUser(UserSelection): - typename__: Literal["User"] = Field(alias="__typename") - - -class SetUserEmailAdminUserMutateSetEmailInvalidInput(InvalidInputSelection): - typename__: Literal["InvalidInput"] = Field(alias="__typename") - - -class SetUserEmailAdminUserMutateSetEmailOperationError(OperationErrorSelection): - typename__: Literal["OperationError"] = Field(alias="__typename") - - -SetUserEmail.model_rebuild() -SetUserEmailAdmin.model_rebuild() -SetUserEmailAdminUser.model_rebuild() -SetUserEmailAdminUserMutate.model_rebuild() diff --git a/api/python/quilt3/admin/_graphql_client/users_add_roles.py b/api/python/quilt3/admin/_graphql_client/users_add_roles.py new file mode 100644 index 00000000000..101a2f8de2d --- /dev/null +++ b/api/python/quilt3/admin/_graphql_client/users_add_roles.py @@ -0,0 +1,47 @@ +# Generated by ariadne-codegen +# Source: queries.graphql + +from typing import Literal, Optional, Union + +from pydantic import Field + +from .base_model import BaseModel +from .fragments import InvalidInputSelection, OperationErrorSelection, UserSelection + + +class UsersAddRoles(BaseModel): + admin: "UsersAddRolesAdmin" + + +class UsersAddRolesAdmin(BaseModel): + user: "UsersAddRolesAdminUser" + + +class UsersAddRolesAdminUser(BaseModel): + mutate: Optional["UsersAddRolesAdminUserMutate"] + + +class UsersAddRolesAdminUserMutate(BaseModel): + add_roles: Union[ + "UsersAddRolesAdminUserMutateAddRolesUser", + "UsersAddRolesAdminUserMutateAddRolesInvalidInput", + "UsersAddRolesAdminUserMutateAddRolesOperationError", + ] = Field(alias="addRoles", discriminator="typename__") + + +class UsersAddRolesAdminUserMutateAddRolesUser(UserSelection): + typename__: Literal["User"] = Field(alias="__typename") + + +class UsersAddRolesAdminUserMutateAddRolesInvalidInput(InvalidInputSelection): + typename__: Literal["InvalidInput"] = Field(alias="__typename") + + +class UsersAddRolesAdminUserMutateAddRolesOperationError(OperationErrorSelection): + typename__: Literal["OperationError"] = Field(alias="__typename") + + +UsersAddRoles.model_rebuild() +UsersAddRolesAdmin.model_rebuild() +UsersAddRolesAdminUser.model_rebuild() +UsersAddRolesAdminUserMutate.model_rebuild() diff --git a/api/python/quilt3/admin/_graphql_client/users_create.py b/api/python/quilt3/admin/_graphql_client/users_create.py new file mode 100644 index 00000000000..2b696f4dcd3 --- /dev/null +++ b/api/python/quilt3/admin/_graphql_client/users_create.py @@ -0,0 +1,42 @@ +# Generated by ariadne-codegen +# Source: queries.graphql + +from typing import Literal, Union + +from pydantic import Field + +from .base_model import BaseModel +from .fragments import InvalidInputSelection, OperationErrorSelection, UserSelection + + +class UsersCreate(BaseModel): + admin: "UsersCreateAdmin" + + +class UsersCreateAdmin(BaseModel): + user: "UsersCreateAdminUser" + + +class UsersCreateAdminUser(BaseModel): + create: Union[ + "UsersCreateAdminUserCreateUser", + "UsersCreateAdminUserCreateInvalidInput", + "UsersCreateAdminUserCreateOperationError", + ] = Field(discriminator="typename__") + + +class UsersCreateAdminUserCreateUser(UserSelection): + typename__: Literal["User"] = Field(alias="__typename") + + +class UsersCreateAdminUserCreateInvalidInput(InvalidInputSelection): + typename__: Literal["InvalidInput"] = Field(alias="__typename") + + +class UsersCreateAdminUserCreateOperationError(OperationErrorSelection): + typename__: Literal["OperationError"] = Field(alias="__typename") + + +UsersCreate.model_rebuild() +UsersCreateAdmin.model_rebuild() +UsersCreateAdminUser.model_rebuild() diff --git a/api/python/quilt3/admin/_graphql_client/users_delete.py b/api/python/quilt3/admin/_graphql_client/users_delete.py new file mode 100644 index 00000000000..3f5cdc726a2 --- /dev/null +++ b/api/python/quilt3/admin/_graphql_client/users_delete.py @@ -0,0 +1,47 @@ +# Generated by ariadne-codegen +# Source: queries.graphql + +from typing import Literal, Optional, Union + +from pydantic import Field + +from .base_model import BaseModel +from .fragments import InvalidInputSelection, OperationErrorSelection + + +class UsersDelete(BaseModel): + admin: "UsersDeleteAdmin" + + +class UsersDeleteAdmin(BaseModel): + user: "UsersDeleteAdminUser" + + +class UsersDeleteAdminUser(BaseModel): + mutate: Optional["UsersDeleteAdminUserMutate"] + + +class UsersDeleteAdminUserMutate(BaseModel): + delete: Union[ + "UsersDeleteAdminUserMutateDeleteOk", + "UsersDeleteAdminUserMutateDeleteInvalidInput", + "UsersDeleteAdminUserMutateDeleteOperationError", + ] = Field(discriminator="typename__") + + +class UsersDeleteAdminUserMutateDeleteOk(BaseModel): + typename__: Literal["Ok"] = Field(alias="__typename") + + +class UsersDeleteAdminUserMutateDeleteInvalidInput(InvalidInputSelection): + typename__: Literal["InvalidInput"] = Field(alias="__typename") + + +class UsersDeleteAdminUserMutateDeleteOperationError(OperationErrorSelection): + typename__: Literal["OperationError"] = Field(alias="__typename") + + +UsersDelete.model_rebuild() +UsersDeleteAdmin.model_rebuild() +UsersDeleteAdminUser.model_rebuild() +UsersDeleteAdminUserMutate.model_rebuild() diff --git a/api/python/quilt3/admin/_graphql_client/users_get.py b/api/python/quilt3/admin/_graphql_client/users_get.py new file mode 100644 index 00000000000..3a93f98aa2d --- /dev/null +++ b/api/python/quilt3/admin/_graphql_client/users_get.py @@ -0,0 +1,28 @@ +# Generated by ariadne-codegen +# Source: queries.graphql + +from typing import Optional + +from .base_model import BaseModel +from .fragments import UserSelection + + +class UsersGet(BaseModel): + admin: "UsersGetAdmin" + + +class UsersGetAdmin(BaseModel): + user: "UsersGetAdminUser" + + +class UsersGetAdminUser(BaseModel): + get: Optional["UsersGetAdminUserGet"] + + +class UsersGetAdminUserGet(UserSelection): + pass + + +UsersGet.model_rebuild() +UsersGetAdmin.model_rebuild() +UsersGetAdminUser.model_rebuild() diff --git a/api/python/quilt3/admin/_graphql_client/users_list.py b/api/python/quilt3/admin/_graphql_client/users_list.py new file mode 100644 index 00000000000..bd85e2399cf --- /dev/null +++ b/api/python/quilt3/admin/_graphql_client/users_list.py @@ -0,0 +1,28 @@ +# Generated by ariadne-codegen +# Source: queries.graphql + +from typing import List + +from .base_model import BaseModel +from .fragments import UserSelection + + +class UsersList(BaseModel): + admin: "UsersListAdmin" + + +class UsersListAdmin(BaseModel): + user: "UsersListAdminUser" + + +class UsersListAdminUser(BaseModel): + list: List["UsersListAdminUserList"] + + +class UsersListAdminUserList(UserSelection): + pass + + +UsersList.model_rebuild() +UsersListAdmin.model_rebuild() +UsersListAdminUser.model_rebuild() diff --git a/api/python/quilt3/admin/_graphql_client/users_remove_roles.py b/api/python/quilt3/admin/_graphql_client/users_remove_roles.py new file mode 100644 index 00000000000..521dda0feef --- /dev/null +++ b/api/python/quilt3/admin/_graphql_client/users_remove_roles.py @@ -0,0 +1,47 @@ +# Generated by ariadne-codegen +# Source: queries.graphql + +from typing import Literal, Optional, Union + +from pydantic import Field + +from .base_model import BaseModel +from .fragments import InvalidInputSelection, OperationErrorSelection, UserSelection + + +class UsersRemoveRoles(BaseModel): + admin: "UsersRemoveRolesAdmin" + + +class UsersRemoveRolesAdmin(BaseModel): + user: "UsersRemoveRolesAdminUser" + + +class UsersRemoveRolesAdminUser(BaseModel): + mutate: Optional["UsersRemoveRolesAdminUserMutate"] + + +class UsersRemoveRolesAdminUserMutate(BaseModel): + remove_roles: Union[ + "UsersRemoveRolesAdminUserMutateRemoveRolesUser", + "UsersRemoveRolesAdminUserMutateRemoveRolesInvalidInput", + "UsersRemoveRolesAdminUserMutateRemoveRolesOperationError", + ] = Field(alias="removeRoles", discriminator="typename__") + + +class UsersRemoveRolesAdminUserMutateRemoveRolesUser(UserSelection): + typename__: Literal["User"] = Field(alias="__typename") + + +class UsersRemoveRolesAdminUserMutateRemoveRolesInvalidInput(InvalidInputSelection): + typename__: Literal["InvalidInput"] = Field(alias="__typename") + + +class UsersRemoveRolesAdminUserMutateRemoveRolesOperationError(OperationErrorSelection): + typename__: Literal["OperationError"] = Field(alias="__typename") + + +UsersRemoveRoles.model_rebuild() +UsersRemoveRolesAdmin.model_rebuild() +UsersRemoveRolesAdminUser.model_rebuild() +UsersRemoveRolesAdminUserMutate.model_rebuild() diff --git a/api/python/quilt3/admin/_graphql_client/users_reset_password.py b/api/python/quilt3/admin/_graphql_client/users_reset_password.py new file mode 100644 index 00000000000..65b54546dc5 --- /dev/null +++ b/api/python/quilt3/admin/_graphql_client/users_reset_password.py @@ -0,0 +1,49 @@ +# Generated by ariadne-codegen +# Source: queries.graphql + +from typing import Literal, Optional, Union + +from pydantic import Field + +from .base_model import BaseModel +from .fragments import InvalidInputSelection, OperationErrorSelection + + +class UsersResetPassword(BaseModel): + admin: "UsersResetPasswordAdmin" + + +class UsersResetPasswordAdmin(BaseModel): + user: "UsersResetPasswordAdminUser" + + +class UsersResetPasswordAdminUser(BaseModel): + mutate: Optional["UsersResetPasswordAdminUserMutate"] + + +class UsersResetPasswordAdminUserMutate(BaseModel): + reset_password: Union[ + "UsersResetPasswordAdminUserMutateResetPasswordOk", + "UsersResetPasswordAdminUserMutateResetPasswordInvalidInput", + "UsersResetPasswordAdminUserMutateResetPasswordOperationError", + ] = Field(alias="resetPassword", discriminator="typename__") + + +class UsersResetPasswordAdminUserMutateResetPasswordOk(BaseModel): + typename__: Literal["Ok"] = Field(alias="__typename") + + +class UsersResetPasswordAdminUserMutateResetPasswordInvalidInput(InvalidInputSelection): + typename__: Literal["InvalidInput"] = Field(alias="__typename") + + +class UsersResetPasswordAdminUserMutateResetPasswordOperationError( + OperationErrorSelection +): + typename__: Literal["OperationError"] = Field(alias="__typename") + + +UsersResetPassword.model_rebuild() +UsersResetPasswordAdmin.model_rebuild() +UsersResetPasswordAdminUser.model_rebuild() +UsersResetPasswordAdminUserMutate.model_rebuild() diff --git a/api/python/quilt3/admin/_graphql_client/users_set_active.py b/api/python/quilt3/admin/_graphql_client/users_set_active.py new file mode 100644 index 00000000000..1d6b06056dc --- /dev/null +++ b/api/python/quilt3/admin/_graphql_client/users_set_active.py @@ -0,0 +1,47 @@ +# Generated by ariadne-codegen +# Source: queries.graphql + +from typing import Literal, Optional, Union + +from pydantic import Field + +from .base_model import BaseModel +from .fragments import InvalidInputSelection, OperationErrorSelection, UserSelection + + +class UsersSetActive(BaseModel): + admin: "UsersSetActiveAdmin" + + +class UsersSetActiveAdmin(BaseModel): + user: "UsersSetActiveAdminUser" + + +class UsersSetActiveAdminUser(BaseModel): + mutate: Optional["UsersSetActiveAdminUserMutate"] + + +class UsersSetActiveAdminUserMutate(BaseModel): + set_active: Union[ + "UsersSetActiveAdminUserMutateSetActiveUser", + "UsersSetActiveAdminUserMutateSetActiveInvalidInput", + "UsersSetActiveAdminUserMutateSetActiveOperationError", + ] = Field(alias="setActive", discriminator="typename__") + + +class UsersSetActiveAdminUserMutateSetActiveUser(UserSelection): + typename__: Literal["User"] = Field(alias="__typename") + + +class UsersSetActiveAdminUserMutateSetActiveInvalidInput(InvalidInputSelection): + typename__: Literal["InvalidInput"] = Field(alias="__typename") + + +class UsersSetActiveAdminUserMutateSetActiveOperationError(OperationErrorSelection): + typename__: Literal["OperationError"] = Field(alias="__typename") + + +UsersSetActive.model_rebuild() +UsersSetActiveAdmin.model_rebuild() +UsersSetActiveAdminUser.model_rebuild() +UsersSetActiveAdminUserMutate.model_rebuild() diff --git a/api/python/quilt3/admin/_graphql_client/users_set_admin.py b/api/python/quilt3/admin/_graphql_client/users_set_admin.py new file mode 100644 index 00000000000..67e3213265a --- /dev/null +++ b/api/python/quilt3/admin/_graphql_client/users_set_admin.py @@ -0,0 +1,47 @@ +# Generated by ariadne-codegen +# Source: queries.graphql + +from typing import Literal, Optional, Union + +from pydantic import Field + +from .base_model import BaseModel +from .fragments import InvalidInputSelection, OperationErrorSelection, UserSelection + + +class UsersSetAdmin(BaseModel): + admin: "UsersSetAdminAdmin" + + +class UsersSetAdminAdmin(BaseModel): + user: "UsersSetAdminAdminUser" + + +class UsersSetAdminAdminUser(BaseModel): + mutate: Optional["UsersSetAdminAdminUserMutate"] + + +class UsersSetAdminAdminUserMutate(BaseModel): + set_admin: Union[ + "UsersSetAdminAdminUserMutateSetAdminUser", + "UsersSetAdminAdminUserMutateSetAdminInvalidInput", + "UsersSetAdminAdminUserMutateSetAdminOperationError", + ] = Field(alias="setAdmin", discriminator="typename__") + + +class UsersSetAdminAdminUserMutateSetAdminUser(UserSelection): + typename__: Literal["User"] = Field(alias="__typename") + + +class UsersSetAdminAdminUserMutateSetAdminInvalidInput(InvalidInputSelection): + typename__: Literal["InvalidInput"] = Field(alias="__typename") + + +class UsersSetAdminAdminUserMutateSetAdminOperationError(OperationErrorSelection): + typename__: Literal["OperationError"] = Field(alias="__typename") + + +UsersSetAdmin.model_rebuild() +UsersSetAdminAdmin.model_rebuild() +UsersSetAdminAdminUser.model_rebuild() +UsersSetAdminAdminUserMutate.model_rebuild() diff --git a/api/python/quilt3/admin/_graphql_client/users_set_email.py b/api/python/quilt3/admin/_graphql_client/users_set_email.py new file mode 100644 index 00000000000..4e434d313f0 --- /dev/null +++ b/api/python/quilt3/admin/_graphql_client/users_set_email.py @@ -0,0 +1,47 @@ +# Generated by ariadne-codegen +# Source: queries.graphql + +from typing import Literal, Optional, Union + +from pydantic import Field + +from .base_model import BaseModel +from .fragments import InvalidInputSelection, OperationErrorSelection, UserSelection + + +class UsersSetEmail(BaseModel): + admin: "UsersSetEmailAdmin" + + +class UsersSetEmailAdmin(BaseModel): + user: "UsersSetEmailAdminUser" + + +class UsersSetEmailAdminUser(BaseModel): + mutate: Optional["UsersSetEmailAdminUserMutate"] + + +class UsersSetEmailAdminUserMutate(BaseModel): + set_email: Union[ + "UsersSetEmailAdminUserMutateSetEmailUser", + "UsersSetEmailAdminUserMutateSetEmailInvalidInput", + "UsersSetEmailAdminUserMutateSetEmailOperationError", + ] = Field(alias="setEmail", discriminator="typename__") + + +class UsersSetEmailAdminUserMutateSetEmailUser(UserSelection): + typename__: Literal["User"] = Field(alias="__typename") + + +class UsersSetEmailAdminUserMutateSetEmailInvalidInput(InvalidInputSelection): + typename__: Literal["InvalidInput"] = Field(alias="__typename") + + +class UsersSetEmailAdminUserMutateSetEmailOperationError(OperationErrorSelection): + typename__: Literal["OperationError"] = Field(alias="__typename") + + +UsersSetEmail.model_rebuild() +UsersSetEmailAdmin.model_rebuild() +UsersSetEmailAdminUser.model_rebuild() +UsersSetEmailAdminUserMutate.model_rebuild() diff --git a/api/python/quilt3/admin/_graphql_client/users_set_role.py b/api/python/quilt3/admin/_graphql_client/users_set_role.py new file mode 100644 index 00000000000..e5af3f1b997 --- /dev/null +++ b/api/python/quilt3/admin/_graphql_client/users_set_role.py @@ -0,0 +1,47 @@ +# Generated by ariadne-codegen +# Source: queries.graphql + +from typing import Literal, Optional, Union + +from pydantic import Field + +from .base_model import BaseModel +from .fragments import InvalidInputSelection, OperationErrorSelection, UserSelection + + +class UsersSetRole(BaseModel): + admin: "UsersSetRoleAdmin" + + +class UsersSetRoleAdmin(BaseModel): + user: "UsersSetRoleAdminUser" + + +class UsersSetRoleAdminUser(BaseModel): + mutate: Optional["UsersSetRoleAdminUserMutate"] + + +class UsersSetRoleAdminUserMutate(BaseModel): + set_role: Union[ + "UsersSetRoleAdminUserMutateSetRoleUser", + "UsersSetRoleAdminUserMutateSetRoleInvalidInput", + "UsersSetRoleAdminUserMutateSetRoleOperationError", + ] = Field(alias="setRole", discriminator="typename__") + + +class UsersSetRoleAdminUserMutateSetRoleUser(UserSelection): + typename__: Literal["User"] = Field(alias="__typename") + + +class UsersSetRoleAdminUserMutateSetRoleInvalidInput(InvalidInputSelection): + typename__: Literal["InvalidInput"] = Field(alias="__typename") + + +class UsersSetRoleAdminUserMutateSetRoleOperationError(OperationErrorSelection): + typename__: Literal["OperationError"] = Field(alias="__typename") + + +UsersSetRole.model_rebuild() +UsersSetRoleAdmin.model_rebuild() +UsersSetRoleAdminUser.model_rebuild() +UsersSetRoleAdminUserMutate.model_rebuild() diff --git a/api/python/quilt3/admin/exceptions.py b/api/python/quilt3/admin/exceptions.py new file mode 100644 index 00000000000..c9f24ca6fcb --- /dev/null +++ b/api/python/quilt3/admin/exceptions.py @@ -0,0 +1,9 @@ +class Quilt3AdminError(Exception): + def __init__(self, details): + super().__init__(details) + self.details = details + + +class UserNotFoundError(Quilt3AdminError): + def __init__(self): + super().__init__(None) diff --git a/api/python/quilt3/admin/roles.py b/api/python/quilt3/admin/roles.py new file mode 100644 index 00000000000..ec7b6450919 --- /dev/null +++ b/api/python/quilt3/admin/roles.py @@ -0,0 +1,10 @@ +from typing import List + +from . import types, util + + +def list() -> List[types.Role]: + """ + Get a list of all roles in the registry. + """ + return [types.role_adapter.validate_python(r.model_dump()) for r in util.get_client().roles_list()] diff --git a/api/python/quilt3/admin/types.py b/api/python/quilt3/admin/types.py new file mode 100644 index 00000000000..959a3c00601 --- /dev/null +++ b/api/python/quilt3/admin/types.py @@ -0,0 +1,39 @@ +from datetime import datetime +from typing import Annotated, List, Literal, Optional, Union + +import pydantic + + +@pydantic.dataclasses.dataclass +class ManagedRole: + id: str + name: str + arn: str + typename__: Literal["ManagedRole"] + + +@pydantic.dataclasses.dataclass +class UnmanagedRole: + id: str + name: str + arn: str + typename__: Literal["UnmanagedRole"] + + +Role = Union[ManagedRole, UnmanagedRole] +AnnotatedRole = Annotated[Role, pydantic.Field(discriminator="typename__")] +role_adapter = pydantic.TypeAdapter(AnnotatedRole) + + +@pydantic.dataclasses.dataclass +class User: + name: str + email: str + date_joined: datetime + last_login: datetime + is_active: bool + is_admin: bool + is_sso_only: bool + is_service: bool + role: Optional[AnnotatedRole] + extra_roles: List[AnnotatedRole] diff --git a/api/python/quilt3/admin/users.py b/api/python/quilt3/admin/users.py new file mode 100644 index 00000000000..fb667de9de8 --- /dev/null +++ b/api/python/quilt3/admin/users.py @@ -0,0 +1,165 @@ + +from typing import List, Optional + +from . import _graphql_client, exceptions, types, util + + +def get(name: str) -> Optional[types.User]: + """ + Get a specific user from the registry. Return `None` if the user does not exist. + + Args: + name: Username of user to get. + """ + result = util.get_client().users_get(name=name) + if result is None: + return None + return types.User(**result.model_dump()) + + +def list() -> List[types.User]: + """ + Get a list of all users in the registry. + """ + return [types.User(**u.model_dump()) for u in util.get_client().users_list()] + + +def create(name: str, email: str, role: str, extra_roles: Optional[List[str]] = None) -> types.User: + """ + Create a new user in the registry. + + Args: + name: Username of user to create. + email: Email of user to create. + role: Active role of the user. + extra_roles: Additional roles to assign to the user. + """ + + return util.handle_user_mutation( + util.get_client().users_create( + input=_graphql_client.UserInput(name=name, email=email, role=role, extraRoles=extra_roles) + ) + ) + + +def delete(name: str) -> None: + """ + Delete user from the registry. + + Args: + name: Username of user to delete. + """ + result = util.get_client().users_delete(name=name) + if result is None: + raise exceptions.UserNotFoundError + util.handle_errors(result.delete) + + +def set_email(name: str, email: str) -> types.User: + """ + Set the email for a user. + + Args: + name: Username of user to update. + email: Email to set for the user. + """ + result = util.get_client().users_set_email(name=name, email=email) + if result is None: + raise exceptions.UserNotFoundError + return util.handle_user_mutation(result.set_email) + + +def set_admin(name: str, admin: bool) -> types.User: + """ + Set the admin status for a user. + + Args: + name: Username of user to update. + admin: Admin status to set for the user. + """ + result = util.get_client().users_set_admin(name=name, admin=admin) + if result is None: + raise exceptions.UserNotFoundError + return util.handle_user_mutation(result.set_admin) + + +def set_active(name: str, active: bool) -> types.User: + """ + Set the active status for a user. + + Args: + name: Username of user to update. + active: Active status to set for the user. + """ + result = util.get_client().users_set_active(name=name, active=active) + if result is None: + raise exceptions.UserNotFoundError + return util.handle_user_mutation(result.set_active) + + +def reset_password(name: str) -> None: + """ + Reset the password for a user. + + Args: + name: Username of user to update. + """ + result = util.get_client().users_reset_password(name=name) + if result is None: + raise exceptions.UserNotFoundError + util.handle_errors(result.reset_password) + + +def set_role( + name: str, + role: str, + extra_roles: Optional[List[str]] = None, + *, + append: bool = False, +) -> types.User: + """ + Set the active and extra roles for a user. + + Args: + name: Username of user to update. + role: Role to be set as the active role. + extra_roles: Additional roles to assign to the user. + append: If True, append the extra roles to the existing roles. If False, replace the existing roles. + """ + result = util.get_client().users_set_role(name=name, role=role, extra_roles=extra_roles, append=append) + if result is None: + raise exceptions.UserNotFoundError + return util.handle_user_mutation(result.set_role) + + +def add_roles(name: str, roles: List[str]) -> types.User: + """ + Add roles to a user. + + Args: + name: Username of user to update. + roles: Roles to add to the user. + """ + result = util.get_client().users_add_roles(name=name, roles=roles) + if result is None: + raise exceptions.UserNotFoundError + return util.handle_user_mutation(result.add_roles) + + +def remove_roles( + name: str, + roles: List[str], + fallback: Optional[str] = None, +) -> types.User: + """ + Remove roles from a user. + + Args: + name: Username of user to update. + roles: Roles to remove from the user. + fallback: If set, the role to assign to the user if the active role is removed. + """ + result = util.get_client().users_remove_roles(name=name, roles=roles, fallback=fallback) + if result is None: + raise exceptions.UserNotFoundError + return util.handle_user_mutation(result.remove_roles) diff --git a/api/python/quilt3/admin/util.py b/api/python/quilt3/admin/util.py new file mode 100644 index 00000000000..bf3a3f9c988 --- /dev/null +++ b/api/python/quilt3/admin/util.py @@ -0,0 +1,15 @@ +from . import _graphql_client, exceptions, types + + +def handle_errors(result: _graphql_client.BaseModel) -> _graphql_client.BaseModel: + if isinstance(result, (_graphql_client.InvalidInputSelection, _graphql_client.OperationErrorSelection)): + raise exceptions.Quilt3AdminError(result) + return result + + +def handle_user_mutation(result: _graphql_client.BaseModel) -> types.User: + return types.User(**handle_errors(result).model_dump()) + + +def get_client(): + return _graphql_client.Client() diff --git a/api/python/tests/test_admin_api.py b/api/python/tests/test_admin_api.py index 93b0ca972ea..69446664b1b 100644 --- a/api/python/tests/test_admin_api.py +++ b/api/python/tests/test_admin_api.py @@ -5,6 +5,7 @@ import pytest from quilt3 import admin +from quilt3.admin import _graphql_client UNMANAGED_ROLE = { "__typename": "UnmanagedRole", @@ -98,8 +99,8 @@ def mock_client(data, operation_name, variables=None): def test_get_roles(): - with mock_client({"roles": [UNMANAGED_ROLE, MANAGED_ROLE]}, "getRoles"): - assert admin.get_roles() == [ + with mock_client({"roles": [UNMANAGED_ROLE, MANAGED_ROLE]}, "rolesList"): + assert admin.roles.list() == [ admin.UnmanagedRole(**_as_dataclass_kwargs(UNMANAGED_ROLE)), admin.ManagedRole(**_as_dataclass_kwargs(MANAGED_ROLE)), ] @@ -113,13 +114,13 @@ def test_get_roles(): ], ) def test_get_user(data, result): - with mock_client(_make_nested_dict("admin.user.get", data), "getUser", variables={"name": "test"}): - assert admin.get_user("test") == result + with mock_client(_make_nested_dict("admin.user.get", data), "usersGet", variables={"name": "test"}): + assert admin.users.get("test") == result def test_get_users(): - with mock_client(_make_nested_dict("admin.user.list", [USER]), "getUsers"): - assert admin.get_users() == [admin.User(**_as_dataclass_kwargs(USER))] + with mock_client(_make_nested_dict("admin.user.list", [USER]), "usersList"): + assert admin.users.list() == [admin.User(**_as_dataclass_kwargs(USER))] @pytest.mark.parametrize( @@ -132,18 +133,18 @@ def test_get_users(): def test_create_user(data, result): with mock_client( _make_nested_dict("admin.user.create", data), - "createUser", + "usersCreate", variables={ - "input": admin._graphql_client.UserInput( + "input": _graphql_client.UserInput( name="test", email="test@example.com", role="UnmanagedRole", extraRoles=[] ) }, ): if isinstance(result, type) and issubclass(result, Exception): with pytest.raises(result): - admin.create_user("test", "test@example.com", "UnmanagedRole", []) + admin.users.create("test", "test@example.com", "UnmanagedRole", []) else: - assert admin.create_user("test", "test@example.com", "UnmanagedRole", []) == result + assert admin.users.create("test", "test@example.com", "UnmanagedRole", []) == result @pytest.mark.parametrize( @@ -153,11 +154,11 @@ def test_create_user(data, result): def test_delete_user(data, result): with mock_client( _make_nested_dict("admin.user.mutate.delete", data), - "deleteUser", + "usersDelete", variables={"name": "test"}, ): with pytest.raises(result): - admin.delete_user("test") + admin.users.delete("test") @pytest.mark.parametrize( @@ -174,14 +175,14 @@ def test_set_user_email(data, result): if data is None else _make_nested_dict("admin.user.mutate.setEmail", data) ), - "setUserEmail", + "usersSetEmail", variables={"name": "test", "email": "test@example.com"}, ): if isinstance(result, type) and issubclass(result, Exception): with pytest.raises(result): - admin.set_user_email("test", "test@example.com") + admin.users.set_email("test", "test@example.com") else: - assert admin.set_user_email("test", "test@example.com") == result + assert admin.users.set_email("test", "test@example.com") == result @pytest.mark.parametrize( @@ -198,14 +199,14 @@ def test_set_user_admin(data, result): if data is None else _make_nested_dict("admin.user.mutate.setAdmin", data) ), - "setUserAdmin", + "usersSetAdmin", variables={"name": "test", "admin": True}, ): if isinstance(result, type) and issubclass(result, Exception): with pytest.raises(result): - admin.set_user_admin("test", True) + admin.users.set_admin("test", True) else: - assert admin.set_user_admin("test", True) == result + assert admin.users.set_admin("test", True) == result @pytest.mark.parametrize( @@ -222,14 +223,14 @@ def test_set_user_active(data, result): if data is None else _make_nested_dict("admin.user.mutate.setActive", data) ), - "setUserActive", + "usersSetActive", variables={"name": "test", "active": True}, ): if isinstance(result, type) and issubclass(result, Exception): with pytest.raises(result): - admin.set_user_active("test", True) + admin.users.set_active("test", True) else: - assert admin.set_user_active("test", True) == result + assert admin.users.set_active("test", True) == result @pytest.mark.parametrize( @@ -243,14 +244,14 @@ def test_reset_user_password(data, result): if data is None else _make_nested_dict("admin.user.mutate.resetPassword", data) ), - "resetUserPassword", + "usersResetPassword", variables={"name": "test"}, ): if isinstance(result, type) and issubclass(result, Exception): with pytest.raises(result): - admin.reset_user_password("test") + admin.users.reset_password("test") else: - assert admin.reset_user_password("test") == result + assert admin.users.reset_password("test") == result @pytest.mark.parametrize( @@ -267,14 +268,14 @@ def test_set_role(data, result): if data is None else _make_nested_dict("admin.user.mutate.setRole", data) ), - "setRole", + "usersSetRole", variables={"name": "test", "role": "UnamangedRole", "extraRoles": [], "append": True}, ): if isinstance(result, type) and issubclass(result, Exception): with pytest.raises(result): - admin.set_role("test", "UnamangedRole", [], append=True) + admin.users.set_role("test", "UnamangedRole", [], append=True) else: - assert admin.set_role("test", "UnamangedRole", [], append=True) == result + assert admin.users.set_role("test", "UnamangedRole", [], append=True) == result @pytest.mark.parametrize( @@ -291,14 +292,14 @@ def test_add_roles(data, result): if data is None else _make_nested_dict("admin.user.mutate.addRoles", data) ), - "addRoles", + "usersAddRoles", variables={"name": "test", "roles": ["ManagedRole"]}, ): if isinstance(result, type) and issubclass(result, Exception): with pytest.raises(result): - admin.add_roles("test", ["ManagedRole"]) + admin.users.add_roles("test", ["ManagedRole"]) else: - assert admin.add_roles("test", ["ManagedRole"]) == result + assert admin.users.add_roles("test", ["ManagedRole"]) == result @pytest.mark.parametrize( @@ -315,11 +316,11 @@ def test_remove_roles(data, result): if data is None else _make_nested_dict("admin.user.mutate.removeRoles", data) ), - "removeRoles", + "usersRemoveRoles", variables={"name": "test", "roles": ["ManagedRole"], "fallback": "UnamanagedRole"}, ): if isinstance(result, type) and issubclass(result, Exception): with pytest.raises(result): - admin.remove_roles("test", ["ManagedRole"], fallback="UnamanagedRole") + admin.users.remove_roles("test", ["ManagedRole"], fallback="UnamanagedRole") else: - assert admin.remove_roles("test", ["ManagedRole"], fallback="UnamanagedRole") == result + assert admin.users.remove_roles("test", ["ManagedRole"], fallback="UnamanagedRole") == result diff --git a/docs/api-reference/Admin.md b/docs/api-reference/Admin.md index 232433d9c0e..2ac177a5daf 100644 --- a/docs/api-reference/Admin.md +++ b/docs/api-reference/Admin.md @@ -1,7 +1,5 @@ -# quilt3.admin - -APIs for Quilt administrators. 'Registry' refers to Quilt stack backend services, including identity management. +# quilt3.admin.types ## ManagedRole(id: str, name: str, arn: str, typename\_\_: Literal['ManagedRole']) -> None {#ManagedRole} @@ -10,15 +8,21 @@ APIs for Quilt administrators. 'Registry' refers to Quilt stack backend services ## UnmanagedRole(id: str, name: str, arn: str, typename\_\_: Literal['UnmanagedRole']) -> None {#UnmanagedRole} -## User(name: str, email: str, date\_joined: datetime.datetime, last\_login: datetime.datetime, is\_active: bool, is\_admin: bool, is\_sso\_only: bool, is\_service: bool, role: Optional[Annotated[Union[quilt3.admin.ManagedRole, quilt3.admin.UnmanagedRole], FieldInfo(annotation=NoneType, required=True, discriminator='typename\_\_')]], extra\_roles: List[Annotated[Union[quilt3.admin.ManagedRole, quilt3.admin.UnmanagedRole], FieldInfo(annotation=NoneType, required=True, discriminator='typename\_\_')]]) -> None {#User} +## User(name: str, email: str, date\_joined: datetime.datetime, last\_login: datetime.datetime, is\_active: bool, is\_admin: bool, is\_sso\_only: bool, is\_service: bool, role: Optional[Annotated[Union[quilt3.admin.types.ManagedRole, quilt3.admin.types.UnmanagedRole], FieldInfo(annotation=NoneType, required=True, discriminator='typename\_\_')]], extra\_roles: List[Annotated[Union[quilt3.admin.types.ManagedRole, quilt3.admin.types.UnmanagedRole], FieldInfo(annotation=NoneType, required=True, discriminator='typename\_\_')]]) -> None {#User} + + +# quilt3.admin.roles -## get\_roles() -> List[Union[quilt3.admin.ManagedRole, quilt3.admin.UnmanagedRole]] {#get\_roles} +## list() -> List[Union[quilt3.admin.types.ManagedRole, quilt3.admin.types.UnmanagedRole]] {#list} Get a list of all roles in the registry. -## get\_user(name: str) -> Optional[quilt3.admin.User] {#get\_user} +# quilt3.admin.users + + +## get(name: str) -> Optional[quilt3.admin.types.User] {#get} Get a specific user from the registry. Return `None` if the user does not exist. @@ -27,12 +31,12 @@ __Arguments__ * __name__: Username of user to get. -## get\_users() -> List[quilt3.admin.User] {#get\_users} +## list() -> List[quilt3.admin.types.User] {#list} Get a list of all users in the registry. -## create\_user(name: str, email: str, role: str, extra\_roles: Optional[List[str]] = None) -> quilt3.admin.User {#create\_user} +## create(name: str, email: str, role: str, extra\_roles: Optional[List[str]] = None) -> quilt3.admin.types.User {#create} Create a new user in the registry. @@ -44,7 +48,7 @@ __Arguments__ * __extra_roles__: Additional roles to assign to the user. -## delete\_user(name: str) -> None {#delete\_user} +## delete(name: str) -> None {#delete} Delete user from the registry. @@ -53,7 +57,7 @@ __Arguments__ * __name__: Username of user to delete. -## set\_user\_email(name: str, email: str) -> quilt3.admin.User {#set\_user\_email} +## set\_email(name: str, email: str) -> quilt3.admin.types.User {#set\_email} Set the email for a user. @@ -63,7 +67,7 @@ __Arguments__ * __email__: Email to set for the user. -## set\_user\_admin(name: str, admin: bool) -> quilt3.admin.User {#set\_user\_admin} +## set\_admin(name: str, admin: bool) -> quilt3.admin.types.User {#set\_admin} Set the admin status for a user. @@ -73,7 +77,7 @@ __Arguments__ * __admin__: Admin status to set for the user. -## set\_user\_active(name: str, active: bool) -> quilt3.admin.User {#set\_user\_active} +## set\_active(name: str, active: bool) -> quilt3.admin.types.User {#set\_active} Set the active status for a user. @@ -83,7 +87,7 @@ __Arguments__ * __active__: Active status to set for the user. -## reset\_user\_password(name: str) -> None {#reset\_user\_password} +## reset\_password(name: str) -> None {#reset\_password} Reset the password for a user. @@ -92,7 +96,7 @@ __Arguments__ * __name__: Username of user to update. -## set\_role(name: str, role: str, extra\_roles: Optional[List[str]] = None, \*, append: bool = False) -> quilt3.admin.User {#set\_role} +## set\_role(name: str, role: str, extra\_roles: Optional[List[str]] = None, \*, append: bool = False) -> quilt3.admin.types.User {#set\_role} Set the active and extra roles for a user. @@ -104,7 +108,7 @@ __Arguments__ * __append__: If True, append the extra roles to the existing roles. If False, replace the existing roles. -## add\_roles(name: str, roles: List[str]) -> quilt3.admin.User {#add\_roles} +## add\_roles(name: str, roles: List[str]) -> quilt3.admin.types.User {#add\_roles} Add roles to a user. @@ -114,7 +118,7 @@ __Arguments__ * __roles__: Roles to add to the user. -## remove\_roles(name: str, roles: List[str], fallback: Optional[str] = None) -> quilt3.admin.User {#remove\_roles} +## remove\_roles(name: str, roles: List[str], fallback: Optional[str] = None) -> quilt3.admin.types.User {#remove\_roles} Remove roles from a user. diff --git a/gendocs/pydocmd.yml b/gendocs/pydocmd.yml index da211f1b4e7..6c0e1253f99 100644 --- a/gendocs/pydocmd.yml +++ b/gendocs/pydocmd.yml @@ -31,7 +31,9 @@ generate: - quilt3.packages.PackageEntry+ - Admin.md: - - quilt3.admin+ + - quilt3.admin.types+ + - quilt3.admin.roles+ + - quilt3.admin.users+ # MkDocs pages configuration. The `<<` operator is sugar added by pydocmd # that allows you to use an external Markdown file (eg. your project's README)