Globus Timer#

class globus_sdk.TimerClient(*, environment: Optional[str] = None, base_url: Optional[str] = None, authorizer: Optional[GlobusAuthorizer] = None, app_name: Optional[str] = None, transport_params: Optional[dict[str, Any]] = None)[source]#

Bases: BaseClient

Client for the Globus Timer API.

Parameters:
  • authorizer (GlobusAuthorizer) – An authorizer instance used for all calls to Timer

  • app_name (str) – Optional “nice name” for the application. Has no bearing on the semantics of client actions. It is just passed as part of the User-Agent string, and may be useful when debugging issues with the Globus team

  • transport_params (dict) – Options to pass to the transport for this client

Methods

scopes: ScopeBuilder | None = <globus_sdk.scopes.builder.ScopeBuilder object>#

the scopes for this client may be present as a ScopeBuilder

list_jobs(*, query_params: Optional[dict[str, Any]] = None) GlobusHTTPResponse[source]#

GET /jobs/

Examples

>>> timer_client = globus_sdk.TimerClient(...)
>>> jobs = timer_client.list_jobs()
get_job(job_id: Union[UUID, str], *, query_params: Optional[dict[str, Any]] = None) GlobusHTTPResponse[source]#

GET /jobs/<job_id>

Examples

>>> timer_client = globus_sdk.TimerClient(...)
>>> job = timer_client.get_job(job_id)
>>> assert job["job_id"] == job_id
create_job(data: globus_sdk.services.timer.data.TimerJob | dict[str, Any]) GlobusHTTPResponse[source]#

POST /jobs/

Examples

>>> from datetime import datetime, timedelta
>>> transfer_client = TransferClient(...)
>>> transfer_data = TransferData(transfer_client, ...)
>>> timer_client = globus_sdk.TimerClient(...)
>>> job = TimerJob.from_transfer_data(
...     transfer_data,
...     datetime.utcnow(),
...     timedelta(days=14),
...     name="my-timer-job"
... )
>>> timer_result = timer_client.create_job(job)
update_job(job_id: Union[UUID, str], data: dict[str, Any]) GlobusHTTPResponse[source]#

PATCH /jobs/<job_id>

Examples

>>> timer_client = globus_sdk.TimerClient(...)
>>> timer_client.update_job(job_id, {"name": "new name}"})
delete_job(job_id: Union[UUID, str]) GlobusHTTPResponse[source]#

DELETE /jobs/<job_id>

Examples

>>> timer_client = globus_sdk.TimerClient(...)
>>> timer_client.delete_job(job_id)

Helper Objects#

The TimerJob class is used to set up request data to send to Timer for creating a recurring job. Currently only recurring transfers are supported. Thus, a TimerJob should not be initialized directly; use the TimerJob.from_transfer_data() method to construct one to start a Timer job to run a transfer. This will require having a TransferClient nstantiated first – see the Transfer service docs for details and examples.

class globus_sdk.TimerJob(callback_url: str, callback_body: dict[str, Any], start: datetime.datetime | str, interval: datetime.timedelta | int | None, *, name: Optional[str] = None, stop_after: Optional[datetime] = None, stop_after_n: Optional[int] = None, scope: Optional[str] = None)[source]#

Bases: PayloadWrapper

Class for specifying parameters used to create a job in the Timer service. Used as the data argument in create_job.

Timer operates through the Globus Automate API. Crucially, the callback_url parameter should always be the URL used to run an action provider.

Warning

Currently the only supported action provider for this is for Transfer. Thus, users should generally only use the from_transfer_data() method here. Any other usage is meant for internal purposes; proceed with caution!

Parameters:
  • callback_url (str) – URL for the action which the Timer job will use.

  • callback_body (dict) – JSON data which Timer will send to the Action Provider on each invocation

  • start (datetime.datetime or str) – The datetime at which to start the Timer job.

  • interval (datetime.timedelta or int) – The interval at which the Timer job should recur. Interpreted as seconds if specified as an integer. If stop_after_n == 1, i.e. the job is set to run only a single time, then interval must be None.

  • name (str, optional) – A (not necessarily unique) name to identify this job in Timer

  • stop_after (datetime.datetime, optional) – A date after which the Timer job will stop running

  • stop_after_n (int) – A number of executions after which the Timer job will stop

  • scope (str, optional) – Timer defaults to the Transfer ‘all’ scope. Use this parameter to change the scope used by Timer when calling the Transfer Action Provider.

Methods

classmethod from_transfer_data(transfer_data: globus_sdk.services.transfer.data.transfer_data.TransferData | dict[str, Any], start: datetime.datetime | str, interval: datetime.timedelta | int | None, *, name: Optional[str] = None, stop_after: Optional[datetime] = None, stop_after_n: Optional[int] = None, scope: Optional[str] = None, environment: Optional[str] = None) TimerJob[source]#

Specify data to create a Timer job using the parameters for a transfer. Timer will use those parameters to run the defined transfer operation, recurring at the given interval.

Parameters:
  • transfer_data (globus_sdk.TransferData) – A TransferData object. Construct this object exactly as you would normally; Timer will use this to run the recurring transfer.

  • start (datetime.datetime or str) – The datetime at which to start the Timer job.

  • interval (datetime.timedelta or int) – The interval at which the Timer job should recur. Interpreted as seconds if specified as an integer. If stop_after_n == 1, i.e. the job is set to run only a single time, then interval must be None.

  • name (str, optional) – A (not necessarily unique) name to identify this job in Timer

  • stop_after (datetime.datetime, optional) – A date after which the Timer job will stop running

  • stop_after_n (int) – A number of executions after which the Timer job will stop

  • scope (str, optional) – Timer defaults to the Transfer ‘all’ scope. Use this parameter to change the scope used by Timer when calling the Transfer Action Provider.

  • environment (str, optional) – For internal use: because this method needs to generate a URL for the Transfer Action Provider, this argument can control which environment the Timer job is sent to.

Client Errors#

When an error occurs, a TimerClient will raise specifically a TimerAPIError rather than just a GlobusAPIError.

class globus_sdk.TimerAPIError(r: Response, *args: Any, **kwargs: Any)[source]#

Bases: GlobusAPIError

Error class to represent error responses from Timer.

Has no particular additions to the base GlobusAPIError, but implements a different method for parsing error responses from Timer due to the differences between pydantic-generated errors and other errors.