Beispiel #1
0
 def execute(self, context):
     self._validate_body_fields()
     hook = CloudSQLHook(gcp_conn_id=self.gcp_conn_id,
                         api_version=self.api_version)
     if not self._check_if_db_exists(self.database, hook):
         raise AirflowException(
             "Cloud SQL instance with ID {instance} does not contain "
             "database '{database}'. "
             "Please specify another database to patch.".format(
                 instance=self.instance, database=self.database))
     else:
         return hook.patch_database(project_id=self.project_id,
                                    instance=self.instance,
                                    database=self.database,
                                    body=self.body)
Beispiel #2
0
 def execute(self, context: 'Context') -> None:
     self._validate_body_fields()
     hook = CloudSQLHook(
         gcp_conn_id=self.gcp_conn_id,
         api_version=self.api_version,
         impersonation_chain=self.impersonation_chain,
     )
     if not self._check_if_db_exists(self.database, hook):
         raise AirflowException(
             f"Cloud SQL instance with ID {self.instance} does not contain database '{self.database}'. "
             "Please specify another database to patch.")
     else:
         return hook.patch_database(project_id=self.project_id,
                                    instance=self.instance,
                                    database=self.database,
                                    body=self.body)