def export_data_to_gcs()

in kubernetes/storage/parallelstore-transfer-tool/main.py [0:0]


def export_data_to_gcs(gcs_bucket, path, instance, location, request_id, project_id):
    """Exports data from Parallelstore to GCS."""

    client = parallelstore_v1.ParallelstoreClient()

    destination_gcs_bucket = parallelstore_v1.DestinationGcsBucket()
    destination_gcs_bucket.uri = f"gs://{gcs_bucket}"

    request = parallelstore_v1.ExportDataRequest(
        name=f"projects/{project_id}/locations/{location}/instances/{instance}",
        destination_gcs_bucket=destination_gcs_bucket,
    )

    if request_id is not None:
        request.request_id = request_id
    if path != "/":
        request.destination_parallelstore = path

    operation = client.export_data(request=request)
    log_operation_start(
        "Export", gcs_bucket, instance, location, project_id, request_id
    )

    wait_for_operation(operation)

    if operation.done():
        response = operation.result()
        logger.info(f"Operation succeeded: {response}")