docstr: Marks the tag as favorite
  ---
  post:
    description: >-
      Marks the tag as favorite for the current user
    parameters:
    - in: path
      schema:
        type: integer
      name: pk
    responses:
      200:
        description: Tag added to favorites
        content:
          application/json:
            schema:
              type: object
              properties:
                result:
                  type: object
      401:
        $ref: '#/components/responses/401'
      404:
        $ref: '#/components/responses/404'
      422:
        $ref: '#/components/responses/422'
      500:
        $ref: '#/components/responses/500'
docstr_tok: ["Marks","the","tag","as","favorite","--","-","post",":","description",":",">","-","Marks","the","tag","as","favorite","for","the","current","user","parameters",":","-","in",":","path","schema",":","type",":","integer","name",":","pk","responses",":","200",":","description",":","Tag","added","to","favorites","content",":","application\/json",":","schema",":","type",":","object","properties",":","result",":","type",":","object","401",":","$","ref",":","'","#","\/components\/responses\/401'","404",":","$","ref",":","'","#","\/components\/responses\/404'","422",":","$","ref",":","'","#","\/components\/responses\/422'","500",":","$","ref",":","'","#","\/components\/responses\/500","'"]
code: def add_favorite(self, pk: int) -> Response:
      """Marks the tag as favorite
      ---
      post:
        description: >-
          Marks the tag as favorite for the current user
        parameters:
        - in: path
          schema:
            type: integer
          name: pk
        responses:
          200:
            description: Tag added to favorites
            content:
              application/json:
                schema:
                  type: object
                  properties:
                    result:
                      type: object
          401:
            $ref: '#/components/responses/401'
          404:
            $ref: '#/components/responses/404'
          422:
            $ref: '#/components/responses/422'
          500:
            $ref: '#/components/responses/500'
      """
      try:
          TagDAO.favorite_tag_by_id_for_current_user(pk)
          return self.response(200, result="OK")
      except TagNotFoundError:
          return self.response_404()
      except MissingUserContextException as ex:
          return self.response_422(message=str(ex))
  
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 marshmallow import ValidationError
  from superset.commands.tag.create import CreateCustomTagCommand, CreateCustomTagWithRelationshipsCommand
  from superset.commands.tag.delete import DeleteTaggedObjectCommand, DeleteTagsCommand
  from superset.commands.tag.exceptions import TagDeleteFailedError, TaggedObjectDeleteFailedError, TaggedObjectNotFoundError, TagInvalidError, TagNotFoundError, TagUpdateFailedError
  from superset.commands.tag.update import UpdateTagCommand
  from superset.constants import MODEL_API_RW_METHOD_PERMISSION_MAP, RouteMethod
  from superset.daos.tag import TagDAO
  from superset.exceptions import MissingUserContextException
  from superset.extensions import event_logger
  from superset.tags.models import ObjectType, Tag
  from superset.tags.schemas import delete_tags_schema, openapi_spec_methods_override, TaggedObjectEntityResponseSchema, TagGetResponseSchema, TagPostBulkSchema, TagPostSchema, TagPutSchema
  from superset.views.base_api import BaseSupersetModelRestApi, RelatedFieldFilter, statsd_metrics
  from superset.views.filters import BaseFilterRelatedUsers, FilterRelatedOwners
label_desc: Use image node_id 10 for calling the TagRestApi obj's underlying member method code with example usage: obj.add_favorite(pk) and returns: self, self, self