Encode request into client_message
15522
def encode_request(name, uuid, callable, address):
    
    client_message = ClientMessage(payload_size=calculate_size(name, uuid, callable, address))
    client_message.set_message_type(REQUEST_TYPE)
    client_message.set_retryable(RETRYABLE)
    client_message.append_str(name)
    client_message.append_str(uuid)
    client_message.append_data(callable)
    AddressCodec.encode(client_message, address)
    client_message.update_frame_length()
    return client_message
1091692
def encode_request(name, expected, updated):
    
    client_message = ClientMessage(payload_size=calculate_size(name, expected, updated))
    client_message.set_message_type(REQUEST_TYPE)
    client_message.set_retryable(RETRYABLE)
    client_message.append_str(name)
    client_message.append_bool(expected is None)
    if expected is not None:
        client_message.append_data(expected)
    client_message.append_bool(updated is None)
    if updated is not None:
        client_message.append_data(updated)
    client_message.update_frame_length()
    return client_message
673275
def encode_offset_commit_request(cls, client_id, correlation_id,
                                     group, payloads):
        
        grouped_payloads = group_by_topic_and_partition(payloads)

        message = []
        message.append(cls._encode_message_header(client_id, correlation_id,
                                                  KafkaProtocol.OFFSET_COMMIT_KEY))
        message.append(write_short_string(group))
        message.append(struct.pack('>i', len(grouped_payloads)))

        for topic, topic_payloads in grouped_payloads.items():
            message.append(write_short_string(topic))
            message.append(struct.pack('>i', len(topic_payloads)))

            for partition, payload in topic_payloads.items():
                message.append(struct.pack('>iq', partition, payload.offset))
                message.append(write_short_string(payload.metadata))

        msg = b''.join(message)
        return struct.pack('>i%ds' % len(msg), len(msg), msg)
586524
def encode_request(uuid, address, interrupt):
    
    client_message = ClientMessage(payload_size=calculate_size(uuid, address, interrupt))
    client_message.set_message_type(REQUEST_TYPE)
    client_message.set_retryable(RETRYABLE)
    client_message.append_str(uuid)
    AddressCodec.encode(client_message, address)
    client_message.append_bool(interrupt)
    client_message.update_frame_length()
    return client_message
41966
def _decode_request(self, encoded_request):
        """"""
        obj = self.serializer.loads(encoded_request)
        return request_from_dict(obj, self.spider)
719799
def to_mime_message(self):
        """"""
        msg = MIMEMultipart('alternative')
        msg['Subject'] = self._header(self._subject or '')

        msg['From'] = self._encoded(self._addrs_to_header([self._from]))
        msg['To'] = self._encoded(self._addrs_to_header(self._to))

        if self._cc:
            msg['CC'] = self._addrs_to_header(self._cc)

        if self._headers:
            for key, value in self._headers.items():
                msg[key] = self._header(value)

        for part in self._parts:
            type_maj, type_min = part[0].split('/')
            if type_maj == 'text' and type_min in ('html', 'plain'):
                msg.attach(MIMEText(part[1], type_min, self._charset))
            else:
                msg.attach(part[1])

        return msg
1147706
def _encode_request(self, request):
        """"""
        obj = request_to_dict(request, self.spider)
        return self.serializer.dumps(obj)
1125899
def encode_request(name, data_list):
    
    client_message = ClientMessage(payload_size=calculate_size(name, data_list))
    client_message.set_message_type(REQUEST_TYPE)
    client_message.set_retryable(RETRYABLE)
    client_message.append_str(name)
    client_message.append_int(len(data_list))
    for data_list_item in data_list:
        client_message.append_data(data_list_item)
    client_message.update_frame_length()
    return client_message
162139
def encode(cls, d):
        
        warnings.warn(
            'The `encode` class method of APIRequestor is deprecated and '
            'will be removed in version 2.0.'
            'If you need public access to this function, please email us '
            'at support@stripe.com.',
            DeprecationWarning)
        return urllib.urlencode(list(_api_encode(d)))
983696
def encode_request(uuid, partition_id, interrupt):
    
    client_message = ClientMessage(payload_size=calculate_size(uuid, partition_id, interrupt))
    client_message.set_message_type(REQUEST_TYPE)
    client_message.set_retryable(RETRYABLE)
    client_message.append_str(uuid)
    client_message.append_int(partition_id)
    client_message.append_bool(interrupt)
    client_message.update_frame_length()
    return client_message
196629
def decode_response(client_message, to_object=None):
    
    parameters = dict(read_count=None, items=None)
    parameters['read_count'] = client_message.read_int()
    items_size = client_message.read_int()
    items = []
    for _ in range(0, items_size):
        items_item = client_message.read_data()
        items.append(items_item)
    parameters['items'] = ImmutableLazyDataList(items, to_object)
    return parameters
849775
def _send_signed_request(url, payload):
    
    payload64 = _b64(json.dumps(payload).encode('utf8'))

    out = parse_account_key()
    header = get_boulder_header(out)

    protected = copy.deepcopy(header)
    protected["nonce"] = urlopen(DEFAULT_CA + "/directory").headers['Replay-Nonce']
    protected64 = _b64(json.dumps(protected).encode('utf8'))
    cmd = [
        'openssl', 'dgst',
        '-sha256',
        '-sign', os.path.join(gettempdir(), 'account.key')
    ]
    proc = subprocess.Popen(
        cmd,
        stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE
    )
    out, err = proc.communicate("{0}.{1}".format(protected64, payload64).encode('utf8'))
    if proc.returncode != 0: # pragma: no cover
        raise IOError("OpenSSL Error: {0}".format(err))
    data = json.dumps({
        "header": header, "protected": protected64,
        "payload": payload64, "signature": _b64(out),
    })
    try:
        resp = urlopen(url, data.encode('utf8'))
        return resp.getcode(), resp.read()
    except IOError as e:
        return getattr(e, "code", None), getattr(e, "read", e.__str__)()
1371234
def encode_request(username, password, uuid, owner_uuid, is_owner_connection, client_type, serialization_version, client_hazelcast_version):
    
    client_message = ClientMessage(payload_size=calculate_size(username, password, uuid, owner_uuid, is_owner_connection, client_type, serialization_version, client_hazelcast_version))
    client_message.set_message_type(REQUEST_TYPE)
    client_message.set_retryable(RETRYABLE)
    client_message.append_str(username)
    client_message.append_str(password)
    client_message.append_bool(uuid is None)
    if uuid is not None:
        client_message.append_str(uuid)
    client_message.append_bool(owner_uuid is None)
    if owner_uuid is not None:
        client_message.append_str(owner_uuid)
    client_message.append_bool(is_owner_connection)
    client_message.append_str(client_type)
    client_message.append_byte(serialization_version)
    client_message.append_str(client_hazelcast_version)
    client_message.update_frame_length()
    return client_message
716327
def send_request(request)
      message = RemoteMessage.new(request_message: request).serialize_to_string
      message_size = [message.length].pack('N')
      @ssl_client.write(message_size + message)
    end
690872
def encode_request(name, items):
    
    client_message = ClientMessage(payload_size=calculate_size(name, items))
    client_message.set_message_type(REQUEST_TYPE)
    client_message.set_retryable(RETRYABLE)
    client_message.append_str(name)
    client_message.append_int(len(items))
    for items_item in items:
        client_message.append_data(items_item)
    client_message.update_frame_length()
    return client_message
717973
def _get_request_messages(self, request):
        
        data = request.get_data(as_text=True)
        try:
            msg = self.json_decoder.decode(data)
        except Exception:
            raise ParseError("Could not parse request data '{}'".format(data))
        if isinstance(msg, list):
            return msg
        else:
            return [msg]
621977
def encode_consumermetadata_request(cls, client_id, correlation_id,
                                        consumer_group):
        
        message = cls._encode_message_header(client_id, correlation_id,
                                             KafkaCodec.CONSUMER_METADATA_KEY)
        message += write_short_ascii(consumer_group)
        return message