Exemple #1
0
    def execute(self, context: 'Context'):
        hook = WorkflowsHook(gcp_conn_id=self.gcp_conn_id,
                             impersonation_chain=self.impersonation_chain)
        workflow_id = self._workflow_id(context)

        self.log.info("Creating workflow")
        try:
            operation = hook.create_workflow(
                workflow=self.workflow,
                workflow_id=workflow_id,
                location=self.location,
                project_id=self.project_id,
                retry=self.retry,
                timeout=self.timeout,
                metadata=self.metadata,
            )
            workflow = operation.result()
        except AlreadyExists:
            workflow = hook.get_workflow(
                workflow_id=workflow_id,
                location=self.location,
                project_id=self.project_id,
                retry=self.retry,
                timeout=self.timeout,
                metadata=self.metadata,
            )
        return Workflow.to_dict(workflow)
Exemple #2
0
    def execute(self, context: 'Context'):
        hook = WorkflowsHook(gcp_conn_id=self.gcp_conn_id, impersonation_chain=self.impersonation_chain)

        workflow = hook.get_workflow(
            workflow_id=self.workflow_id,
            project_id=self.project_id,
            location=self.location,
            retry=self.retry,
            timeout=self.timeout,
            metadata=self.metadata,
        )
        self.log.info("Updating workflow")
        operation = hook.update_workflow(
            workflow=workflow,
            update_mask=self.update_mask,
            retry=self.retry,
            timeout=self.timeout,
            metadata=self.metadata,
        )
        workflow = operation.result()

        WorkflowsWorkflowDetailsLink.persist(
            context=context,
            task_instance=self,
            location_id=self.location,
            workflow_id=self.workflow_id,
            project_id=self.project_id or hook.project_id,
        )

        return Workflow.to_dict(workflow)
Exemple #3
0
 def execute(self, context: 'Context'):
     hook = WorkflowsHook(gcp_conn_id=self.gcp_conn_id, impersonation_chain=self.impersonation_chain)
     self.log.info("Retrieving workflow")
     workflow = hook.get_workflow(
         workflow_id=self.workflow_id,
         location=self.location,
         project_id=self.project_id,
         retry=self.retry,
         timeout=self.timeout,
         metadata=self.metadata,
     )
     return Workflow.to_dict(workflow)
Exemple #4
0
 def execute(self, context: 'Context'):
     hook = WorkflowsHook(gcp_conn_id=self.gcp_conn_id, impersonation_chain=self.impersonation_chain)
     self.log.info("Retrieving workflows")
     workflows_iter = hook.list_workflows(
         filter_=self.filter_,
         order_by=self.order_by,
         location=self.location,
         project_id=self.project_id,
         retry=self.retry,
         timeout=self.timeout,
         metadata=self.metadata,
     )
     return [Workflow.to_dict(w) for w in workflows_iter]
Exemple #5
0
    def execute(self, context):
        hook = WorkflowsHook(gcp_conn_id=self.gcp_conn_id,
                             impersonation_chain=self.impersonation_chain)

        workflow = hook.get_workflow(
            workflow_id=self.workflow_id,
            project_id=self.project_id,
            location=self.location,
            retry=self.retry,
            timeout=self.timeout,
            metadata=self.metadata,
        )
        self.log.info("Updating workflow")
        operation = hook.update_workflow(
            workflow=workflow,
            update_mask=self.update_mask,
            retry=self.retry,
            timeout=self.timeout,
            metadata=self.metadata,
        )
        workflow = operation.result()
        return Workflow.to_dict(workflow)