docstr: Update an RLS rule.
  ---
  put:
    summary: Update an RLS rule
    parameters:
    - in: path
      schema:
        type: integer
      name: pk
      description: The Rule pk
    requestBody:
      description: RLS schema
      required: true
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/{{self.__class__.__name__}}.put'
    responses:
      200:
        description: Rule changed
        content:
          application/json:
            schema:
              type: object
              properties:
                id:
                  type: number
                result:
                  $ref: '#/components/schemas/{{self.__class__.__name__}}.put'
      400:
        $ref: '#/components/responses/400'
      401:
        $ref: '#/components/responses/401'
      403:
        $ref: '#/components/responses/403'
      404:
        $ref: '#/components/responses/404'
      422:
        $ref: '#/components/responses/422'
      500:
        $ref: '#/components/responses/500'
docstr_tok: ["Update","an","RLS","rule",".","--","-","put",":","summary",":","Update","an","RLS","rule","parameters",":","-","in",":","path","schema",":","type",":","integer","name",":","pk","description",":","The","Rule","pk","requestBody",":","description",":","RLS","schema","required",":","true","content",":","application\/json",":","schema",":","$","ref",":","'","#","\/components\/schemas\/","{","{","self.__class__.__name__","}","}",".put'","responses",":","200",":","description",":","Rule","changed","content",":","application\/json",":","schema",":","type",":","object","properties",":","id",":","type",":","number","result",":","$","ref",":","'","#","\/components\/schemas\/","{","{","self.__class__.__name__","}","}",".put'","400",":","$","ref",":","'","#","\/components\/responses\/400'","401",":","$","ref",":","'","#","\/components\/responses\/401'","403",":","$","ref",":","'","#","\/components\/responses\/403'","404",":","$","ref",":","'","#","\/components\/responses\/404'","422",":","$","ref",":","'","#","\/components\/responses\/422'","500",":","$","ref",":","'","#","\/components\/responses\/500","'"]
code: def put(self, pk: int) -> Response:
      """Update an RLS rule.
      ---
      put:
        summary: Update an RLS rule
        parameters:
        - in: path
          schema:
            type: integer
          name: pk
          description: The Rule pk
        requestBody:
          description: RLS schema
          required: true
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/{{self.__class__.__name__}}.put'
        responses:
          200:
            description: Rule changed
            content:
              application/json:
                schema:
                  type: object
                  properties:
                    id:
                      type: number
                    result:
                      $ref: '#/components/schemas/{{self.__class__.__name__}}.put'
          400:
            $ref: '#/components/responses/400'
          401:
            $ref: '#/components/responses/401'
          403:
            $ref: '#/components/responses/403'
          404:
            $ref: '#/components/responses/404'
          422:
            $ref: '#/components/responses/422'
          500:
            $ref: '#/components/responses/500'
      """
  
      try:
          item = self.edit_model_schema.load(request.json)
      except ValidationError as error:
          return self.response_400(message=error.messages)
  
      try:
          new_model = UpdateRLSRuleCommand(pk, item).run()
          return self.response(201, id=new_model.id, result=item)
      except RolesNotFoundValidationError as ex:
          logger.error(
              "Role not found while updating RLS rule %s: %s",
              self.__class__.__name__,
              str(ex),
              exc_info=True,
          )
          return self.response_422(message=str(ex))
      except DatasourceNotFoundValidationError as ex:
          logger.error(
              "Table not found while updating RLS rule %s: %s",
              self.__class__.__name__,
              str(ex),
              exc_info=True,
          )
          return self.response_422(message=str(ex))
      except DAOUpdateFailedError as ex:
          logger.error(
              "Error updating RLS rule %s: %s",
              self.__class__.__name__,
              str(ex),
              exc_info=True,
          )
          return self.response_422(message=str(ex))
      except RLSRuleNotFoundError as ex:
          return self.response_404()
  
imports: import logging
  from typing import Any
  from flask import request, Response
  from flask_appbuilder.api import expose, protect, rison, safe
  from flask_appbuilder.models.sqla.interface import SQLAInterface
  from flask_babel import ngettext
  from marshmallow import ValidationError
  from superset.commands.exceptions import DatasourceNotFoundValidationError, RolesNotFoundValidationError
  from superset.commands.security.create import CreateRLSRuleCommand
  from superset.commands.security.delete import DeleteRLSRuleCommand
  from superset.commands.security.exceptions import RLSRuleNotFoundError
  from superset.commands.security.update import UpdateRLSRuleCommand
  from superset.connectors.sqla.models import RowLevelSecurityFilter
  from superset.constants import MODEL_API_RW_METHOD_PERMISSION_MAP, RouteMethod
  from superset.daos.exceptions import DAOCreateFailedError, DAOUpdateFailedError
  from superset.extensions import event_logger
  from superset.row_level_security.schemas import get_delete_ids_schema, openapi_spec_methods_override, RLSListSchema, RLSPostSchema, RLSPutSchema, RLSShowSchema
  from superset.views.base import DatasourceFilter
  from superset.views.base_api import BaseSupersetModelRestApi, requires_json, statsd_metrics
  from superset.views.filters import BaseFilterRelatedRoles
label_desc: Use image node_id 2 for calling the RLSRestApi obj's underlying member method code with example usage: obj.put(pk) and returns: self, self, self, self, self, self