Пример #1
0
class TestStructure(Structure):
    valid_api_versions = [
        '2013-09-24',
        '2013-07-31',
    ]

    name = HelloField('Name')
    slug = fields.BoundField('Slug', required=False)
    md5 = fields.BoundField('TestMD5')
    body = fields.BoundField('MessageBody')
    tags = fields.ListBoundField('Tags', TestTag)

    def prepare(self, data):
        if not data.get('slug'):
            slug = data['name'].lower()
            data['slug'] = slug
            # FIXME: This feels clumsy. :/
            self.fields['slug'].set_python(self, slug)

        return data

    def post_populate(self, data):
        if not 'MessageBody' in data:
            return data

        md5_seen = hashlib.md5(data['MessageBody'].encode('utf-8')).hexdigest()

        if md5_seen != self.md5:
            raise MD5ValidationError("Whoopsie!")

        return data
Пример #2
0
class Message(Structure):
    valid_api_versions = [
        '2012-11-05',
    ]
    possible_paths = [
        'Messages',
        'Message',
    ]

    body = fields.BoundField('Body')
    md5 = fields.BoundField('MD5OfBody', required=False)
    message_id = fields.BoundField('MessageId', required=False)
    receipt_handle = fields.BoundField('ReceiptHandle', required=False)
    attributes = fields.ListBoundField('Attribute', Attribute)

    def post_populate(self, data):
        # Verify the MD5 if present.
        if not self.md5:
            return

        body_md5 = md5(self.body).hexdigest()

        if body_md5 != self.md5:
            raise MD5ValidationError(
                "The provided MD5 does not match the body")
Пример #3
0
class Queue(Resource):
    service_name = 'sqs'
    # A special, required key identifying what API versions a given
    # ``Resource/Structure`` works correctly with.
    valid_api_versions = [
        '2012-11-05',
    ]

    # Instance variables
    name = fields.BoundField('queue_name')
    url = fields.BoundField('queue_url', required=False)

    # Instance methods
    delete = methods.InstanceMethod('delete_queue')
    get_url = methods.InstanceMethod('get_queue_url')
    send_message = methods.InstanceMethod('send_message')
    receive_message = methods.InstanceMethod('receive_message', limit=1)
    receive_messages = methods.InstanceMethod('receive_message')
    change_message_visibility = methods.InstanceMethod(
        'change_message_visibility')

    add_permission = methods.InstanceMethod('add_permission')
    remove_permission = methods.InstanceMethod('remove_permission')
    get_attributes = methods.InstanceMethod('get_queue_attributes')
    set_attributes = methods.InstanceMethod('set_queue_attributes')

    send_message_batch = methods.InstanceMethod('send_message_batch')
    delete_message_batch = methods.InstanceMethod('delete_message_batch')
    change_message_visibility_batch = methods.InstanceMethod(
        'change_message_visibility_batch')
Пример #4
0
class Attribute(Structure):
    valid_api_versions = [
        '2012-11-05',
    ]
    possible_paths = [
        'Attributes',
    ]

    name = fields.BoundField('Name')
    value = fields.BoundField('Value')
Пример #5
0
class TestResource(Resource):
    valid_api_versions = [
        '2013-08-23',
    ]
    service_name = 'test'
    structures_to_use = [
        TestMessage,
    ]

    name = fields.BoundField('QueueName')
    url = fields.BoundField('QueueUrl', required=False)

    receive = methods.InstanceMethod('receive_message')
    send = methods.InstanceMethod('send_message', message_type='json')
    delete = methods.InstanceMethod('delete_queue')
Пример #6
0
class TestMessage(Structure):
    valid_api_versions = [
        '2013-08-23',
    ]
    possible_paths = [
        'Messages',
    ]

    message_id = fields.BoundField('MessageId', required=False)
    body = fields.BoundField('Body')
    md5 = fields.BoundField('MD5OfBody', required=False)
    attributes = fields.ListBoundField('Attributes',
                                       data_class=None,
                                       required=False)
    receipt_handle = fields.BoundField('ReceiptHandle', required=False)
Пример #7
0
class Key(Resource):
    valid_api_versions = [
        '2006-03-01',
    ]

    name = fields.BoundField('KeyName')
Пример #8
0
class Bucket(Resource):
    valid_api_versions = [
        '2006-03-01',
    ]

    name = fields.BoundField('BucketName')
Пример #9
0
class Role(Resource):
    valid_api_versions = [
        '2010-05-08',
    ]

    name = fields.BoundField('RoleName')
Пример #10
0
class TestTag(Structure):
    valid_api_versions = [
        '2013-09-24',
    ]

    name = fields.BoundField('Name')
Пример #11
0
class Topic(Resource):
    valid_api_versions = [
        '2010-03-31',
    ]

    name = fields.BoundField('Name')
Пример #12
0
class Job(Resource):
    valid_api_versions = [
        '2012-09-25',
    ]

    name = fields.BoundField('JobName')
Пример #13
0
class Pipeline(Resource):
    valid_api_versions = [
        '2012-09-25',
    ]

    name = fields.BoundField('PipelineName')