parameters: (self, project_id)
docstring: Get all tasks for a project as OSM XML
          ---
          tags:
              - tasks
          produces:
              - application/xml
          parameters:
              - name: project_id
                in: path
                description: Project ID the task is associated with
                required: true
                type: integer
                default: 1
              - in: query
                name: tasks
                type: string
                description: List of tasks; leave blank to retrieve all
                default: 1,2
              - in: query
                name: as_file
                type: boolean
                description: Set to true if file download preferred
                default: False
          responses:
              200:
                  description: OSM XML
              400:
                  description: Client Error
              404:
                  description: No mapped tasks
              500:
                  description: Internal Server Error
docstring_summary: Get all tasks for a project as OSM XML
          ---
          tags:
              - tasks
          produces:
              - application/xml
          parameters:
              - name: project_id
                in: path
                description: Project ID the task is associated with
                required: true
                type: integer
                default: 1
              - in: query
                name: tasks
                type: string
                description: List of tasks; leave blank to retrieve all
                default: 1,2
              - in: query
                name: as_file
                type: boolean
                description: Set to true if file download preferred
                default: False
          responses:
              200:
                  description: OSM XML
              400:
                  description: Client Error
              404:
                  description: No mapped tasks
              500:
                  description: Internal Server Error
docstring_tokens: Get all tasks for a project as OSM XML --- tags : - tasks produces : - application / xml parameters : - name : project_id in : path description : Project ID the task is associated with required : true type : integer default : 1 - in : query name : tasks type : string description : List of tasks ; leave blank to retrieve all default : 1 2 - in : query name : as_file type : boolean description : Set to true if file download preferred default : False responses : 200 : description : OSM XML 400 : description : Client Error 404 : description : No mapped tasks 500 : description : Internal Server Error
function: def get(self, project_id):
          """
          Get all tasks for a project as OSM XML
          ---
          tags:
              - tasks
          produces:
              - application/xml
          parameters:
              - name: project_id
                in: path
                description: Project ID the task is associated with
                required: true
                type: integer
                default: 1
              - in: query
                name: tasks
                type: string
                description: List of tasks; leave blank to retrieve all
                default: 1,2
              - in: query
                name: as_file
                type: boolean
                description: Set to true if file download preferred
                default: False
          responses:
              200:
                  description: OSM XML
              400:
                  description: Client Error
              404:
                  description: No mapped tasks
              500:
                  description: Internal Server Error
          """
          try:
              tasks = request.args.get("tasks") if request.args.get("tasks") else None
              as_file = (
                  strtobool(request.args.get("as_file"))
                  if request.args.get("as_file")
                  else False
              )
  
              xml = MappingService.generate_osm_xml(project_id, tasks)
  
              if as_file:
                  return send_file(
                      io.BytesIO(xml),
                      mimetype="text.xml",
                      as_attachment=True,
                      attachment_filename=f"HOT-project-{project_id}.osm",
                  )
  
              return Response(xml, mimetype="text/xml", status=200)
          except NotFound:
              return (
                  {"Error": "Not found; please check the project and task numbers."},
                  404,
              )
          except Exception as e:
              error_msg = f"TasksQueriesXmlAPI - unhandled error: {str(e)}"
              current_app.logger.critical(error_msg)
              return {"Error": "Unable to fetch task XML"}, 500
function_tokens: def get ( self , project_id ) : try : tasks = request . args . get ( "tasks" ) if request . args . get ( "tasks" ) else None as_file = ( strtobool ( request . args . get ( "as_file" ) ) if request . args . get ( "as_file" ) else False ) xml = MappingService . generate_osm_xml ( project_id , tasks ) if as_file : return send_file ( io . BytesIO ( xml ) , mimetype = "text.xml" , as_attachment = True , attachment_filename = f"HOT-project-{project_id}.osm" , ) return Response ( xml , mimetype = "text/xml" , status = 200 ) except NotFound : return ( { "Error" : "Not found; please check the project and task numbers." } , 404 , ) except Exception as e : error_msg = f"TasksQueriesXmlAPI - unhandled error: {str(e)}" current_app . logger . critical ( error_msg ) return { "Error" : "Unable to fetch task XML" } , 500