예제 #1
0
    def put(self, path, data, metadata={}, reduced_redundancy=False, encrypt_key=False, callback=None):
        """
        Stores data at given path
        :param string path: Path or 'key' for created/updated object
        :param bytes data: Data to write
        :param dict metadata: Metadata to store with this data
        :param bool reduced_redundancy: Whether to reduce storage redundancy or not?
        :param bool encrypt_key: Encrypt data?
        :param callable callback: Called function once done
        """
        storage_class = 'REDUCED_REDUNDANCY' if reduced_redundancy else 'STANDARD'

        args = dict(
            callback=callback,
            Bucket=self._bucket,
            Key=self._clean_key(path),
            Body=data,
            Metadata=metadata,
            StorageClass=storage_class,
        )

        if encrypt_key:
            args['ServerSideEncryption'] = 'AES256'

        my_session = session_handler.get_session(self._endpoint is not None)
        session = Botocore(service='s3', region_name=self._region,
                           operation='PutObject', session=my_session,
                           endpoint_url=self._endpoint)

        session.call(**args)
예제 #2
0
파일: bucket.py 프로젝트: aoqfonseca/aws
    def put(self, path, data, metadata={}, reduced_redundancy=False, encrypt_key=False, callback=None):
        """
        Stores data at given path
        :param string path: Path or 'key' for created/updated object
        :param bytes data: Data to write
        :param dict metadata: Metadata to store with this data
        :param bool reduced_redundancy: Whether to reduce storage redundancy or not?
        :param bool encrypt_key: Encrypt data?
        :param callable callback: Called function once done
        """
        storage_class = 'REDUCED_REDUNDANCY' if reduced_redundancy else 'STANDARD'

        args = dict(
            callback=callback,
            Bucket=self._bucket,
            Key=self._clean_key(path),
            Body=data,
            Metadata=metadata,
            StorageClass=storage_class,
        )

        if encrypt_key:
            args['ServerSideEncryption'] = 'AES256'

        my_session = session_handler.get_session(self._endpoint is not None)
        session = Botocore(service='s3', region_name=self._region,
                           operation='PutObject', session=my_session,
                           endpoint_url=self._endpoint)

        session.call(**args)
예제 #3
0
파일: sqs.py 프로젝트: homm/boto_addins
 def _get_method(self, name):
     method = self._methods.get(name)
     if method is None:
         method = Botocore('sqs', name,
                           region_name=self.region, session=self.session)
         method.http_client = self.http_client
         self._methods[name] = method
     return method.call
예제 #4
0
파일: bucket.py 프로젝트: abaldwin1/tc_aws
 def delete(self, path, callback=None):
     """
     Deletes key at given path
     :param string path: Path or 'key' to delete
     :param callable callback: Called function once done
     """
     my_session = session_handler.get_session()
     session = Botocore(service="s3", region_name=self._region, operation="DeleteObject", session=my_session)
     session.call(callback=callback, Bucket=self._bucket, Key=self._clean_key(path))
예제 #5
0
파일: bucket.py 프로젝트: abaldwin1/tc_aws
 def get(self, path, callback=None):
     """
     Returns object at given path
     :param string path: Path or 'key' to retrieve AWS object
     :param callable callback: Callback function for once the retrieval is done
     """
     my_session = session_handler.get_session()
     session = Botocore(service="s3", region_name=self._region, operation="GetObject", session=my_session)
     session.call(callback=callback, Bucket=self._bucket, Key=self._clean_key(path))
예제 #6
0
 def _get_method(self, name):
     method = self._methods.get(name)
     if method is None:
         method = Botocore('sqs',
                           name,
                           region_name=self.region,
                           session=self.session)
         method.http_client = self.http_client
         self._methods[name] = method
     return method.call
예제 #7
0
 def delete(self, path, callback=None):
     """
     Deletes key at given path
     :param string path: Path or 'key' to delete
     :param callable callback: Called function once done
     """
     my_session = session_handler.get_session(self._endpoint is not None)
     session = Botocore(service='s3', region_name=self._region,
                        operation='DeleteObject', session=my_session,
                        endpoint_url=self._endpoint)
     session.call(
         callback=callback,
         Bucket=self._bucket,
         Key=self._clean_key(path),
     )
예제 #8
0
 def get(self, path, callback=None):
     """
     Returns object at given path
     :param string path: Path or 'key' to retrieve AWS object
     :param callable callback: Callback function for once the retrieval is done
     """
     my_session = session_handler.get_session(self._endpoint is not None)
     session = Botocore(service='s3', region_name=self._region,
                        operation='GetObject', session=my_session,
                        endpoint_url=self._endpoint)
     session.call(
         callback=callback,
         Bucket=self._bucket,
         Key=self._clean_key(path),
     )
예제 #9
0
파일: bucket.py 프로젝트: aoqfonseca/aws
 def delete(self, path, callback=None):
     """
     Deletes key at given path
     :param string path: Path or 'key' to delete
     :param callable callback: Called function once done
     """
     my_session = session_handler.get_session(self._endpoint is not None)
     session = Botocore(service='s3', region_name=self._region,
                        operation='DeleteObject', session=my_session,
                        endpoint_url=self._endpoint)
     session.call(
         callback=callback,
         Bucket=self._bucket,
         Key=self._clean_key(path),
     )
예제 #10
0
	def setUp(self):
		super(SendSesEmailIncorrectTestCase, self).setUp()
		# initialize with the wrong region (no SES subscription)
		self.ses_handler.ses_client = Botocore(
			service='ses', operation='SendEmail', region_name='us-east-1'
		)
		# force ses.botocore client use the same io_loop as the test case,
		# otherwise nothing will be yielded in the test method
		self.ses_handler.ses_client.http_client = AsyncHTTPClient(io_loop = self.io_loop)
예제 #11
0
 def _create_dynamodb_task(self, task, region=None):
     return Botocore(
         service='dynamodb',
         operation=task,
         region_name=region or self.region_name,
         endpoint_url=self.endpoint_url,
         session=self.session,
         connect_timeout=self.connect_timeout,
         request_timeout=self.request_timeout
     )
예제 #12
0
 def dynamodb(self, operation):
     session = getattr(self, '_session', None)
     ddb = Botocore(
         service='dynamodb', operation=operation,
         session=session,
         region_name=options.amazon_region,
         endpoint_url=options.amazon_ddb_host)
     if options.amazon_access_key and options.amazon_secret_key:
         ddb.session.set_credentials(
             options.amazon_access_key,
             options.amazon_secret_key)
     self._session = ddb.session
     return ddb
예제 #13
0
    def __init__(self, main_logger=None):
        """Initalizes the logger for the object.
		Creates an async boto client to communicate with the aws service.
		API keys are derived from the environment (e.g. ~/.aws/credentials).

	    Args:
	    	main_logger: logger to which the logs should be sent, optional
	    """
        self.log = main_logger or logger.init_logger("ses")

        self.ses_client = Botocore(service='ses',
                                   operation='SendEmail',
                                   region_name='eu-west-1')
예제 #14
0
 def delete(self, path, callback=None):
     """
     Deletes key at given path
     :param string path: Path or 'key' to delete
     :param callable callback: Called function once done
     """
     session = Botocore(service='s3',
                        region_name=self._region,
                        operation='DeleteObject')
     session.call(
         callback=callback,
         Bucket=self._bucket,
         Key=path,
     )
예제 #15
0
 def get(self, path, callback=None):
     """
     Returns object at given path
     :param string path: Path or 'key' to retrieve AWS object
     :param callable callback: Callback function for once the retrieval is done
     """
     session = Botocore(service='s3',
                        region_name=self._region,
                        operation='GetObject')
     session.call(
         callback=callback,
         Bucket=self._bucket,
         Key=path,
     )
예제 #16
0
from tornado.ioloop import IOLoop
from tornado_botocore import Botocore


def on_response(response):
    http_response, response_data = response
    print response_data


if __name__ == '__main__':
    ec2 = Botocore(
        service='ec2', operation='DescribeInstances',
        region_name='us-east-1')
    ec2.call(callback=on_response)
    IOLoop.instance().start()
예제 #17
0
from __future__ import print_function

from tornado.ioloop import IOLoop
from tornado_botocore import Botocore

ioloop = IOLoop.instance()


def on_response(response):
    for reservation in response['Reservations']:
        for instance in reservation['Instances']:
            print(instance['InstanceId'])
    # i-279e5123
    # ...
    ioloop.stop()


if __name__ == '__main__':
    ec2 = Botocore(service='ec2',
                   operation='DescribeInstances',
                   region_name='us-east-1')
    ec2.call(callback=on_response)
    ioloop.start()
예제 #18
0
from update_and_delete import UpdateAndDelete
from delete import Delete

import logging

logging.getLogger(
    'botocore.vendored.requests.packages.urllib3.connectionpool'
).setLevel(logging.CRITICAL)

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)


session = botocore.session.get_session()
sqs_receive_message = Botocore(service='sqs',
                               operation='ReceiveMessage',
                               region_name='ap-northeast-1',
                               session=session)
sqs_delete_message_batch = Botocore(service='sqs',
                                    operation='DeleteMessageBatch',
                                    region_name='ap-northeast-1',
                                    session=session)
db_update_item = Botocore(service='dynamodb',
                          operation='UpdateItem',
                          region_name='ap-northeast-1',
                          session=session)


def handler(event, contest):
    logger.info("Start!")

    main_loop = IOLoop.instance()
예제 #19
0
import botocore

from poll import Poll

import logging

logging.getLogger(
    'botocore.vendored.requests.packages.urllib3.connectionpool').setLevel(
        logging.CRITICAL)

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)

session = botocore.session.get_session()
sqs_receive_message = Botocore(service='sqs',
                               operation='ReceiveMessage',
                               region_name='ap-northeast-1',
                               session=session)


def handler(event, contest):
    logger.info("Start!")

    main_loop = IOLoop.instance()

    poll = Poll(main_loop)

    queue_url = event['queueUrl']
    message_count = event['messageCount']

    poll.messages(sqs_receive_message, queue_url, message_count)
예제 #20
0
from tornado.ioloop import IOLoop
from tornado_botocore import Botocore


def on_response(response):
    print response
    # {u'Reservations': [], 'ResponseMetadata': {'RequestId': 'ad5d87c9-ec3c-4eab-86c4-851332d4c397'}}


if __name__ == '__main__':
    ec2 = Botocore(
        service='ec2', operation='DescribeInstances',
        region_name='us-east-1')
    # sync
    print ec2.call()
    # async
    ec2.call(callback=on_response)
    IOLoop.instance().start()