Example #1
0
    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,
            )

        return Queue.to_dict(queue)
Example #2
0
    def execute(self, 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:
            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,
            )

        return Queue.to_dict(queue)
Example #3
0
 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,
     )
     return Queue.to_dict(queue)
Example #4
0
 def execute(self, context: 'Context'):
     hook = CloudTasksHook(
         gcp_conn_id=self.gcp_conn_id,
         impersonation_chain=self.impersonation_chain,
     )
     queues = hook.list_queues(
         location=self.location,
         project_id=self.project_id,
         results_filter=self.results_filter,
         page_size=self.page_size,
         retry=self.retry,
         timeout=self.timeout,
         metadata=self.metadata,
     )
     return [Queue.to_dict(q) for q in queues]
Example #5
0
 def execute(self, context: 'Context'):
     hook = CloudTasksHook(
         gcp_conn_id=self.gcp_conn_id,
         impersonation_chain=self.impersonation_chain,
     )
     queue = hook.pause_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)