def execute(self, context: 'Context'): hook = CloudTasksHook( gcp_conn_id=self.gcp_conn_id, impersonation_chain=self.impersonation_chain, ) try: queue = hook.create_queue( location=self.location, task_queue=self.task_queue, project_id=self.project_id, queue_name=self.queue_name, retry=self.retry, timeout=self.timeout, metadata=self.metadata, ) except AlreadyExists: if self.queue_name is None: raise RuntimeError("The queue name should be set here!") queue = hook.get_queue( location=self.location, project_id=self.project_id, queue_name=self.queue_name, retry=self.retry, timeout=self.timeout, metadata=self.metadata, ) CloudTasksQueueLink.persist( operator_instance=self, context=context, queue_name=queue.name, ) return Queue.to_dict(queue)
def execute(self, context: 'Context'): hook = CloudTasksHook( gcp_conn_id=self.gcp_conn_id, impersonation_chain=self.impersonation_chain, ) queue = hook.resume_queue( location=self.location, queue_name=self.queue_name, project_id=self.project_id, retry=self.retry, timeout=self.timeout, metadata=self.metadata, ) CloudTasksQueueLink.persist( operator_instance=self, context=context, queue_name=queue.name, ) return Queue.to_dict(queue)
def execute(self, context: 'Context'): hook = CloudTasksHook( gcp_conn_id=self.gcp_conn_id, impersonation_chain=self.impersonation_chain, ) task = hook.get_task( location=self.location, queue_name=self.queue_name, task_name=self.task_name, project_id=self.project_id, response_view=self.response_view, retry=self.retry, timeout=self.timeout, metadata=self.metadata, ) CloudTasksQueueLink.persist( operator_instance=self, context=context, queue_name=task.name, ) return Task.to_dict(task)
def execute(self, context: 'Context'): hook = CloudTasksHook( gcp_conn_id=self.gcp_conn_id, impersonation_chain=self.impersonation_chain, ) tasks = hook.list_tasks( location=self.location, queue_name=self.queue_name, project_id=self.project_id, response_view=self.response_view, page_size=self.page_size, retry=self.retry, timeout=self.timeout, metadata=self.metadata, ) CloudTasksQueueLink.persist( operator_instance=self, context=context, queue_name=f"projects/{self.project_id or hook.project_id}/" f"locations/{self.location}/queues/{self.queue_name}", ) return [Task.to_dict(t) for t in tasks]