示例#1
0
def _parse_append_block(response):
    '''
    Extracts append block response headers.
    '''
    append_block = AppendBlockProperties()
    append_block.last_modified = parser.parse(response.headers.get('last-modified'))
    append_block.etag = response.headers.get('etag')
    append_block.append_offset = _int_to_str(response.headers.get('x-ms-blob-append-offset'))
    append_block.committed_block_count = _int_to_str(response.headers.get('x-ms-blob-committed-block-count'))

    return append_block
def _parse_metadata_and_message_count(response):
    '''
    Extracts approximate messages count header.
    '''
    metadata = _parse_metadata(response)
    metadata.approximate_message_count = _int_to_str(
        response.headers.get('x-ms-approximate-messages-count'))

    return metadata
示例#3
0
def _parse_page_properties(response):
    '''
    Extracts page response headers.
    '''
    put_page = PageBlobProperties()
    put_page.last_modified = parser.parse(response.headers.get('last-modified'))
    put_page.etag = response.headers.get('etag')
    put_page.sequence_number = _int_to_str(response.headers.get('x-ms-blob-sequence-number'))

    return put_page
示例#4
0
def _parse_lease(response):
    '''
    Extracts lease time and ID return headers.
    '''
    lease = {'time': response.headers.get('x-ms-lease-time')}
    if lease['time']:
        lease['time'] = _int_to_str(lease['time'])

    lease['id'] = response.headers.get('x-ms-lease-id')

    return lease
def _convert_xml_to_queue_messages(response,
                                   decode_function,
                                   require_encryption,
                                   key_encryption_key,
                                   resolver,
                                   content=None):
    '''
    <?xml version="1.0" encoding="utf-8"?>
    <QueueMessagesList>
        <QueueMessage>
          <MessageId>string-message-id</MessageId>
          <InsertionTime>insertion-time</InsertionTime>
          <ExpirationTime>expiration-time</ExpirationTime>
          <PopReceipt>opaque-string-receipt-data</PopReceipt>
          <TimeNextVisible>time-next-visible</TimeNextVisible>
          <DequeueCount>integer</DequeueCount>
          <MessageText>message-body</MessageText>
        </QueueMessage>
    </QueueMessagesList>
    '''
    if response is None or response.body is None:
        return None

    messages = list()
    list_element = ETree.fromstring(response.body)

    for message_element in list_element.findall('QueueMessage'):
        message = QueueMessage()

        message.id = message_element.findtext('MessageId')

        dequeue_count = message_element.findtext('DequeueCount')
        if dequeue_count is not None:
            message.dequeue_count = _int_to_str(dequeue_count)

        # content is not returned for put_message
        if content is not None:
            message.content = content
        else:
            message.content = message_element.findtext('MessageText')
            if (key_encryption_key is not None) or (resolver is not None):
                message.content = _decrypt_queue_message(
                    message.content, require_encryption, key_encryption_key,
                    resolver)
            message.content = decode_function(message.content)

        message.insertion_time = parser.parse(
            message_element.findtext('InsertionTime'))
        message.expiration_time = parser.parse(
            message_element.findtext('ExpirationTime'))

        message.pop_receipt = message_element.findtext('PopReceipt')

        time_next_visible = message_element.find('TimeNextVisible')
        if time_next_visible is not None:
            message.time_next_visible = parser.parse(time_next_visible.text)

        # Add message to list
        messages.append(message)

    return messages