docstr: Download multiple saved queries as YAML files.
  ---
  get:
    summary: Download multiple saved queries as YAML files
    parameters:
    - in: query
      name: q
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/get_export_ids_schema'
    responses:
      200:
        description: A zip file with saved query(ies) and database(s) as YAML
        content:
          application/zip:
            schema:
              type: string
              format: binary
      400:
        $ref: '#/components/responses/400'
      401:
        $ref: '#/components/responses/401'
      404:
        $ref: '#/components/responses/404'
      500:
        $ref: '#/components/responses/500'
docstr_tok: ["Download","multiple","saved","queries","as","YAML","files",".","--","-","get",":","summary",":","Download","multiple","saved","queries","as","YAML","files","parameters",":","-","in",":","query","name",":","q","content",":","application\/json",":","schema",":","$","ref",":","'","#","\/components\/schemas\/get_export_ids_schema'","responses",":","200",":","description",":","A","zip","file","with","saved","query","(","ies",")","and","database","(","s",")","as","YAML","content",":","application\/zip",":","schema",":","type",":","string","format",":","binary","400",":","$","ref",":","'","#","\/components\/responses\/400'","401",":","$","ref",":","'","#","\/components\/responses\/401'","404",":","$","ref",":","'","#","\/components\/responses\/404'","500",":","$","ref",":","'","#","\/components\/responses\/500","'"]
code: def export(self, **kwargs: Any) -> Response:
      """Download multiple saved queries as YAML files.
      ---
      get:
        summary: Download multiple saved queries as YAML files
        parameters:
        - in: query
          name: q
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/get_export_ids_schema'
        responses:
          200:
            description: A zip file with saved query(ies) and database(s) as YAML
            content:
              application/zip:
                schema:
                  type: string
                  format: binary
          400:
            $ref: '#/components/responses/400'
          401:
            $ref: '#/components/responses/401'
          404:
            $ref: '#/components/responses/404'
          500:
            $ref: '#/components/responses/500'
      """
      requested_ids = kwargs["rison"]
      timestamp = datetime.now().strftime("%Y%m%dT%H%M%S")
      root = f"saved_query_export_{timestamp}"
      filename = f"{root}.zip"
  
      buf = BytesIO()
      with ZipFile(buf, "w") as bundle:
          try:
              for file_name, file_content in ExportSavedQueriesCommand(
                  requested_ids
              ).run():
                  with bundle.open(f"{root}/{file_name}", "w") as fp:
                      fp.write(file_content.encode())
          except SavedQueryNotFoundError:
              return self.response_404()
      buf.seek(0)
  
      response = send_file(
          buf,
          mimetype="application/zip",
          as_attachment=True,
          download_name=filename,
      )
      if token := request.args.get("token"):
          response.set_cookie(token, "done", max_age=600)
      return response
  
imports: import json
  import logging
  from datetime import datetime
  from io import BytesIO
  from typing import Any
  from zipfile import is_zipfile, ZipFile
  from flask import g, request, Response, send_file
  from flask_appbuilder.api import expose, protect, rison, safe
  from flask_appbuilder.models.sqla.interface import SQLAInterface
  from flask_babel import ngettext
  from superset import is_feature_enabled
  from superset.commands.importers.exceptions import IncorrectFormatError, NoValidFilesFoundError
  from superset.commands.importers.v1.utils import get_contents_from_bundle
  from superset.commands.query.delete import DeleteSavedQueryCommand
  from superset.commands.query.exceptions import SavedQueryDeleteFailedError, SavedQueryNotFoundError
  from superset.commands.query.export import ExportSavedQueriesCommand
  from superset.commands.query.importers.dispatcher import ImportSavedQueriesCommand
  from superset.constants import MODEL_API_RW_METHOD_PERMISSION_MAP, RouteMethod
  from superset.databases.filters import DatabaseFilter
  from superset.extensions import event_logger
  from superset.models.sql_lab import SavedQuery
  from superset.queries.saved_queries.filters import SavedQueryAllTextFilter, SavedQueryFavoriteFilter, SavedQueryFilter, SavedQueryTagFilter
  from superset.queries.saved_queries.schemas import get_delete_ids_schema, get_export_ids_schema, openapi_spec_methods_override
  from superset.views.base_api import BaseSupersetModelRestApi, requires_form_data, statsd_metrics
label_desc: Use image node_id 4 for calling the SavedQueryRestApi obj's underlying member method code with example usage: obj.export() and returns: response, self