original_docstring: Accept the POST request for push registrations event callback.
docstring: Accept the POST request for push registrations event callback.
docstring_tokens: Accept the POST request for push registrations event callback .
code: async def post(self, request):
          """Accept the POST request for push registrations event callback."""
          auth_check = self.check_authorization_header(request)
          if not isinstance(auth_check, dict):
              return auth_check
  
          try:
              data = await request.json()
          except ValueError:
              return self.json_message('Invalid JSON', HTTP_BAD_REQUEST)
  
          event_payload = {
              ATTR_TAG: data.get(ATTR_TAG),
              ATTR_TYPE: data[ATTR_TYPE],
              ATTR_TARGET: auth_check[ATTR_TARGET],
          }
  
          if data.get(ATTR_ACTION) is not None:
              event_payload[ATTR_ACTION] = data.get(ATTR_ACTION)
  
          if data.get(ATTR_DATA) is not None:
              event_payload[ATTR_DATA] = data.get(ATTR_DATA)
  
          try:
              event_payload = CALLBACK_EVENT_PAYLOAD_SCHEMA(event_payload)
          except vol.Invalid as ex:
              _LOGGER.warning("Callback event payload is not valid: %s",
                              humanize_error(event_payload, ex))
  
          event_name = '{}.{}'.format(NOTIFY_CALLBACK_EVENT,
                                      event_payload[ATTR_TYPE])
          request.app['hass'].bus.fire(event_name, event_payload)
          return self.json({'status': 'ok', 'event': event_payload[ATTR_TYPE]})
code_tokens: async def post ( self , request ) : auth_check = self . check_authorization_header ( request ) if not isinstance ( auth_check , dict ) : return auth_check try : data = await request . json ( ) except ValueError : return self . json_message ( 'Invalid JSON' , HTTP_BAD_REQUEST ) event_payload = { ATTR_TAG : data . get ( ATTR_TAG ) , ATTR_TYPE : data [ ATTR_TYPE ] , ATTR_TARGET : auth_check [ ATTR_TARGET ] , } if data . get ( ATTR_ACTION ) is not None : event_payload [ ATTR_ACTION ] = data . get ( ATTR_ACTION ) if data . get ( ATTR_DATA ) is not None : event_payload [ ATTR_DATA ] = data . get ( ATTR_DATA ) try : event_payload = CALLBACK_EVENT_PAYLOAD_SCHEMA ( event_payload ) except vol . Invalid as ex : _LOGGER . warning ( "Callback event payload is not valid: %s" , humanize_error ( event_payload , ex ) ) event_name = '{}.{}' . format ( NOTIFY_CALLBACK_EVENT , event_payload [ ATTR_TYPE ] ) request . app [ 'hass' ] . bus . fire ( event_name , event_payload ) return self . json ( { 'status' : 'ok' , 'event' : event_payload [ ATTR_TYPE ] } )
short_docstring: Accept the POST request for push registrations event callback.
short_docstring_tokens: Accept the POST request for push registrations event callback .
comment: """Accept the POST request for push registrations event callback."""