code: def _raise_if_bad_http_status_and_method(self, response):
          
          code = response.status_code
          if code in {200, 202} or \
             (code == 201 and self.method in {'PUT', 'PATCH'}) or \
             (code == 204 and self.method in {'DELETE', 'POST'}):
              return
          raise BadStatus(
              "Invalid return status for {!r} operation".format(self.method))
docs: Check response status code is valid for a Put or Patch
          request. Must be 200, 201, 202, or 204.
  
          :raises: BadStatus if invalid status.