| :py:mod:`airflow.providers.google.cloud.hooks.tasks` |
| ==================================================== |
| |
| .. py:module:: airflow.providers.google.cloud.hooks.tasks |
| |
| .. autoapi-nested-parse:: |
| |
| This module contains a CloudTasksHook |
| which allows you to connect to Google Cloud Tasks service, |
| performing actions to queues or tasks. |
| |
| |
| |
| Module Contents |
| --------------- |
| |
| Classes |
| ~~~~~~~ |
| |
| .. autoapisummary:: |
| |
| airflow.providers.google.cloud.hooks.tasks.CloudTasksHook |
| |
| |
| |
| |
| .. py:class:: CloudTasksHook(gcp_conn_id = 'google_cloud_default', delegate_to = None, impersonation_chain = None) |
| |
| Bases: :py:obj:`airflow.providers.google.common.hooks.base_google.GoogleBaseHook` |
| |
| Hook for Google Cloud Tasks APIs. Cloud Tasks allows developers to manage |
| the execution of background work in their applications. |
| |
| All the methods in the hook where project_id is used must be called with |
| keyword arguments rather than positional. |
| |
| :param gcp_conn_id: The connection ID to use when fetching connection info. |
| :param delegate_to: The account to impersonate using domain-wide delegation of authority, |
| if any. For this to work, the service account making the request must have |
| domain-wide delegation enabled. |
| :param impersonation_chain: Optional service account to impersonate using short-term |
| credentials, or chained list of accounts required to get the access_token |
| of the last account in the list, which will be impersonated in the request. |
| If set as a string, the account must grant the originating account |
| the Service Account Token Creator IAM role. |
| If set as a sequence, the identities from the list must grant |
| Service Account Token Creator IAM role to the directly preceding identity, with first |
| account from the list granting this role to the originating account. |
| |
| .. py:method:: get_conn(self) |
| |
| Provides a client for interacting with the Google Cloud Tasks API. |
| |
| :return: Google Cloud Tasks API Client |
| :rtype: google.cloud.tasks_v2.CloudTasksClient |
| |
| |
| .. py:method:: create_queue(self, location, task_queue, project_id = PROVIDE_PROJECT_ID, queue_name = None, retry = DEFAULT, timeout = None, metadata = ()) |
| |
| Creates a queue in Cloud Tasks. |
| |
| :param location: The location name in which the queue will be created. |
| :param task_queue: The task queue to create. |
| Queue's name cannot be the same as an existing queue. |
| If a dict is provided, it must be of the same form as the protobuf message Queue. |
| :param project_id: (Optional) The ID of the Google Cloud project that owns the Cloud Tasks. |
| If set to None or missing, the default project_id from the Google Cloud connection is used. |
| :param queue_name: (Optional) The queue's name. |
| If provided, it will be used to construct the full queue path. |
| :param retry: (Optional) A retry object used to retry requests. |
| If None is specified, requests will not be retried. |
| :param timeout: (Optional) The amount of time, in seconds, to wait for the request |
| to complete. Note that if retry is specified, the timeout applies to each |
| individual attempt. |
| :param metadata: (Optional) Additional metadata that is provided to the method. |
| :rtype: google.cloud.tasks_v2.types.Queue |
| |
| |
| .. py:method:: update_queue(self, task_queue, project_id = PROVIDE_PROJECT_ID, location = None, queue_name = None, update_mask = None, retry = DEFAULT, timeout = None, metadata = ()) |
| |
| Updates a queue in Cloud Tasks. |
| |
| :param task_queue: The task queue to update. |
| This method creates the queue if it does not exist and updates the queue if |
| it does exist. The queue's name must be specified. |
| :param project_id: (Optional) The ID of the Google Cloud project that owns the Cloud Tasks. |
| If set to None or missing, the default project_id from the Google Cloud connection is used. |
| :param location: (Optional) The location name in which the queue will be updated. |
| If provided, it will be used to construct the full queue path. |
| :param queue_name: (Optional) The queue's name. |
| If provided, it will be used to construct the full queue path. |
| :param update_mask: A mast used to specify which fields of the queue are being updated. |
| If empty, then all fields will be updated. |
| If a dict is provided, it must be of the same form as the protobuf message. |
| :param retry: (Optional) A retry object used to retry requests. |
| If None is specified, requests will not be retried. |
| :param timeout: (Optional) The amount of time, in seconds, to wait for the request |
| to complete. Note that if retry is specified, the timeout applies to each |
| individual attempt. |
| :param metadata: (Optional) Additional metadata that is provided to the method. |
| :rtype: google.cloud.tasks_v2.types.Queue |
| |
| |
| .. py:method:: get_queue(self, location, queue_name, project_id = PROVIDE_PROJECT_ID, retry = DEFAULT, timeout = None, metadata = ()) |
| |
| Gets a queue from Cloud Tasks. |
| |
| :param location: The location name in which the queue was created. |
| :param queue_name: The queue's name. |
| :param project_id: (Optional) The ID of the Google Cloud project that owns the Cloud Tasks. |
| If set to None or missing, the default project_id from the Google Cloud connection is used. |
| :param retry: (Optional) A retry object used to retry requests. |
| If None is specified, requests will not be retried. |
| :param timeout: (Optional) The amount of time, in seconds, to wait for the request |
| to complete. Note that if retry is specified, the timeout applies to each |
| individual attempt. |
| :param metadata: (Optional) Additional metadata that is provided to the method. |
| :rtype: google.cloud.tasks_v2.types.Queue |
| |
| |
| .. py:method:: list_queues(self, location, project_id = PROVIDE_PROJECT_ID, results_filter = None, page_size = None, retry = DEFAULT, timeout = None, metadata = ()) |
| |
| Lists queues from Cloud Tasks. |
| |
| :param location: The location name in which the queues were created. |
| :param project_id: (Optional) The ID of the Google Cloud project that owns the Cloud Tasks. |
| If set to None or missing, the default project_id from the Google Cloud connection is used. |
| :param results_filter: (Optional) Filter used to specify a subset of queues. |
| :param page_size: (Optional) The maximum number of resources contained in the |
| underlying API response. |
| :param retry: (Optional) A retry object used to retry requests. |
| If None is specified, requests will not be retried. |
| :param timeout: (Optional) The amount of time, in seconds, to wait for the request |
| to complete. Note that if retry is specified, the timeout applies to each |
| individual attempt. |
| :param metadata: (Optional) Additional metadata that is provided to the method. |
| :rtype: list[google.cloud.tasks_v2.types.Queue] |
| |
| |
| .. py:method:: delete_queue(self, location, queue_name, project_id = PROVIDE_PROJECT_ID, retry = DEFAULT, timeout = None, metadata = ()) |
| |
| Deletes a queue from Cloud Tasks, even if it has tasks in it. |
| |
| :param location: The location name in which the queue will be deleted. |
| :param queue_name: The queue's name. |
| :param project_id: (Optional) The ID of the Google Cloud project that owns the Cloud Tasks. |
| If set to None or missing, the default project_id from the Google Cloud connection is used. |
| :param retry: (Optional) A retry object used to retry requests. |
| If None is specified, requests will not be retried. |
| :param timeout: (Optional) The amount of time, in seconds, to wait for the request |
| to complete. Note that if retry is specified, the timeout applies to each |
| individual attempt. |
| :param metadata: (Optional) Additional metadata that is provided to the method. |
| |
| |
| .. py:method:: purge_queue(self, location, queue_name, project_id = PROVIDE_PROJECT_ID, retry = DEFAULT, timeout = None, metadata = ()) |
| |
| Purges a queue by deleting all of its tasks from Cloud Tasks. |
| |
| :param location: The location name in which the queue will be purged. |
| :param queue_name: The queue's name. |
| :param project_id: (Optional) The ID of the Google Cloud project that owns the Cloud Tasks. |
| If set to None or missing, the default project_id from the Google Cloud connection is used. |
| :param retry: (Optional) A retry object used to retry requests. |
| If None is specified, requests will not be retried. |
| :param timeout: (Optional) The amount of time, in seconds, to wait for the request |
| to complete. Note that if retry is specified, the timeout applies to each |
| individual attempt. |
| :param metadata: (Optional) Additional metadata that is provided to the method. |
| :rtype: list[google.cloud.tasks_v2.types.Queue] |
| |
| |
| .. py:method:: pause_queue(self, location, queue_name, project_id = PROVIDE_PROJECT_ID, retry = DEFAULT, timeout = None, metadata = ()) |
| |
| Pauses a queue in Cloud Tasks. |
| |
| :param location: The location name in which the queue will be paused. |
| :param queue_name: The queue's name. |
| :param project_id: (Optional) The ID of the Google Cloud project that owns the Cloud Tasks. |
| If set to None or missing, the default project_id from the Google Cloud connection is used. |
| :param retry: (Optional) A retry object used to retry requests. |
| If None is specified, requests will not be retried. |
| :param timeout: (Optional) The amount of time, in seconds, to wait for the request |
| to complete. Note that if retry is specified, the timeout applies to each |
| individual attempt. |
| :param metadata: (Optional) Additional metadata that is provided to the method. |
| :rtype: list[google.cloud.tasks_v2.types.Queue] |
| |
| |
| .. py:method:: resume_queue(self, location, queue_name, project_id = PROVIDE_PROJECT_ID, retry = DEFAULT, timeout = None, metadata = ()) |
| |
| Resumes a queue in Cloud Tasks. |
| |
| :param location: The location name in which the queue will be resumed. |
| :param queue_name: The queue's name. |
| :param project_id: (Optional) The ID of the Google Cloud project that owns the Cloud Tasks. |
| If set to None or missing, the default project_id from the Google Cloud connection is used. |
| :param retry: (Optional) A retry object used to retry requests. |
| If None is specified, requests will not be retried. |
| :param timeout: (Optional) The amount of time, in seconds, to wait for the request |
| to complete. Note that if retry is specified, the timeout applies to each |
| individual attempt. |
| :param metadata: (Optional) Additional metadata that is provided to the method. |
| :rtype: list[google.cloud.tasks_v2.types.Queue] |
| |
| |
| .. py:method:: create_task(self, location, queue_name, task, project_id = PROVIDE_PROJECT_ID, task_name = None, response_view = None, retry = DEFAULT, timeout = None, metadata = ()) |
| |
| Creates a task in Cloud Tasks. |
| |
| :param location: The location name in which the task will be created. |
| :param queue_name: The queue's name. |
| :param task: The task to add. |
| If a dict is provided, it must be of the same form as the protobuf message Task. |
| :param project_id: (Optional) The ID of the Google Cloud project that owns the Cloud Tasks. |
| If set to None or missing, the default project_id from the Google Cloud connection is used. |
| :param task_name: (Optional) The task's name. |
| If provided, it will be used to construct the full task path. |
| :param response_view: (Optional) This field specifies which subset of the Task will |
| be returned. |
| :param retry: (Optional) A retry object used to retry requests. |
| If None is specified, requests will not be retried. |
| :param timeout: (Optional) The amount of time, in seconds, to wait for the request |
| to complete. Note that if retry is specified, the timeout applies to each |
| individual attempt. |
| :param metadata: (Optional) Additional metadata that is provided to the method. |
| :rtype: google.cloud.tasks_v2.types.Task |
| |
| |
| .. py:method:: get_task(self, location, queue_name, task_name, project_id = PROVIDE_PROJECT_ID, response_view = None, retry = DEFAULT, timeout = None, metadata = ()) |
| |
| Gets a task from Cloud Tasks. |
| |
| :param location: The location name in which the task was created. |
| :param queue_name: The queue's name. |
| :param task_name: The task's name. |
| :param project_id: (Optional) The ID of the Google Cloud project that owns the Cloud Tasks. |
| If set to None or missing, the default project_id from the Google Cloud connection is used. |
| :param response_view: (Optional) This field specifies which subset of the Task will |
| be returned. |
| :param retry: (Optional) A retry object used to retry requests. |
| If None is specified, requests will not be retried. |
| :param timeout: (Optional) The amount of time, in seconds, to wait for the request |
| to complete. Note that if retry is specified, the timeout applies to each |
| individual attempt. |
| :param metadata: (Optional) Additional metadata that is provided to the method. |
| :rtype: google.cloud.tasks_v2.types.Task |
| |
| |
| .. py:method:: list_tasks(self, location, queue_name, project_id, response_view = None, page_size = None, retry = DEFAULT, timeout = None, metadata = ()) |
| |
| Lists the tasks in Cloud Tasks. |
| |
| :param location: The location name in which the tasks were created. |
| :param queue_name: The queue's name. |
| :param project_id: (Optional) The ID of the Google Cloud project that owns the Cloud Tasks. |
| If set to None or missing, the default project_id from the Google Cloud connection is used. |
| :param response_view: (Optional) This field specifies which subset of the Task will |
| be returned. |
| :param page_size: (Optional) The maximum number of resources contained in the |
| underlying API response. |
| :param retry: (Optional) A retry object used to retry requests. |
| If None is specified, requests will not be retried. |
| :param timeout: (Optional) The amount of time, in seconds, to wait for the request |
| to complete. Note that if retry is specified, the timeout applies to each |
| individual attempt. |
| :param metadata: (Optional) Additional metadata that is provided to the method. |
| :rtype: list[google.cloud.tasks_v2.types.Task] |
| |
| |
| .. py:method:: delete_task(self, location, queue_name, task_name, project_id, retry = DEFAULT, timeout = None, metadata = ()) |
| |
| Deletes a task from Cloud Tasks. |
| |
| :param location: The location name in which the task will be deleted. |
| :param queue_name: The queue's name. |
| :param task_name: The task's name. |
| :param project_id: (Optional) The ID of the Google Cloud project that owns the Cloud Tasks. |
| If set to None or missing, the default project_id from the Google Cloud connection is used. |
| :param retry: (Optional) A retry object used to retry requests. |
| If None is specified, requests will not be retried. |
| :param timeout: (Optional) The amount of time, in seconds, to wait for the request |
| to complete. Note that if retry is specified, the timeout applies to each |
| individual attempt. |
| :param metadata: (Optional) Additional metadata that is provided to the method. |
| |
| |
| .. py:method:: run_task(self, location, queue_name, task_name, project_id, response_view = None, retry = DEFAULT, timeout = None, metadata = ()) |
| |
| Forces to run a task in Cloud Tasks. |
| |
| :param location: The location name in which the task was created. |
| :param queue_name: The queue's name. |
| :param task_name: The task's name. |
| :param project_id: (Optional) The ID of the Google Cloud project that owns the Cloud Tasks. |
| If set to None or missing, the default project_id from the Google Cloud connection is used. |
| :param response_view: (Optional) This field specifies which subset of the Task will |
| be returned. |
| :param retry: (Optional) A retry object used to retry requests. |
| If None is specified, requests will not be retried. |
| :param timeout: (Optional) The amount of time, in seconds, to wait for the request |
| to complete. Note that if retry is specified, the timeout applies to each |
| individual attempt. |
| :param metadata: (Optional) Additional metadata that is provided to the method. |
| :rtype: google.cloud.tasks_v2.types.Task |
| |
| |
| |