sprzedwojski commented on a change in pull request #4251: [AIRFLOW-2440] Add
Google Cloud SQL import/export operator
URL: https://github.com/apache/incubator-airflow/pull/4251#discussion_r238257151
##########
File path: airflow/contrib/hooks/gcp_sql_hook.py
##########
@@ -254,6 +254,54 @@ def delete_database(self, project, instance, database):
operation_name = response["name"]
return self._wait_for_operation_to_complete(project, operation_name)
+ def export_instance(self, project_id, instance_id, body):
+ """
+ Exports data from a Cloud SQL instance to a Cloud Storage bucket as a
SQL dump
+ or CSV file.
+
+ :param project_id: Project ID of the project where the instance exists.
+ :type project_id: str
+ :param instance_id: Name of the Cloud SQL instance. This does not
include the
+ project ID.
+ :type instance_id: str
+ :param body: The request body, as described in
+
https://cloud.google.com/sql/docs/mysql/admin-api/v1beta4/instances/export#request-body
+ :type body: dict
+ :return: True if the operation succeeded, raises an error otherwise
+ :rtype: bool
+ """
+ response = self.get_conn().instances().export(
+ project=project_id,
+ instance=instance_id,
+ body=body
+ ).execute(num_retries=NUM_RETRIES)
+ operation_name = response["name"]
+ return self._wait_for_operation_to_complete(project_id, operation_name)
+
+ def import_instance(self, project_id, instance_id, body):
+ """
+ Imports data into a Cloud SQL instance from a SQL dump or CSV file in
+ Cloud Storage.
+
+ :param project_id: Project ID of the project where the instance exists.
+ :type project_id: str
+ :param instance_id: Name of the Cloud SQL instance. This does not
include the
+ project ID.
+ :type instance_id: str
+ :param body: The request body, as described in
+
https://cloud.google.com/sql/docs/mysql/admin-api/v1beta4/instances/export#request-body
+ :type body: dict
+ :return: True if the operation succeeded, raises an error otherwise
+ :rtype: bool
+ """
+ response = self.get_conn().instances().import_(
Review comment:
Done
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services