Ejemplo n.º 1
0
    def peek_lock_subscription_message(self, topic_name, subscription_name, timeout='60'):
        '''
        This operation is used to atomically retrieve and lock a message for 
        processing. The message is guaranteed not to be delivered to other 
        receivers during the lock duration period specified in buffer 
        description. Once the lock expires, the message will be available to 
        other receivers (on the same subscription only) during the lock 
        duration period specified in the topic description. Once the lock 
        expires, the message will be available to other receivers. In order to 
        complete processing of the message, the receiver should issue a delete 
        command with the lock ID received from this operation. To abandon 
        processing of the message and unlock it for other receivers, an Unlock 
        Message command should be issued, or the lock duration period can 
        expire.
        
        topic_name: Name of the topic.
        subscription_name: Name of the subscription.
        timeout: Optional. The timeout parameter is expressed in seconds.
        '''
        _validate_not_none('topic_name', topic_name)
        _validate_not_none('subscription_name', subscription_name)
        request = HTTPRequest()
        request.method = 'POST'
        request.host = self._get_host()
        request.path = '/' + _str(topic_name) + '/subscriptions/' + _str(subscription_name) + '/messages/head'
        request.query = [('timeout', _int_or_none(timeout))]
        request.path, request.query = _update_request_uri_query(request)
        request.headers = self._update_service_bus_header(request)
        response = self._perform_request(request)

        return _create_message(response, self)
Ejemplo n.º 2
0
    def query_entities(self,
                       table_name,
                       filter=None,
                       select=None,
                       top=None,
                       next_partition_key=None,
                       next_row_key=None):
        '''
        Get entities in a table; includes the $filter and $select options. 
        
        table_name: the table to query
        filter: a filter as described at http://msdn.microsoft.com/en-us/library/windowsazure/dd894031.aspx
        select: the property names to select from the entities
        top: the maximum number of entities to return
        '''
        _validate_not_none('table_name', table_name)
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self._get_host()
        request.path = '/' + _str(table_name) + '()'
        request.query = [('$filter', _str_or_none(filter)),
                         ('$select', _str_or_none(select)),
                         ('$top', _int_or_none(top)),
                         ('NextPartitionKey',
                          _str_or_none(next_partition_key)),
                         ('NextRowKey', _str_or_none(next_row_key))]
        request.path, request.query = _update_request_uri_query_local_storage(
            request, self.use_local_storage)
        request.headers = _update_storage_table_header(request)
        response = self._perform_request(request)

        return _convert_response_to_feeds(response, _convert_xml_to_entity)
Ejemplo n.º 3
0
    def list_blobs(self,
                   container_name,
                   prefix=None,
                   marker=None,
                   maxresults=None,
                   include=None):
        '''
        Returns the list of blobs under the specified container.
        '''
        _validate_not_none('container_name', container_name)
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self._get_host()
        request.path = '/' + str(
            container_name) + '?restype=container&comp=list'
        request.query = [('prefix', _str_or_none(prefix)),
                         ('marker', _str_or_none(marker)),
                         ('maxresults', _int_or_none(maxresults)),
                         ('include', _str_or_none(include))]
        request.path, request.query = _update_request_uri_query_local_storage(
            request, self.use_local_storage)
        request.headers = _update_storage_blob_header(request,
                                                      self.account_name,
                                                      self.account_key)
        response = self._perform_request(request)

        return _parse_enum_results_list(response, BlobEnumResults, "Blobs",
                                        Blob)
Ejemplo n.º 4
0
    def query_entities(self, table_name, filter=None, select=None, top=None, next_partition_key=None, next_row_key=None):
        """
        Get entities in a table; includes the $filter and $select options.

        table_name: Table to query.
        filter:
            Optional. Filter as described at
            http://msdn.microsoft.com/en-us/library/windowsazure/dd894031.aspx
        select: Optional. Property names to select from the entities.
        top: Optional. Maximum number of entities to return.
        next_partition_key:
            Optional. When top is used, the next partition key is stored in
            result.x_ms_continuation['NextPartitionKey']
        next_row_key:
            Optional. When top is used, the next partition key is stored in
            result.x_ms_continuation['NextRowKey']
        """
        _validate_not_none('table_name', table_name)
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self._get_host()
        request.path = '/' + _str(table_name) + '()'
        request.query = [
            ('$filter', _str_or_none(filter)),
            ('$select', _str_or_none(select)),
            ('$top', _int_or_none(top)),
            ('NextPartitionKey', _str_or_none(next_partition_key)),
            ('NextRowKey', _str_or_none(next_row_key))
        ]
        request.path, request.query = _update_request_uri_query_local_storage(
            request, self.use_local_storage)
        request.headers = _update_storage_table_header(request)
        response = self._perform_request(request)

        return _convert_response_to_feeds(response, _convert_xml_to_entity)
Ejemplo n.º 5
0
    def peek_lock_subscription_message(self, topic_name, subscription_name, timeout='60'):
        '''
        This operation is used to atomically retrieve and lock a message for processing. 
        The message is guaranteed not to be delivered to other receivers during the lock 
        duration period specified in buffer description. Once the lock expires, the 
        message will be available to other receivers (on the same subscription only) 
        during the lock duration period specified in the topic description. Once the lock
        expires, the message will be available to other receivers. In order to complete 
        processing of the message, the receiver should issue a delete command with the 
        lock ID received from this operation. To abandon processing of the message and 
        unlock it for other receivers, an Unlock Message command should be issued, or 
        the lock duration period can expire. 
        
        topic_name: the name of the topic
        subscription_name: the name of the subscription
        '''
        _validate_not_none('topic_name', topic_name)
        _validate_not_none('subscription_name', subscription_name)
        request = HTTPRequest()
        request.method = 'POST'
        request.host = self._get_host()
        request.path = '/' + str(topic_name) + '/subscriptions/' + str(subscription_name) + '/messages/head'
        request.query = [('timeout', _int_or_none(timeout))]
        request.path, request.query = _update_request_uri_query(request)
        request.headers = _update_service_bus_header(request, self.account_key, self.issuer)
        response = self._perform_request(request)

        return _create_message(response, self)
Ejemplo n.º 6
0
    def list_containers(self,
                        prefix=None,
                        marker=None,
                        maxresults=None,
                        include=None):
        '''
        The List Containers operation returns a list of the containers under the specified account.
        
        prefix: Optional. Filters the results to return only containers whose names begin with
        		the specified prefix. 
        marker: Optional. A string value that identifies the portion of the list to be returned 
                with the next list operation.
        maxresults: Optional. Specifies the maximum number of containers to return. 
        include: Optional. Include this parameter to specify that the container's metadata be 
                returned as part of the response body. set this parameter to string 'metadata' to
        		get container's metadata.
        '''
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self._get_host()
        request.path = '/?comp=list'
        request.query = [('prefix', _str_or_none(prefix)),
                         ('marker', _str_or_none(marker)),
                         ('maxresults', _int_or_none(maxresults)),
                         ('include', _str_or_none(include))]
        request.path, request.query = _update_request_uri_query_local_storage(
            request, self.use_local_storage)
        request.headers = _update_storage_blob_header(request,
                                                      self.account_name,
                                                      self.account_key)
        response = self._perform_request(request)

        return _parse_enum_results_list(response, ContainerEnumResults,
                                        "Containers", Container)
Ejemplo n.º 7
0
    def query_entities(self, table_name, filter=None, select=None, top=None, next_partition_key=None, next_row_key=None):
        '''
        Get entities in a table; includes the $filter and $select options. 
        
        table_name: the table to query
        filter: a filter as described at http://msdn.microsoft.com/en-us/library/windowsazure/dd894031.aspx
        select: the property names to select from the entities
        top: the maximum number of entities to return
        '''
        _validate_not_none('table_name', table_name)
        request = HTTPRequest()
        request.method = 'GET'
        request.host = _get_table_host(self.account_name, self.use_local_storage)
        request.path = '/' + str(table_name) + '()'
        request.query = [
            ('$filter', _str_or_none(filter)),
            ('$select', _str_or_none(select)),
            ('$top', _int_or_none(top)),
            ('NextPartitionKey', _str_or_none(next_partition_key)),
            ('NextRowKey', _str_or_none(next_row_key))
            ]
        request.path, request.query = _update_request_uri_query_local_storage(request, self.use_local_storage)
        request.headers = _update_storage_table_header(request)
        response = self._perform_request(request)

        return _convert_response_to_feeds(response, _convert_xml_to_entity)
Ejemplo n.º 8
0
 def set_blob_service_properties(self,
                                 storage_service_properties,
                                 timeout=None):
     '''
     Sets the properties of a storage account's Blob service, including Windows Azure 
     Storage Analytics. You can also use this operation to set the default request 
     version for all incoming requests that do not have a version specified.
     
     storage_service_properties: a StorageServiceProperties object.
     timeout: Optional. The timeout parameter is expressed in seconds. For example, the 
     		following value sets a timeout of 30 seconds for the request: timeout=30.
     '''
     _validate_not_none('storage_service_properties',
                        storage_service_properties)
     request = HTTPRequest()
     request.method = 'PUT'
     request.host = self._get_host()
     request.path = '/?restype=service&comp=properties'
     request.query = [('timeout', _int_or_none(timeout))]
     request.body = _get_request_body(
         _convert_class_to_xml(storage_service_properties))
     request.path, request.query = _update_request_uri_query_local_storage(
         request, self.use_local_storage)
     request.headers = _update_storage_blob_header(request,
                                                   self.account_name,
                                                   self.account_key)
     response = self._perform_request(request)
Ejemplo n.º 9
0
    def set_queue_service_properties(self, storage_service_properties,
                                     timeout=None):
        '''
        Sets the properties of a storage account's Queue service, including
        Windows Azure Storage Analytics.

        storage_service_properties:
            StorageServiceProperties object.
        timeout:
            Optional. The timeout parameter is expressed in seconds.
        '''
        _validate_not_none('storage_service_properties',
                           storage_service_properties)
        request = HTTPRequest()
        request.method = 'PUT'
        request.host = self._get_host()
        request.path = '/?restype=service&comp=properties'
        request.query = [('timeout', _int_or_none(timeout))]
        request.body = _get_request_body(
            _convert_class_to_xml(storage_service_properties))
        request.path, request.query = _update_request_uri_query_local_storage(
            request, self.use_local_storage)
        request.headers = _update_storage_queue_header(
            request, self.authentication)
        self._perform_request(request)
Ejemplo n.º 10
0
    def set_properties(self, blob_service, storage_service_properties):
        """
        Override API methods to change the API version and send the right
        headers
        """
        request = HTTPRequest()
        request.method = 'PUT'
        request.host = blob_service._get_host()
        request.path = '/?restype=service&comp=properties'
        request.query = [('timeout', _int_or_none(None))]
        request.body = _get_request_body(
            _convert_class_to_xml(storage_service_properties))
        request.path, request.query = _update_request_uri_query_local_storage(
            request, blob_service.use_local_storage)
        request.headers = self.get_request_headers(
            request, blob_service.account_name, blob_service.account_key)

        try:
            if blob_service._batchclient is not None:
                return blob_service._batchclient.insert_request_to_batch(request)
            else:
                resp = blob_service._filter(request)

            if sys.version_info >= (3,) and isinstance(resp, bytes) and \
                'UTF-8':
                resp = resp.decode('UTF-8')

        except:
            raise

        return resp
Ejemplo n.º 11
0
    def list_containers(self, prefix=None, marker=None, maxresults=None, include=None):
        '''
        The List Containers operation returns a list of the containers under the specified account.
        
        prefix: Optional. Filters the results to return only containers whose names begin with
        		the specified prefix. 
        marker: Optional. A string value that identifies the portion of the list to be returned 
                with the next list operation.
        maxresults: Optional. Specifies the maximum number of containers to return. 
        include: Optional. Include this parameter to specify that the container's metadata be 
                returned as part of the response body. set this parameter to string 'metadata' to
        		get container's metadata.
        '''
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self._get_host()
        request.path = '/?comp=list'
        request.query = [
            ('prefix', _str_or_none(prefix)),
            ('marker', _str_or_none(marker)),
            ('maxresults', _int_or_none(maxresults)),
            ('include', _str_or_none(include))
            ]
        request.path, request.query = _update_request_uri_query_local_storage(request, self.use_local_storage)
        request.headers = _update_storage_blob_header(request, self.account_name, self.account_key)
        response = self._perform_request(request)

        return _parse_enum_results_list(response, ContainerEnumResults, "Containers", Container)
Ejemplo n.º 12
0
 def set_queue_service_properties(self,
                                  storage_service_properties,
                                  timeout=None):
     '''
     Sets the properties of a storage account's Queue service, including Windows Azure 
     Storage Analytics.
     
     storage_service_properties: a StorageServiceProperties object.
     timeout: Optional. The timeout parameter is expressed in seconds.
     '''
     _validate_not_none('storage_service_properties',
                        storage_service_properties)
     request = HTTPRequest()
     request.method = 'PUT'
     request.host = self._get_host()
     request.path = '/?restype=service&comp=properties'
     request.query = [('timeout', _int_or_none(timeout))]
     request.body = _get_request_body(
         _convert_class_to_xml(storage_service_properties))
     request.path, request.query = _update_request_uri_query_local_storage(
         request, self.use_local_storage)
     request.headers = _update_storage_queue_header(request,
                                                    self.account_name,
                                                    self.account_key)
     response = self._perform_request(request)
Ejemplo n.º 13
0
    def read_delete_subscription_message(self, topic_name, subscription_name,
                                         timeout='60'):
        '''
        Read and delete a message from a subscription as an atomic operation.
        This operation should be used when a best-effort guarantee is
        sufficient for an application; that is, using this operation it is
        possible for messages to be lost if processing fails.

        topic_name:
            Name of the topic.
        subscription_name:
            Name of the subscription.
        timeout:
            Optional. The timeout parameter is expressed in seconds.
        '''
        _validate_not_none('topic_name', topic_name)
        _validate_not_none('subscription_name', subscription_name)
        request = HTTPRequest()
        request.method = 'DELETE'
        request.host = self._get_host()
        request.path = '/' + _str(topic_name) + \
                       '/subscriptions/' + _str(subscription_name) + \
                       '/messages/head'
        request.query = [('timeout', _int_or_none(timeout))]
        request.path, request.query = _update_request_uri_query(request)
        request.headers = self._update_service_bus_header(request)
        response = self._perform_request(request)

        return _create_message(response, self)
    def query_tables(self, table_name = None, top=None, next_table_name=None):
        '''
        Returns a list of tables under the specified account.
        
        table_name: Optional.  The specific table to query.
        top: Optional. Maximum number of tables to return.
        next_table_name:
            Optional. When top is used, the next table name is stored in 
            result.x_ms_continuation['NextTableName']
        '''
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self._get_host()
        if table_name is not None:
            uri_part_table_name = "('" + table_name + "')"
        else:
            uri_part_table_name = ""
        request.path = '/Tables' + uri_part_table_name + ''
        request.query = [
            ('$top', _int_or_none(top)),
            ('NextTableName', _str_or_none(next_table_name))
            ]
        request.path, request.query = _update_request_uri_query_local_storage(request, self.use_local_storage)
        request.headers = _update_storage_table_header(request)
        response = self._perform_request(request)

        return _convert_response_to_feeds(response, _convert_xml_to_table)
Ejemplo n.º 15
0
    def peek_lock_queue_message(self, queue_name, timeout='60'):
        '''
        Automically retrieves and locks a message from a queue for processing.
        The message is guaranteed not to be delivered to other receivers (on
        the same subscription only) during the lock duration period specified
        in the queue description. Once the lock expires, the message will be
        available to other receivers. In order to complete processing of the
        message, the receiver should issue a delete command with the lock ID
        received from this operation. To abandon processing of the message and
        unlock it for other receivers, an Unlock Message command should be
        issued, or the lock duration period can expire.

        queue_name:
            Name of the queue.
        timeout:
            Optional. The timeout parameter is expressed in seconds.
        '''
        _validate_not_none('queue_name', queue_name)
        request = HTTPRequest()
        request.method = 'POST'
        request.host = self._get_host()
        request.path = '/' + _str(queue_name) + '/messages/head'
        request.query = [('timeout', _int_or_none(timeout))]
        request.path, request.query = _update_request_uri_query(request)
        request.headers = self._update_service_bus_header(request)
        response = self._perform_request(request)

        return _create_message(response, self)
    def peek_lock_queue_message(self, queue_name, timeout='60'):
        '''
        Automically retrieves and locks a message from a queue for processing. The 
        message is guaranteed not to be delivered to other receivers (on the same 
        subscription only) during the lock duration period specified in the queue 
        description. Once the lock expires, the message will be available to other 
        receivers. In order to complete processing of the message, the receiver 
        should issue a delete command with the lock ID received from this operation. 
        To abandon processing of the message and unlock it for other receivers, 
        an Unlock Message command should be issued, or the lock duration period 
        can expire.
        
        queue_name: name of the queue
        '''
        _validate_not_none('queue_name', queue_name)
        request = HTTPRequest()
        request.method = 'POST'
        request.host = self.service_namespace + SERVICE_BUS_HOST_BASE
        request.path = '/' + str(queue_name) + '/messages/head'
        request.query = [('timeout', _int_or_none(timeout))]
        request.path, request.query = _update_request_uri_query(request)
        request.headers = _update_service_bus_header(request, self.account_key, self.issuer)
        response = self._perform_request(request)

        return _create_message(response, self)
Ejemplo n.º 17
0
    def set_properties(self, blob_service, storage_service_properties):
        """
        Override API methods to change the API version and send the right
        headers
        """
        request = HTTPRequest()
        request.method = 'PUT'
        request.host = blob_service._get_host()
        request.path = '/?restype=service&comp=properties'
        request.query = [('timeout', _int_or_none(None))]
        request.body = _get_request_body(
            _convert_class_to_xml(storage_service_properties))
        request.path, request.query = _update_request_uri_query_local_storage(
            request, blob_service.use_local_storage)
        request.headers = self.get_request_headers(request,
                                                   blob_service.account_name,
                                                   blob_service.account_key)

        try:
            if blob_service._batchclient is not None:
                return blob_service._batchclient.insert_request_to_batch(
                    request)
            else:
                resp = blob_service._filter(request)

            if sys.version_info >= (3,) and isinstance(resp, bytes) and \
                'UTF-8':
                resp = resp.decode('UTF-8')

        except:
            raise

        return resp
Ejemplo n.º 18
0
    def read_delete_subscription_message(self,
                                         topic_name,
                                         subscription_name,
                                         timeout='60'):
        '''
        Read and delete a message from a subscription as an atomic operation.
        This operation should be used when a best-effort guarantee is
        sufficient for an application; that is, using this operation it is
        possible for messages to be lost if processing fails.

        topic_name: Name of the topic.
        subscription_name: Name of the subscription.
        timeout: Optional. The timeout parameter is expressed in seconds.
        '''
        _validate_not_none('topic_name', topic_name)
        _validate_not_none('subscription_name', subscription_name)
        request = HTTPRequest()
        request.method = 'DELETE'
        request.host = self._get_host()
        request.path = '/' + _str(topic_name) + \
                       '/subscriptions/' + _str(subscription_name) + \
                       '/messages/head'
        request.query = [('timeout', _int_or_none(timeout))]
        request.path, request.query = _update_request_uri_query(request)
        request.headers = self._update_service_bus_header(request)
        response = self._perform_request(request)

        return _create_message(response, self)
Ejemplo n.º 19
0
    def list_queues(self,
                    prefix=None,
                    marker=None,
                    maxresults=None,
                    include=None):
        '''
        Lists all of the queues in a given storage account.
        '''
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self._get_host()
        request.path = '/?comp=list'
        request.query = [('prefix', _str_or_none(prefix)),
                         ('marker', _str_or_none(marker)),
                         ('maxresults', _int_or_none(maxresults)),
                         ('include', _str_or_none(include))]
        request.path, request.query = _update_request_uri_query_local_storage(
            request, self.use_local_storage)
        request.headers = _update_storage_queue_header(request,
                                                       self.account_name,
                                                       self.account_key)
        response = self._perform_request(request)

        return _parse_enum_results_list(response, QueueEnumResults, "Queues",
                                        Queue)
Ejemplo n.º 20
0
    def query_tables(self, table_name=None, top=None, next_table_name=None):
        '''
        Returns a list of tables under the specified account.

        table_name:
            Optional.  The specific table to query.
        top:
            Optional. Maximum number of tables to return.
        next_table_name:
            Optional. When top is used, the next table name is stored in
            result.x_ms_continuation['NextTableName']
        '''
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self._get_host()
        if table_name is not None:
            uri_part_table_name = "('" + table_name + "')"
        else:
            uri_part_table_name = ""
        request.path = '/Tables' + uri_part_table_name + ''
        request.query = [('$top', _int_or_none(top)),
                         ('NextTableName', _str_or_none(next_table_name))]
        request.path, request.query = _update_request_uri_query_local_storage(
            request, self.use_local_storage)
        request.headers = _update_storage_table_header(request)
        response = self._perform_request(request)

        return _ETreeXmlToObject.convert_response_to_feeds(
            response, _convert_etree_element_to_table)
Ejemplo n.º 21
0
 def put_page(self, container_name, blob_name, page, x_ms_range, x_ms_page_write, timeout=None, content_md5=None, x_ms_lease_id=None, x_ms_if_sequence_number_lte=None, x_ms_if_sequence_number_lt=None, x_ms_if_sequence_number_eq=None, if_modified_since=None, if_unmodified_since=None, if_match=None, if_none_match=None):
     '''
     Writes a range of pages to a page blob.
     
     container_name: the name of container.
     blob_name: the name of blob
     timeout: the timeout parameter is expressed in seconds.
     x_ms_range: Required. Specifies the range of bytes to be written as a page. Both the start
     		and end of the range must be specified. Must be in format: bytes=startByte-endByte.
     		Given that pages must be aligned with 512-byte boundaries, the start offset must be
     		a modulus of 512 and the end offset must be a modulus of 512-1. Examples of valid
     		byte ranges are 0-511, 512-1023, etc.
     x_ms_page_write: Required. You may specify one of the following options : 
     		1. update(lower case): Writes the bytes specified by the request body into the specified 
     		   range. The Range and Content-Length headers must match to perform the update.
     		2. clear(lower case): Clears the specified range and releases the space used in storage  
     		   for that range. To clear a range, set the Content-Length header to zero, and the Range
     		   header to a value that indicates the range to clear, up to maximum blob size.
     x_ms_lease_id: Required if the blob has an active lease. To perform this operation on a blob
     		 with an active lease, specify the valid lease ID for this header.
     '''
     _validate_not_none('container_name', container_name)
     _validate_not_none('blob_name', blob_name)
     _validate_not_none('page', page)
     _validate_not_none('x_ms_range', x_ms_range)
     _validate_not_none('x_ms_page_write', x_ms_page_write)
     request = HTTPRequest()
     request.method = 'PUT'
     request.host = self._get_host()
     request.path = '/' + _str(container_name) + '/' + _str(blob_name) + '?comp=page'
     request.headers = [
         ('x-ms-range', _str_or_none(x_ms_range)),
         ('Content-MD5', _str_or_none(content_md5)),
         ('x-ms-page-write', _str_or_none(x_ms_page_write)),
         ('x-ms-lease-id', _str_or_none(x_ms_lease_id)),
         ('x-ms-if-sequence-number-lte', _str_or_none(x_ms_if_sequence_number_lte)),
         ('x-ms-if-sequence-number-lt', _str_or_none(x_ms_if_sequence_number_lt)),
         ('x-ms-if-sequence-number-eq', _str_or_none(x_ms_if_sequence_number_eq)),
         ('If-Modified-Since', _str_or_none(if_modified_since)),
         ('If-Unmodified-Since', _str_or_none(if_unmodified_since)),
         ('If-Match', _str_or_none(if_match)),
         ('If-None-Match', _str_or_none(if_none_match))
         ]
     request.query = [('timeout', _int_or_none(timeout))]
     request.body = _get_request_body(page)
     request.path, request.query = _update_request_uri_query_local_storage(request, self.use_local_storage)
     request.headers = _update_storage_blob_header(request, self.account_name, self.account_key)
     response = self._perform_request(request)
Ejemplo n.º 22
0
 def put_page(self, container_name, blob_name, page, x_ms_range, x_ms_page_write, timeout=None, content_m_d5=None, x_ms_lease_id=None, x_ms_if_sequence_number_lte=None, x_ms_if_sequence_number_lt=None, x_ms_if_sequence_number_eq=None, if_modified_since=None, if_unmodified_since=None, if_match=None, if_none_match=None):
     '''
     Writes a range of pages to a page blob.
     
     container_name: the name of container.
     blob_name: the name of blob
     timeout: the timeout parameter is expressed in seconds.
     x_ms_range: Required. Specifies the range of bytes to be written as a page. Both the start
     		and end of the range must be specified. Must be in format: bytes=startByte-endByte.
     		Given that pages must be aligned with 512-byte boundaries, the start offset must be
     		a modulus of 512 and the end offset must be a modulus of 512-1. Examples of valid
     		byte ranges are 0-511, 512-1023, etc.
     x_ms_page_write: Required. You may specify one of the following options : 
     		1. update(lower case): Writes the bytes specified by the request body into the specified 
     		   range. The Range and Content-Length headers must match to perform the update.
     		2. clear(lower case): Clears the specified range and releases the space used in storage  
     		   for that range. To clear a range, set the Content-Length header to zero, and the Range
     		   header to a value that indicates the range to clear, up to maximum blob size.
     x_ms_lease_id: Required if the blob has an active lease. To perform this operation on a blob
     		 with an active lease, specify the valid lease ID for this header.
     '''
     _validate_not_none('container_name', container_name)
     _validate_not_none('blob_name', blob_name)
     _validate_not_none('page', page)
     _validate_not_none('x_ms_range', x_ms_range)
     _validate_not_none('x_ms_page_write', x_ms_page_write)
     request = HTTPRequest()
     request.method = 'PUT'
     request.host = _get_blob_host(self.account_name, self.use_local_storage)
     request.path = '/' + str(container_name) + '/' + str(blob_name) + '?comp=page'
     request.headers = [
         ('x-ms-range', _str_or_none(x_ms_range)),
         ('Content-MD5', _str_or_none(content_m_d5)),
         ('x-ms-page-write', _str_or_none(x_ms_page_write)),
         ('x-ms-lease-id', _str_or_none(x_ms_lease_id)),
         ('x-ms-if-sequence-number-lte', _str_or_none(x_ms_if_sequence_number_lte)),
         ('x-ms-if-sequence-number-lt', _str_or_none(x_ms_if_sequence_number_lt)),
         ('x-ms-if-sequence-number-eq', _str_or_none(x_ms_if_sequence_number_eq)),
         ('If-Modified-Since', _str_or_none(if_modified_since)),
         ('If-Unmodified-Since', _str_or_none(if_unmodified_since)),
         ('If-Match', _str_or_none(if_match)),
         ('If-None-Match', _str_or_none(if_none_match))
         ]
     request.query = [('timeout', _int_or_none(timeout))]
     request.body = _get_request_body(page)
     request.path, request.query = _update_request_uri_query_local_storage(request, self.use_local_storage)
     request.headers = _update_storage_blob_header(request, self.account_name, self.account_key)
     response = self._perform_request(request)
    def get_queue_service_properties(self, timeout=None):
        '''
        Gets the properties of a storage account's Queue Service, including 
        Windows Azure Storage Analytics.
        
        timeout: Optional. The timeout parameter is expressed in seconds.
        '''
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self._get_host()
        request.path = '/?restype=service&comp=properties'
        request.query = [('timeout', _int_or_none(timeout))]
        request.path, request.query = _update_request_uri_query_local_storage(request, self.use_local_storage)
        request.headers = _update_storage_queue_header(request, self.account_name, self.account_key)
        response = self._perform_request(request)

        return _parse_response(response, StorageServiceProperties)
    def get_queue_service_properties(self, timeout=None):
        """
        Gets the properties of a storage account's Queue Service, including Windows Azure 
        Storage Analytics.
        
        timeout: Optional. The timeout parameter is expressed in seconds. For example, the 
        following value sets a timeout of 30 seconds for the request: timeout=30
        """
        request = HTTPRequest()
        request.method = "GET"
        request.host = self._get_host()
        request.path = "/?restype=service&comp=properties"
        request.query = [("timeout", _int_or_none(timeout))]
        request.path, request.query = _update_request_uri_query_local_storage(request, self.use_local_storage)
        request.headers = _update_storage_queue_header(request, self.account_name, self.account_key)
        response = self._perform_request(request)

        return _parse_response(response, StorageServiceProperties)
 def set_queue_service_properties(self, storage_service_properties, timeout=None):
     """
     Sets the properties of a storage account's Queue service, including Windows Azure 
     Storage Analytics.
     
     storage_service_properties: a StorageServiceProperties object.
     timeout: Optional. The timeout parameter is expressed in seconds.
     """
     _validate_not_none("storage_service_properties", storage_service_properties)
     request = HTTPRequest()
     request.method = "PUT"
     request.host = self._get_host()
     request.path = "/?restype=service&comp=properties"
     request.query = [("timeout", _int_or_none(timeout))]
     request.body = _get_request_body(_convert_class_to_xml(storage_service_properties))
     request.path, request.query = _update_request_uri_query_local_storage(request, self.use_local_storage)
     request.headers = _update_storage_queue_header(request, self.account_name, self.account_key)
     response = self._perform_request(request)
Ejemplo n.º 26
0
    def get_blob_service_properties(self, timeout=None):
        '''
        Gets the properties of a storage account's Blob service, including Windows Azure 
        Storage Analytics.
        
        timeout: Optional. The timeout parameter is expressed in seconds. For example, the 
        		following value sets a timeout of 30 seconds for the request: timeout=30.
        '''
        request = HTTPRequest()
        request.method = 'GET'
        request.host = _get_blob_host(self.account_name, self.use_local_storage)
        request.path = '/?restype=service&comp=properties'
        request.query = [('timeout', _int_or_none(timeout))]
        request.path, request.query = _update_request_uri_query_local_storage(request, self.use_local_storage)
        request.headers = _update_storage_blob_header(request, self.account_name, self.account_key)
        response = self._perform_request(request)

        return _parse_response(response, StorageServiceProperties)
Ejemplo n.º 27
0
    def query_entities(self,
                       table_name,
                       filter=None,
                       select=None,
                       top=None,
                       next_partition_key=None,
                       next_row_key=None):
        '''
        Get entities in a table; includes the $filter and $select options.

        table_name:
            Table to query.
        filter:
            Optional. Filter as described at
            http://msdn.microsoft.com/en-us/library/windowsazure/dd894031.aspx
        select:
            Optional. Property names to select from the entities.
        top:
            Optional. Maximum number of entities to return.
        next_partition_key:
            Optional. When top is used, the next partition key is stored in
            result.x_ms_continuation['NextPartitionKey']
        next_row_key:
            Optional. When top is used, the next partition key is stored in
            result.x_ms_continuation['NextRowKey']
        '''
        _validate_not_none('table_name', table_name)
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self._get_host()
        request.path = '/' + _str(table_name) + '()'
        request.query = [('$filter', _str_or_none(filter)),
                         ('$select', _str_or_none(select)),
                         ('$top', _int_or_none(top)),
                         ('NextPartitionKey',
                          _str_or_none(next_partition_key)),
                         ('NextRowKey', _str_or_none(next_row_key))]
        request.path, request.query = _update_request_uri_query_local_storage(
            request, self.use_local_storage)
        request.headers = _update_storage_table_header(request)
        response = self._perform_request(request)

        return _ETreeXmlToObject.convert_response_to_feeds(
            response, _convert_etree_element_to_entity)
Ejemplo n.º 28
0
    def list_queues(self, prefix=None, marker=None, maxresults=None, include=None):
        '''
        Lists all of the queues in a given storage account.
        '''
        request = HTTPRequest()
        request.method = 'GET'
        request.host = _get_queue_host(self.account_name, self.use_local_storage)
        request.path = '/?comp=list'
        request.query = [
            ('prefix', _str_or_none(prefix)),
            ('marker', _str_or_none(marker)),
            ('maxresults', _int_or_none(maxresults)),
            ('include', _str_or_none(include))
            ]
        request.path, request.query = _update_request_uri_query_local_storage(request, self.use_local_storage)
        request.headers = _update_storage_queue_header(request, self.account_name, self.account_key)
        response = self._perform_request(request)

        return _parse_enum_results_list(response, QueueEnumResults, "Queues", Queue)
    def list_queues(self, prefix=None, marker=None, maxresults=None, include=None):
        """
        Lists all of the queues in a given storage account.
        """
        request = HTTPRequest()
        request.method = "GET"
        request.host = self._get_host()
        request.path = "/?comp=list"
        request.query = [
            ("prefix", _str_or_none(prefix)),
            ("marker", _str_or_none(marker)),
            ("maxresults", _int_or_none(maxresults)),
            ("include", _str_or_none(include)),
        ]
        request.path, request.query = _update_request_uri_query_local_storage(request, self.use_local_storage)
        request.headers = _update_storage_queue_header(request, self.account_name, self.account_key)
        response = self._perform_request(request)

        return _parse_enum_results_list(response, QueueEnumResults, "Queues", Queue)
Ejemplo n.º 30
0
    def list_queues(self,
                    prefix=None,
                    marker=None,
                    maxresults=None,
                    include=None):
        '''
        Lists all of the queues in a given storage account.

        prefix:
            Filters the results to return only queues with names that begin 
            with the specified prefix.
        marker:
            A string value that identifies the portion of the list to be 
            returned with the next list operation. The operation returns a 
            NextMarker element within the response body if the list returned 
            was not complete. This value may then be used as a query parameter 
            in a subsequent call to request the next portion of the list of 
            queues. The marker value is opaque to the client.
        maxresults:
            Specifies the maximum number of queues to return. If maxresults is 
            not specified, the server will return up to 5,000 items.
        include: 
            Optional. Include this parameter to specify that the container's 
            metadata be returned as part of the response body. 
        '''
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self._get_host()
        request.path = '/?comp=list'
        request.query = [('prefix', _str_or_none(prefix)),
                         ('marker', _str_or_none(marker)),
                         ('maxresults', _int_or_none(maxresults)),
                         ('include', _str_or_none(include))]
        request.path, request.query = _update_request_uri_query_local_storage(
            request, self.use_local_storage)
        request.headers = _update_storage_queue_header(request,
                                                       self.account_name,
                                                       self.account_key)
        response = self._perform_request(request)

        return _parse_enum_results_list(response, QueueEnumResults, "Queues",
                                        Queue)
    def read_delete_queue_message(self, queue_name, timeout='60'):
        '''
        Reads and deletes a message from a queue as an atomic operation. This operation 
        should be used when a best-effort guarantee is sufficient for an application; 
        that is, using this operation it is possible for messages to be lost if 
        processing fails.
        
        queue_name: name of the queue
        '''
        _validate_not_none('queue_name', queue_name)
        request = HTTPRequest()
        request.method = 'DELETE'
        request.host = self.service_namespace + SERVICE_BUS_HOST_BASE
        request.path = '/' + str(queue_name) + '/messages/head'
        request.query = [('timeout', _int_or_none(timeout))]
        request.path, request.query = _update_request_uri_query(request)
        request.headers = _update_service_bus_header(request, self.account_key, self.issuer)
        response = self._perform_request(request)

        return _create_message(response, self)
Ejemplo n.º 32
0
    def read_delete_queue_message(self, queue_name, timeout='60'):
        '''
        Reads and deletes a message from a queue as an atomic operation. This operation 
        should be used when a best-effort guarantee is sufficient for an application; 
        that is, using this operation it is possible for messages to be lost if 
        processing fails.
        
        queue_name: name of the queue
        '''
        _validate_not_none('queue_name', queue_name)
        request = HTTPRequest()
        request.method = 'DELETE'
        request.host = self._get_host()
        request.path = '/' + str(queue_name) + '/messages/head'
        request.query = [('timeout', _int_or_none(timeout))]
        request.path, request.query = _update_request_uri_query(request)
        request.headers = _update_service_bus_header(request, self.account_key, self.issuer)
        response = self._perform_request(request)

        return _create_message(response, self)
Ejemplo n.º 33
0
    def list_blobs(self, container_name, prefix=None, marker=None, maxresults=None, include=None):
        '''
        Returns the list of blobs under the specified container.
        '''
        _validate_not_none('container_name', container_name)
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self._get_host()
        request.path = '/' + _str(container_name) + '?restype=container&comp=list'
        request.query = [
            ('prefix', _str_or_none(prefix)),
            ('marker', _str_or_none(marker)),
            ('maxresults', _int_or_none(maxresults)),
            ('include', _str_or_none(include))
            ]
        request.path, request.query = _update_request_uri_query_local_storage(request, self.use_local_storage)
        request.headers = _update_storage_blob_header(request, self.account_name, self.account_key)
        response = self._perform_request(request)

        return _parse_enum_results_list(response, BlobEnumResults, "Blobs", Blob)
Ejemplo n.º 34
0
 def set_blob_service_properties(self, storage_service_properties, timeout=None):
     '''
     Sets the properties of a storage account's Blob service, including Windows Azure 
     Storage Analytics. You can also use this operation to set the default request 
     version for all incoming requests that do not have a version specified.
     
     storage_service_properties: a StorageServiceProperties object.
     timeout: Optional. The timeout parameter is expressed in seconds. For example, the 
     		following value sets a timeout of 30 seconds for the request: timeout=30.
     '''
     _validate_not_none('storage_service_properties', storage_service_properties)
     request = HTTPRequest()
     request.method = 'PUT'
     request.host = self._get_host()
     request.path = '/?restype=service&comp=properties'
     request.query = [('timeout', _int_or_none(timeout))]
     request.body = _get_request_body(_convert_class_to_xml(storage_service_properties))
     request.path, request.query = _update_request_uri_query_local_storage(request, self.use_local_storage)
     request.headers = _update_storage_blob_header(request, self.account_name, self.account_key)
     response = self._perform_request(request)
Ejemplo n.º 35
0
    def get_queue_service_properties(self, timeout=None):
        '''
        Gets the properties of a storage account's Queue Service, including
        Windows Azure Storage Analytics.

        timeout:
            Optional. The timeout parameter is expressed in seconds.
        '''
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self._get_host()
        request.path = '/?restype=service&comp=properties'
        request.query = [('timeout', _int_or_none(timeout))]
        request.path, request.query = _update_request_uri_query_local_storage(
            request, self.use_local_storage)
        request.headers = _update_storage_queue_header(
            request, self.authentication)
        response = self._perform_request(request)

        return _ETreeXmlToObject.parse_response(
            response, StorageServiceProperties)
    def query_tables(self, table_name = None, top=None):
        '''
        Returns a list of tables under the specified account.
        
        table_name: optional, the specific table to query
        top: the maximum number of tables to return
        '''
        request = HTTPRequest()
        request.method = 'GET'
        request.host = _get_table_host(self.account_name, self.use_local_storage)
        if table_name is not None:
            uri_part_table_name = "('" + table_name + "')"
        else:
            uri_part_table_name = ""
        request.path = '/Tables' + uri_part_table_name + ''
        request.query = [('$top', _int_or_none(top))]
        request.path, request.query = _update_request_uri_query_local_storage(request, self.use_local_storage)
        request.headers = _update_storage_table_header(request)
        response = self._perform_request(request)

        return _convert_response_to_feeds(response, _convert_xml_to_table)
Ejemplo n.º 37
0
    def list_queues(self, prefix=None, marker=None, maxresults=None,
                    include=None):
        '''
        Lists all of the queues in a given storage account.

        prefix:
            Filters the results to return only queues with names that begin
            with the specified prefix.
        marker:
            A string value that identifies the portion of the list to be
            returned with the next list operation. The operation returns a
            NextMarker element within the response body if the list returned
            was not complete. This value may then be used as a query parameter
            in a subsequent call to request the next portion of the list of
            queues. The marker value is opaque to the client.
        maxresults:
            Specifies the maximum number of queues to return. If maxresults is
            not specified, the server will return up to 5,000 items.
        include:
            Optional. Include this parameter to specify that the container's
            metadata be returned as part of the response body.
        '''
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self._get_host()
        request.path = '/?comp=list'
        request.query = [
            ('prefix', _str_or_none(prefix)),
            ('marker', _str_or_none(marker)),
            ('maxresults', _int_or_none(maxresults)),
            ('include', _str_or_none(include))
        ]
        request.path, request.query = _update_request_uri_query_local_storage(
            request, self.use_local_storage)
        request.headers = _update_storage_queue_header(
            request, self.authentication)
        response = self._perform_request(request)

        return _ETreeXmlToObject.parse_enum_results_list(
            response, QueueEnumResults, "Queues", Queue)
    def read_delete_subscription_message(self, topic_name, subscription_name, timeout='60'):
        '''
        Read and delete a message from a subscription as an atomic operation. This 
        operation should be used when a best-effort guarantee is sufficient for an 
        application; that is, using this operation it is possible for messages to 
        be lost if processing fails.
        
        topic_name: the name of the topic
        subscription_name: the name of the subscription
        '''
        _validate_not_none('topic_name', topic_name)
        _validate_not_none('subscription_name', subscription_name)
        request = HTTPRequest()
        request.method = 'DELETE'
        request.host = self.service_namespace + SERVICE_BUS_HOST_BASE
        request.path = '/' + str(topic_name) + '/subscriptions/' + str(subscription_name) + '/messages/head'
        request.query = [('timeout', _int_or_none(timeout))]
        request.path, request.query = _update_request_uri_query(request)
        request.headers = _update_service_bus_header(request, self.account_key, self.issuer)
        response = self._perform_request(request)

        return _create_message(response, self)
Ejemplo n.º 39
0
    def query_tables(self, table_name=None, top=None, next_table_name=None):
        '''
        Returns a list of tables under the specified account.
        
        table_name: optional, the specific table to query
        top: the maximum number of tables to return
        '''
        request = HTTPRequest()
        request.method = 'GET'
        request.host = self._get_host()
        if table_name is not None:
            uri_part_table_name = "('" + table_name + "')"
        else:
            uri_part_table_name = ""
        request.path = '/Tables' + uri_part_table_name + ''
        request.query = [('$top', _int_or_none(top)),
                         ('NextTableName', _str_or_none(next_table_name))]
        request.path, request.query = _update_request_uri_query_local_storage(
            request, self.use_local_storage)
        request.headers = _update_storage_table_header(request)
        response = self._perform_request(request)

        return _convert_response_to_feeds(response, _convert_xml_to_table)