docstr: Updates or creates a view
docstr_tok: ["Updates","or","creates","a","view"]
code: def put(self, project_name, view_name):
      """Updates or creates a view"""
      if "view" not in request.json:
          abort(
              HTTPStatus.BAD_REQUEST,
              'Must provide "view" parameter in PUT body',
          )
      request_view = request.json["view"]
      session = SessionController()
      try:
          project = session.database_controller.get_project(
              project_name
          )
      except NoResultFound:
          abort(
              HTTPStatus.NOT_FOUND,
              f"Project name {project_name} does not exist",
          )
  
      existing_view = project.get_view(view_name)
      if existing_view is None:
          # Create
          if "query" not in request_view:
              abort(
                  HTTPStatus.BAD_REQUEST,
                  'Missing "query" field for new view',
              )
          project.create_view(view_name, request_view["query"])
          created_view = project.get_view(view_name)
          # Only want to return relevant fields to the user.
          return {
              "id": created_view["metadata"]["id"],
              "name": created_view["name"],
              "query": created_view["query"],
          }, HTTPStatus.CREATED
  
      new_query = existing_view["query"]
      if "query" in request_view:
          new_query = request_view["query"]
          project.update_view(view_name, new_query)
  
      existing_view = project.get_view(view_name)
      # Only want to return relevant fields to the user.
      return {
          "id": existing_view["metadata"]["id"],
          "name": existing_view["name"],
          "query": existing_view["query"],
      }
  
file_path: mindsdb/mindsdb/api/http/namespaces/views.py
imports: from http import HTTPStatus
  from flask import request
  from flask_restx import Resource, abort
  from sqlalchemy.exc import NoResultFound
  from mindsdb.api.http.namespaces.configs.projects import ns_conf
  from mindsdb.api.executor.controllers.session_controller import SessionController
label_desc: Use image node_id 2 for calling the ViewResource obj's underlying member method code with example usage: obj.put(project_name, view_name) and returns: dict, dict,  HTTPStatus