:param payload:
            a key/value object containing the scimeta you want to store
            e.g. {"weather": "sunny", "temperature": "80C" }
        :return:
            empty (200 status code)
771109
def custom(self, payload):
        
        url = "{url_base}/resource/{pid}/scimeta/custom/".format(url_base=self.hs.url_base,
                                                                 pid=self.pid)
        r = self.hs._request('POST', url, data=payload)
        return r
397113
def on_post(self, req, resp):
        
        resp.content_type = falcon.MEDIA_TEXT
        resp.status = falcon.HTTP_200

        # verify payload is in the correct format
        # default to no filter
        payload = {}
        if req.content_length:
            try:
                payload = json.load(req.stream)
            except Exception as e:  # pragma: no cover
                resp.body = "(False, 'malformed payload')"
                return
        else:
            resp.body = "(False, 'malformed payload')"
            return

        if 'filter' not in payload:
            payload['filter'] = ''

        # payload should have the following fields:
        # - id
        # - nic
        # - interval
        # - filter
        # - iters
        # should spin up a tcpdump container that writes out pcap files based
        # on the filter needs to be attached to the nic specified, if iters is
        # -1 then loops until killed, otherwise completes iters number of
        # captures (and creates that many pcap files) should keep track of
        # container id, container name, and id of filter and filter + whatever

        # verify payload has necessary information
        if 'nic' not in payload:
            resp.body = "(False, 'payload missing nic')"
            return
        if 'id' not in payload:
            resp.body = "(False, 'payload missing id')"
            return
        if 'interval' not in payload:
            resp.body = "(False, 'payload missing interval')"
            return
        if 'iters' not in payload:
            resp.body = "(False, 'payload missing iters')"
            return

        # connect to docker
        c = None
        try:
            c = docker.from_env()
        except Exception as e:  # pragma: no cover
            resp.body = "(False, 'unable to connect to docker because: " + str(e) + "')"
            return

        # spin up container with payload specifications
        if c:
            tool_d = {'network_mode': 'host',
                      'volumes_from': [socket.gethostname()]}

            cmd = '/tmp/run.sh ' + payload['nic'] + ' ' + payload['interval']
            cmd += ' ' + payload['id'] + ' ' + payload['iters'] + ' "'
            cmd += payload['filter'] + '"'
            try:
                container = c.containers.run(image='cyberreboot/vent-ncapture:master',
                                             command=cmd, remove=True, detach=True, **tool_d)
                resp.body = "(True, 'successfully created and started filter: " + \
                    str(payload['id']) + ' on container: ' + \
                    str(container.id) + "')"
            except Exception as e:  # pragma: no cover
                resp.body = "(False, 'unable to start container because: " + str(e) + "')"
                return

        return
972522
def checkAndCreate(self, key, payload):
        
        if key not in self:
            if 'templates' in payload:
                templates = payload.pop('templates')
            self[key] = payload
            self.reload()
        return self[key]['id']
1218053
def send_tick(self, payload=""):
        
        data = self.message(MessageType.SEND_TICK, payload)
        return json.loads(data, object_hook=TickReply)
1357171
def payload(self):
    """"""
    try:
      rdf_cls = self.classes.get(self.name)
      if rdf_cls:
        value = rdf_cls.FromSerializedString(self.data)
        value.age = self.embedded_age

        return value
    except TypeError:
      return None
1273568
def _read_payload(self):
        
        comm('reading payload data')
        comm('remaining bytes to read: %d', self._to_read)
        data_read = self.read(self._to_read)
        nb_bytes_read = len(data_read)
        comm('%d bytes read', nb_bytes_read)
        self._data_buf += data_read
        self._to_read -= nb_bytes_read
        if self._to_read <= 0:
            try:
                data = self._data_buf.decode('utf-8')
            except AttributeError:
                data = bytes(self._data_buf.data()).decode('utf-8')
            comm('payload read: %r', data)
            comm('payload length: %r', len(self._data_buf))
            comm('decoding payload as json object')
            obj = json.loads(data)
            comm('response received: %r', obj)
            try:
                results = obj['results']
            except (KeyError, TypeError):
                results = None
            # possible callback
            if self._callback and self._callback():
                self._callback()(results)
            self._header_complete = False
            self._data_buf = bytes()
            self.finished.emit(self)
691075
def _nest_payload(self, keys, payload):
        
        if len(keys) == 0:
            return payload

        return {keys[0]: self._nest_payload(keys[1:], payload)}
892188
def __bytes_to_share_data(self, payload):
        """"""
        rbytes = payload[P_DATA]
        mime = payload[P_MIME]

        if mime is None or not self.__auto_encode_decode:
            return rbytes, mime
        mime = expand_idx_mimetype(mime).lower()
        try:
            if mime == 'application/ubjson':
                return ubjloadb(rbytes), None
            elif mime == 'text/plain; charset=utf8':
                return rbytes.decode('utf-8'), None
            else:
                return rbytes, mime
        except:
            logger.warning('auto-decode failed, returning bytes', exc_info=DEBUG_ENABLED)
            return rbytes, mime
873377
def _sign_payload(self, payload):
        
        app_key = self._app_key
        t = int(time.time() * 1000)
        requestStr = {
            'header': self._req_header,
            'model': payload
        }
        data = json.dumps({'requestStr': json.dumps(requestStr)})
        data_str = '{}&{}&{}&{}'.format(self._req_token, t, app_key, data)
        sign = hashlib.md5(data_str.encode('utf-8')).hexdigest()
        params = {
            't': t,
            'appKey': app_key,
            'sign': sign,
            'data': data,
        }
        return params
662167
def parse_payload(data, payload_fmt, *payload_names):
    
    payload = struct.unpack(payload_fmt, data)
    return dict(zip(payload_names, payload))
6572
def to_api_repr(self):
        
        info = super(StructEntry, self).to_api_repr()
        info["jsonPayload"] = self.payload
        return info
1292859
def get_single_payload(self, query_obj):
        """"""
        payload = self.get_df_payload(query_obj)
        df = payload.get('df')
        status = payload.get('status')
        if status != utils.QueryStatus.FAILED:
            if df is not None and df.empty:
                payload['error'] = 'No data'
            else:
                payload['data'] = self.get_data(df)
        if 'df' in payload:
            del payload['df']
        return payload
457732
def get_instance(self, payload):
        
        return SyncMapInstance(self._version, payload, service_sid=self._solution['service_sid'], )
549063
def insert(self, payload):
        
        response = self.session.post(self._get_table_url(), data=json.dumps(payload))
        return self._get_content(response)
137639
def minimal_payload(self):
        
        payload_dict = self.__dict__
        payload_dict.pop("api_version", None)
        return util._make_minimal(payload_dict)
914153
def _got_sol_payload(self, payload):
        
        # TODO(jbjohnso) test cases to throw some likely scenarios at functions
        # for example, retry with new data, retry with no new data
        # retry with unexpected sequence number
        if type(payload) == dict:  # we received an error condition
            self.activated = False
            self._print_error(payload)
            return
        newseq = payload[0] & 0b1111
        ackseq = payload[1] & 0b1111
        ackcount = payload[2]
        nacked = payload[3] & 0b1000000
        breakdetected = payload[3] & 0b10000
        # for now, ignore overrun.  I assume partial NACK for this reason or
        # for no reason would be treated the same, new payload with partial
        # data.
        remdata = ""
        remdatalen = 0
        flag = 0
        if not self.poweredon:
            flag |= 0b1100000
        if not self.activated:
            flag |= 0b1010000
        if newseq != 0:  # this packet at least has some data to send to us..
            if len(payload) > 4:
                remdatalen = len(payload[4:])  # store remote len before dupe
                # retry logic, we must ack *this* many even if it is
                # a retry packet with new partial data
                remdata = bytes(payload[4:])
            if newseq == self.remseq:  # it is a retry, but could have new data
                if remdatalen > self.lastsize:
                    remdata = bytes(remdata[4 + self.lastsize:])
                else:  # no new data...
                    remdata = ""
            else:  # TODO(jbjohnso) what if remote sequence number is wrong??
                self.remseq = newseq
            self.lastsize = remdatalen
            ackpayload = bytearray((0, self.remseq, remdatalen, flag))
            # Why not put pending data into the ack? because it's rare
            # and might be hard to decide what to do in the context of
            # retry situation
            try:
                self.send_payload(ackpayload, retry=False)
            except exc.IpmiException:
                # if the session is broken, then close the SOL session
                self.close()
            if remdata:  # Do not subject callers to empty data
                self._print_data(remdata)
        if self.myseq != 0 and ackseq == self.myseq:  # the bmc has something
            # to say about last xmit
            self.awaitingack = False
            if nacked and not breakdetected:  # the BMC was in some way unhappy
                newtext = self.lastpayload[4 + ackcount:]
                with self.outputlock:
                    if (self.pendingoutput and
                            not isinstance(self.pendingoutput[0], dict)):
                        self.pendingoutput[0] = newtext + self.pendingoutput[0]
                    else:
                        self.pendingoutput = [newtext] + self.pendingoutput
            # self._sendpendingoutput() checks len(self._sendpendingoutput)
            self._sendpendingoutput()
        elif ackseq != 0 and self.awaitingack:
            # if an ack packet came in, but did not match what we
            # expected, retry our payload now.
            # the situation that was triggered was a senseless retry
            # when data came in while we xmitted.  In theory, a BMC
            # should handle a retry correctly, but some do not, so
            # try to mitigate by avoiding overeager retries
            # occasional retry of a packet
            # sooner than timeout suggests is evidently a big deal
            self.send_payload(payload=self.lastpayload)
502604
def _get_payload(self, key):
        
        path = self._path(key)

        # If the file doesn't exists, we obviously can't return the cache so we will
        # just return null. Otherwise, we'll get the contents of the file and get
        # the expiration UNIX timestamps from the start of the file's contents.
        if not os.path.exists(path):
            return {'data': None, 'time': None}

        with open(path, 'rb') as fh:
            contents = fh.read()

        expire = int(contents[:10])

        # If the current time is greater than expiration timestamps we will delete
        # the file and return null. This helps clean up the old files and keeps
        # this directory much cleaner for us as old files aren't hanging out.
        if round(time.time()) >= expire:
            self.forget(key)

            return {'data': None, 'time': None}

        data = self.unserialize(contents[10:])

        # Next, we'll extract the number of minutes that are remaining for a cache
        # so that we can properly retain the time for things like the increment
        # operation that may be performed on the cache. We'll round this out.
        time_ = math.ceil((expire - round(time.time())) / 60.)

        return {'data': data, 'time': time_}