Warning
This document is for an old release of Galaxy. You can alternatively view this page in the latest release if it exists or view the top of the latest release's documentation.
galaxy.webapps.galaxy.services package
Submodules
galaxy.webapps.galaxy.services.authenticate module
- class galaxy.webapps.galaxy.services.authenticate.APIKeyResponse(*, api_key: str)[source]
Bases:
BaseModel
- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class galaxy.webapps.galaxy.services.authenticate.AuthenticationService(user_manager: UserManager, auth_manager: AuthManager, api_keys_manager: ApiKeyManager)[source]
Bases:
object
- __init__(user_manager: UserManager, auth_manager: AuthManager, api_keys_manager: ApiKeyManager)[source]
galaxy.webapps.galaxy.services.base module
- class galaxy.webapps.galaxy.services.base.ServiceBase(security: IdEncodingHelper | None = None)[source]
Bases:
object
Base class with common logic and utils reused by other services.
- A service class:
Provides top level operations (Index, Show, Delete…) that are usually consumed directly by the API controllers or other services.
Uses a combination of managers to perform the operations and avoids accessing the database layer directly.
Can speak ‘pydantic’ and has rich type annotations to be explicit about the required parameters and outputs of each operation.
- __init__(security: IdEncodingHelper | None = None)[source]
- property security: IdEncodingHelper
- decode_id(id: str[str], kind: str | None = None) int [source]
Decodes a previously encoded database ID.
- encode_all_ids(rval, recursive: bool = False)[source]
Encodes all integer values in the dict rval whose keys are ‘id’ or end with ‘_id’
It might be useful to turn this in to a decorator
- build_order_by(manager: SortableManager, order_by_query: str | None = None)[source]
Returns an ORM compatible order_by clause using the order attribute and the given manager.
The manager has to implement the parse_order_by function to support all the sortable model attributes.
- get_class(class_name)[source]
Returns the class object that a string denotes. Without this method, we’d have to do eval(<class_name>).
- get_object(trans, id, class_name, check_ownership=False, check_accessible=False, deleted=None)[source]
Convenience method to get a model object with the specified checks.
- check_user_is_authenticated(trans: ProvidesUserContext)[source]
Raises an exception if the request is anonymous.
- get_authenticated_user(trans: ProvidesUserContext) User [source]
Gets the authenticated user and prevents access from anonymous users.
- class galaxy.webapps.galaxy.services.base.ServedExportStore(export_store, export_target)[source]
Bases:
tuple
- export_store: ModelExportStore
Alias for field number 0
- galaxy.webapps.galaxy.services.base.model_store_storage_target(short_term_storage_allocator: ShortTermStorageAllocator, file_name: str, model_store_format: str) ShortTermStorageTarget [source]
- galaxy.webapps.galaxy.services.base.async_task_summary(async_result: AsyncResult) AsyncTaskResultSummary [source]
galaxy.webapps.galaxy.services.dataset_collections module
galaxy.webapps.galaxy.services.datasets module
galaxy.webapps.galaxy.services.histories module
Bases:
ShareableService
alias of
ShareHistoryWithStatus
- class galaxy.webapps.galaxy.services.histories.HistoriesService(security: IdEncodingHelper, manager: HistoryManager, user_manager: UserManager, serializer: HistorySerializer, deserializer: HistoryDeserializer, citations_manager: CitationsManager, history_export_manager: HistoryExportManager, filters: HistoryFilters, short_term_storage_allocator: ShortTermStorageAllocator, notification_manager: NotificationManager)[source]
Bases:
ServiceBase
,ConsumesModelStores
,ServesExportStores
Common interface/service logic for interactions with histories in the context of the API.
Provides the logic of the actions invoked by API controllers and uses type definitions and pydantic models to declare its parameters and return types.
- __init__(security: IdEncodingHelper, manager: HistoryManager, user_manager: UserManager, serializer: HistorySerializer, deserializer: HistoryDeserializer, citations_manager: CitationsManager, history_export_manager: HistoryExportManager, filters: HistoryFilters, short_term_storage_allocator: ShortTermStorageAllocator, notification_manager: NotificationManager)[source]
- index(trans: ProvidesHistoryContext, serialization_params: SerializationParams, filter_query_params: FilterQueryParams, deleted_only: bool | None = False, all_histories: bool | None = False)[source]
Return a collection of histories for the current user. Additional filters can be applied.
- Parameters:
deleted_only (optional boolean) – if True, show only deleted histories, if False, non-deleted
Note
Anonymous users are allowed to get their current history
- index_query(trans, payload: HistoryIndexQueryPayload, serialization_params: SerializationParams, include_total_count: bool = False) Tuple[List[CustomHistoryView | galaxy.schema.schema.HistoryDetailed | galaxy.schema.schema.HistorySummary[CustomHistoryView | HistoryDetailed | HistorySummary]], int] [source]
Return a list of History accessible by the user
- Return type:
- Returns:
dictionaries containing History details
- create(trans: ProvidesHistoryContext, payload: CreateHistoryPayload, serialization_params: SerializationParams)[source]
Create a new history from scratch, by copying an existing one or by importing from URL or File depending on the provided parameters in the payload.
- create_from_store(trans, payload: CreateHistoryFromStore, serialization_params: SerializationParams) CustomHistoryView | galaxy.schema.schema.HistoryDetailed | galaxy.schema.schema.HistorySummary[CustomHistoryView | HistoryDetailed | HistorySummary] [source]
- create_from_store_async(trans, payload: CreateHistoryFromStore) AsyncTaskResultSummary [source]
- show(trans: ProvidesHistoryContext, serialization_params: SerializationParams, history_id: int[int] | None = None)[source]
Returns detailed information about the history with the given encoded id. If no id is provided, then the most recently used history will be returned.
- Parameters:
history_id – the encoded id of the history to query or None to use the most recently used
serialization_params – contains the optional view, keys and default_view for serialization
- Returns:
detailed history information
- prepare_download(trans: ProvidesHistoryContext, history_id: int[int], payload: StoreExportPayload) AsyncFile [source]
- write_store(trans: ProvidesHistoryContext, history_id: int[int], payload: WriteStoreToPayload) AsyncTaskResultSummary [source]
- update(trans: ProvidesHistoryContext, history_id: int[int], payload, serialization_params: SerializationParams)[source]
Updates the values for the history with the given
id
- Parameters:
history_id – the encoded id of the history to update
payload –
a dictionary containing any or all the fields in
galaxy.model.History.to_dict()
and/or the following:annotation: an annotation for the history
serialization_params – contains the optional view, keys and default_view for serialization
- Returns:
an error object if an error occurred or a dictionary containing any values that were different from the original and, therefore, updated
- delete(trans: ProvidesHistoryContext, history_id: int[int], serialization_params: SerializationParams, purge: bool = False)[source]
Delete the history with the given
id
Note
Stops all active jobs in the history if purge is set.
You can purge a history, removing all it’s datasets from disk (if unshared), by passing in
purge=True
in the url.
- undelete(trans: ProvidesHistoryContext, history_id: int[int], serialization_params: SerializationParams)[source]
Undelete history (that hasn’t been purged) with the given
id
- Parameters:
history_id – the encoded id of the history to undelete
serialization_params – contains the optional view, keys and default_view for serialization
- Returns:
the undeleted history
Return all histories that are shared with the current user. The results can be filtered.
- count(trans: ProvidesHistoryContext)[source]
Returns number of histories for the current user.
- published(trans: ProvidesHistoryContext, serialization_params: SerializationParams, filter_query_params: FilterQueryParams)[source]
Return all histories that are published. The results can be filtered.
- citations(trans: ProvidesHistoryContext, history_id: int[int])[source]
Return all the citations for the tools used to produce the datasets in the history.
- index_exports(trans: ProvidesHistoryContext, history_id: int[int], use_tasks: bool = False, limit: int | None = None, offset: int | None = None)[source]
- archive_export(trans, history_id: int[int], payload: ExportHistoryArchivePayload | None = None) Tuple[JobExportHistoryArchiveModel | JobIdResponse, bool] [source]
start job (if needed) to create history export for corresponding history.
- Parameters:
history_id – the encoded id of the history to export
- Returns:
object containing url to fetch export from.
- get_ready_history_export(trans: ProvidesHistoryContext, history_id: int[int], jeha_id: int[int] | typing_extensions.Literal[latest]) JobExportHistoryArchive [source]
Returns the exported history archive information if it’s ready or raises an exception if not.
- get_archive_download_path(trans: ProvidesHistoryContext, jeha: JobExportHistoryArchive) str [source]
If ready and available, return raw contents of exported history using a generator function.
- get_archive_media_type(jeha: JobExportHistoryArchive)[source]
- legacy_archive_download(trans: ProvidesHistoryContext, history_id: int[int], jeha_id: int[int])[source]
If ready and available, return raw contents of exported history.
- get_custom_builds_metadata(trans: ProvidesHistoryContext, history_id: int[int]) CustomBuildsMetadataResponse [source]
Returns metadata for custom builds.
- archive_history(trans: ProvidesHistoryContext, history_id: int[int], payload: ArchiveHistoryRequestPayload | None = None) ArchivedHistorySummary | ArchivedHistoryDetailed | Any [source]
Marks the history with the given id as archived and optionally associates it with the given archive export record in the payload.
Archived histories are not part of the active histories of the user, so they won’t be shown to the user by default.
- restore_archived_history(trans: ProvidesHistoryContext, history_id: int[int], force: bool | None = False) CustomHistoryView | galaxy.schema.schema.HistoryDetailed | galaxy.schema.schema.HistorySummary[CustomHistoryView | HistoryDetailed | HistorySummary] [source]
- get_archived_histories(trans: ProvidesHistoryContext, serialization_params: SerializationParams, filter_query_params: FilterQueryParams, include_total_matches: bool = False) Tuple[List[ArchivedHistorySummary | ArchivedHistoryDetailed | Any], int | None] [source]
galaxy.webapps.galaxy.services.history_contents module
galaxy.webapps.galaxy.services.invocations module
galaxy.webapps.galaxy.services.jobs module
galaxy.webapps.galaxy.services.libraries module
- class galaxy.webapps.galaxy.services.libraries.LibrariesService(security: IdEncodingHelper, folder_manager: FolderManager, library_manager: LibraryManager, role_manager: RoleManager)[source]
Bases:
ServiceBase
,ConsumesModelStores
Common interface/service logic for interactions with libraries (top level) in the context of the API.
Provides the logic of the actions invoked by API controllers and uses type definitions and pydantic models to declare its parameters and return types.
- __init__(security: IdEncodingHelper, folder_manager: FolderManager, library_manager: LibraryManager, role_manager: RoleManager)[source]
- index(trans: ProvidesAppContext, deleted: bool | None = False) LibrarySummaryList [source]
Returns a list of summary data for all libraries.
- Parameters:
deleted (boolean (optional)) – if True, show only
deleted
libraries, if False show onlynon-deleted
- Returns:
list of dictionaries containing library information
- Return type:
- show(trans, id: int[int]) LibrarySummary [source]
Returns detailed information about a library.
- create(trans, payload: CreateLibraryPayload) LibrarySummary [source]
Creates a new library.
Note
Currently, only admin users can create libraries.
- create_from_store(trans, payload: CreateLibrariesFromStore) List[LibrarySummary] [source]
- update(trans, id: int[int], payload: UpdateLibraryPayload) LibrarySummary [source]
Updates the library with given
id
with the data in the payload.
- delete(trans, id: int[int], undelete: bool | None = False) LibrarySummary [source]
Marks the library with the given
id
as deleted (or removes the deleted mark if the undelete param is true)Note
Currently, only admin users can un/delete libraries.
- Parameters:
undelete (bool) – (optional) flag specifying whether the item should be deleted or undeleted, defaults to false:
- get_permissions(trans, id: int[int], scope: LibraryPermissionScope | None = LibraryPermissionScope.current, is_library_access: bool | None = False, page: int = 1, page_limit: int = 10, query: str | None = None) LibraryCurrentPermissions | LibraryAvailablePermissions [source]
Load all permissions for the given library id and return it.
- Parameters:
id (an encoded id string) – the encoded id of the library
scope (string) – either ‘current’ or ‘available’
is_library_access (bool) – indicates whether the roles available for the library access are requested
- Returns:
dictionary with all applicable permissions’ values
- Return type:
dictionary
- Raises:
InsufficientPermissionsException
- set_permissions(trans, id: int[int], payload: Dict[str, Any]) LibraryLegacySummary | LibraryCurrentPermissions [source]
Set permissions of the given library to the given role ids.
- Parameters:
id (an encoded id string) – the encoded id of the library to set the permissions of
payload –
dictionary structure containing:
- param action:
(required) describes what action should be performed available actions: remove_restrictions, set_permissions
- type action:
str
- param access_ids[]:
list of Role.id defining roles that should have access permission on the library
- type access_ids[]:
string or list
- param add_ids[]:
list of Role.id defining roles that should have add item permission on the library
- type add_ids[]:
string or list
- param manage_ids[]:
list of Role.id defining roles that should have manage permission on the library
- type manage_ids[]:
string or list
- param modify_ids[]:
list of Role.id defining roles that should have modify permission on the library
- type modify_ids[]:
string or list
- Type:
dictionary
- Returns:
dict of current roles for all available permission types
- Return type:
dictionary
- Raises:
RequestParameterInvalidException, InsufficientPermissionsException, InternalServerError RequestParameterMissingException
galaxy.webapps.galaxy.services.library_folder_contents module
- class galaxy.webapps.galaxy.services.library_folder_contents.UserFolderPermissions(access: bool, modify: bool, add: bool, manage: bool)[source]
Bases:
object
- class galaxy.webapps.galaxy.services.library_folder_contents.LibraryFolderContentsService(security: IdEncodingHelper, hda_manager: HDAManager, folder_manager: FolderManager)[source]
Bases:
ServiceBase
,UsesLibraryMixinItems
Interface/service shared by controllers for interacting with the contents of a library folder.
- __init__(security: IdEncodingHelper, hda_manager: HDAManager, folder_manager: FolderManager)[source]
- get_object(trans, id, class_name, check_ownership=False, check_accessible=False, deleted=None)[source]
Convenience method to get a model object with the specified checks.
- index(trans: ProvidesUserContext, folder_id: int[int], payload: LibraryFolderContentsIndexQueryPayload) LibraryFolderContentsIndexResult [source]
Displays a collection (list) of a folder’s contents (files and folders). Encoded folder ID is prepended with ‘F’ if it is a folder as opposed to a data set which does not have it. Full path is provided in response as a separate object providing data for breadcrumb path building.
- create(trans: ProvidesUserContext, folder_id: int[int], payload: CreateLibraryFilePayload)[source]
Create a new library file from an HDA/HDCA.
galaxy.webapps.galaxy.services.library_folders module
- class galaxy.webapps.galaxy.services.library_folders.LibraryFoldersService(security: IdEncodingHelper, folder_manager: FolderManager, role_manager: RoleManager)[source]
Bases:
ServiceBase
Common interface/service logic for interactions with library folders in the context of the API. Provides the logic of the actions invoked by API controllers and uses type definitions and pydantic models to declare its parameters and return types.
- __init__(security: IdEncodingHelper, folder_manager: FolderManager, role_manager: RoleManager)[source]
- show(trans, folder_id: int[int]) LibraryFolderDetails [source]
Displays information about a folder.
- Parameters:
id (an encoded id string (has to be prefixed by 'F')) – the folder’s encoded id (required)
- Returns:
dictionary including details of the folder
- Return type:
- create(trans, parent_folder_id: int[int], payload: CreateLibraryFolderPayload) LibraryFolderDetails [source]
Create a new folder object underneath the one specified in the parameters.
- Parameters:
parent_folder_id – (required) the parent folder’s id
payload –
dictionary structure containing:
- param name:
(required) the name of the new folder
- type name:
str
- param description:
the description of the new folder
- type description:
str
:type dictionary :returns: information about newly created folder, notably including ID :rtype: dictionary :raises: RequestParameterMissingException
- get_permissions(trans, folder_id: int[int], scope: LibraryPermissionScope | None = LibraryPermissionScope.current, page: int = 1, page_limit: int = 10, query: str | None = None) LibraryFolderCurrentPermissions | LibraryAvailablePermissions [source]
Load all permissions for the given folder id and return it.
- Parameters:
folder_id – the encoded id of the folder
scope (string) – either ‘current’ or ‘available’
- Returns:
dictionary with all applicable permissions’ values
- Return type:
dictionary
- Raises:
InsufficientPermissionsException
- set_permissions(trans, folder_id: int[int], payload: dict) LibraryFolderCurrentPermissions [source]
Set permissions of the given folder to the given role ids.
- Parameters:
folder_id – the encoded id of the folder to set the permissions of
payload –
dictionary structure containing:
- param action:
(required) describes what action should be performed
- type action:
string
- param add_ids[]:
list of Role.id defining roles that should have add item permission on the folder
- type add_ids[]:
string or list
- param manage_ids[]:
list of Role.id defining roles that should have manage permission on the folder
- type manage_ids[]:
string or list
- param modify_ids[]:
list of Role.id defining roles that should have modify permission on the folder
- type modify_ids[]:
string or list
:type dictionary :returns: dict of current roles for all available permission types. :rtype: dictionary :raises: RequestParameterInvalidException, InsufficientPermissionsException, RequestParameterMissingException
- delete(trans, folder_id: int[int], undelete: bool | None = False) LibraryFolderDetails [source]
Mark the folder with the given
encoded_folder_id
as deleted (or remove the deleted mark if the undelete param is true).Note
Currently, only admin users can un/delete folders.
- Parameters:
folder_id – the encoded id of the folder to un/delete
undelete (bool) – (optional) flag specifying whether the item should be deleted or undeleted, defaults to false:
- Returns:
detailed folder information
- Return type:
dictionary
- update(trans, folder_id: int[int], payload: UpdateLibraryFolderPayload) LibraryFolderDetails [source]
Update the folder with id
folder_id
with the data in the payload.Note
Currently, only administrators can update library folders. Also the folder must not be deleted.
- param folder_id:
the encoded id of the folder
- param payload:
(required) dictionary structure containing:: ‘name’: new folder’s name, cannot be empty ‘description’: new folder’s description
- type payload:
dict
- returns:
detailed folder information
- rtype:
dict
- raises:
RequestParameterMissingException
galaxy.webapps.galaxy.services.pages module
- class galaxy.webapps.galaxy.services.pages.PagesService(security: IdEncodingHelper, manager: PageManager, serializer: PageSerializer, short_term_storage_allocator: ShortTermStorageAllocator, notification_manager: NotificationManager)[source]
Bases:
ServiceBase
Common interface/service logic for interactions with pages in the context of the API.
Provides the logic of the actions invoked by API controllers and uses type definitions and pydantic models to declare its parameters and return types.
- __init__(security: IdEncodingHelper, manager: PageManager, serializer: PageSerializer, short_term_storage_allocator: ShortTermStorageAllocator, notification_manager: NotificationManager)[source]
- index(trans, payload: PageIndexQueryPayload, include_total_count: bool = False) Tuple[PageSummaryList, int] [source]
Return a list of Pages viewable by the user
- Return type:
- Returns:
dictionaries containing summary or detailed Page information
- create(trans, payload: CreatePagePayload) PageSummary [source]
Create a page and return Page summary
- delete(trans, id: int[int])[source]
Mark page as deleted
- Parameters:
id – ID of the page to be deleted
- undelete(trans, id: int[int])[source]
Undelete page
- Parameters:
id – ID of the page to be undeleted
- show(trans, id: int[int]) PageDetails [source]
View a page summary and the content of the latest revision
- Parameters:
id – ID of page to be displayed
- Return type:
- Returns:
Dictionary return of the Page.to_dict call with the ‘content’ field populated by the most recent revision
galaxy.webapps.galaxy.services.quotas module
- class galaxy.webapps.galaxy.services.quotas.QuotasService(security: IdEncodingHelper, quota_manager: QuotaManager)[source]
Bases:
ServiceBase
Interface/service object shared by controllers for interacting with quotas.
- __init__(security: IdEncodingHelper, quota_manager: QuotaManager)[source]
- index(trans: ProvidesUserContext, deleted: bool = False) QuotaSummaryList [source]
Displays a list of quotas.
- show(trans: ProvidesUserContext, id: int[int], deleted: bool = False) QuotaDetails [source]
Displays information about a quota.
- create(trans: ProvidesUserContext, params: CreateQuotaParams) CreateQuotaResult [source]
Creates a new quota.
- update(trans: ProvidesUserContext, id: int[int], params: UpdateQuotaParams) str [source]
Modifies a quota.
- delete(trans: ProvidesUserContext, id: int[int], payload: DeleteQuotaPayload | None = None) str [source]
Marks a quota as deleted.
galaxy.webapps.galaxy.services.sharable module
Bases:
object
Provides the common logic used by the API to share any kind of resource with other users.
The Manager class of the particular resource must implement the SharableModelManager and have a compatible SharableModelSerializer implementation.
alias of
ShareWithStatus
Gets the current sharing status of the item with the given id.
Makes this item accessible by link. If this item contains other elements they will be publicly accessible too.
Makes this item publicly accessible. If this item contains other elements they will be publicly accessible too.
Bases:
object
galaxy.webapps.galaxy.services.tools module
- class galaxy.webapps.galaxy.services.tools.ToolsService(config: GalaxyAppConfiguration, toolbox_search: ToolBoxSearch, security: IdEncodingHelper, history_manager: HistoryManager)[source]
Bases:
ServiceBase
- __init__(config: GalaxyAppConfiguration, toolbox_search: ToolBoxSearch, security: IdEncodingHelper, history_manager: HistoryManager)[source]
- create_fetch(trans: ProvidesHistoryContext, fetch_payload: FetchDataFormPayload | FetchDataPayload, files: List[UploadFile] | None = None)[source]
galaxy.webapps.galaxy.services.users module
- class galaxy.webapps.galaxy.services.users.UsersService(security: IdEncodingHelper, user_manager: UserManager, api_key_manager: ApiKeyManager, user_serializer: UserSerializer, user_deserializer: UserDeserializer, quota_agent: QuotaAgent)[source]
Bases:
ServiceBase
Common interface/service logic for interactions with users in the context of the API.
Provides the logic of the actions invoked by API controllers and uses type definitions and pydantic models to declare its parameters and return types.
- __init__(security: IdEncodingHelper, user_manager: UserManager, api_key_manager: ApiKeyManager, user_serializer: UserSerializer, user_deserializer: UserDeserializer, quota_agent: QuotaAgent)[source]
- recalculate_disk_usage(trans: ProvidesUserContext, user_id: int)[source]
- get_api_key(trans: ProvidesUserContext, user_id: int) APIKeyModel | None [source]
Returns the current API key or None if the user doesn’t have any valid API key.
- get_or_create_api_key(trans: ProvidesUserContext, user_id: int) str [source]
Returns the current API key (as plain string) or creates a new one.
- create_api_key(trans: ProvidesUserContext, user_id: int) APIKeyModel [source]
Creates a new API key for the given user
- delete_api_key(trans: ProvidesUserContext, user_id: int) None [source]
Deletes a particular API key
- get_user(trans: ProvidesUserContext, user_id)[source]
- get_non_anonymous_user_full(trans: ProvidesUserContext, user_id: int[int] | typing_extensions.Literal[current], deleted: bool) User [source]
- get_user_full(trans: ProvidesUserContext, user_id: int[int] | typing_extensions.Literal[current], deleted: bool) User | None [source]
- show_user(trans: ProvidesHistoryContext, user_id: int[int] | typing_extensions.Literal[current], deleted: bool) DetailedUserModel | AnonUserModel [source]
- user_to_detailed_model(user: User) DetailedUserModel [source]
galaxy.webapps.galaxy.services.visualizations module
- class galaxy.webapps.galaxy.services.visualizations.VisualizationsService(security: IdEncodingHelper, manager: VisualizationManager, serializer: VisualizationSerializer, notification_manager: NotificationManager)[source]
Bases:
ServiceBase
Common interface/service logic for interactions with visualizations in the context of the API.
Provides the logic of the actions invoked by API controllers and uses type definitions and pydantic models to declare its parameters and return types.
- __init__(security: IdEncodingHelper, manager: VisualizationManager, serializer: VisualizationSerializer, notification_manager: NotificationManager)[source]