Exemple #1
0
            ET.SubElement(rrset, '{%s}TTL' % self.xmlns).text = str(ttl)
            records = ET.SubElement(rrset, '{%s}ResourceRecords' % self.xmlns)
            for value in values:
                ET.SubElement(
                    ET.SubElement(records, '{%s}ResourceRecord' % self.xmlns),
                    '{%s}Value' % self.xmlns).text = value

        body = self._tostring(root)
        print body

        return self.req(self._endpoint, self.version,
                        'hostedzone/' + ZoneId.split('/')[-1] + '/rrset',
                        self._key, self._secret, {}, response, None, 'POST',
                        self._tostring(root))

    def GetChange(self, changeId):
        pass

if __name__ == '__main__':
    import proxy
    key, secret = getBotoCredentials()
    dns = proxy.ServiceProxy(Route53('us-west-1', key, secret))
    zones = dns.ListHostedZones()
    print zones.keys()
    zone = zones['snitch.co.nz.']['Id']
    print zone
    for record in dns.ListResourceRecordSets(zone):
        print repr(record)
#       print dns.ChangeResourceRecord(zone, Create=[('smith.snitch.co.nz', 'A', 86400, ('209.160.32.205',))])
#       print dns.CreateHostedZone('snitch.co.nz.')
Exemple #2
0
            }, response)

    def ListAction(self, Elements):
        """listAction tests that lists pass correctly through the system

                Returns -- True if HTTP request succeeds
                """
        def response(status, reason, data):
            if status == 200:
                return True
            raise AWSError(status, reason, data)

        r = request.AWSRequest(self._endpoint, '/', self._key, self._secret,
                               'ListAction', {
                                   'Version': self.version,
                               }, response)
        for idx, e in enumerate(Elements):
            r.addParm('Element.%d' % idx, e)
        return r


if __name__ == '__main__':
    from proxy import ServiceProxy
    k, s = getBotoCredentials()
    es = ServiceProxy(ExampleService('localhost', k, s))
    es.ExampleAction('Mr', 'Joe', 'Bloggs')
    es.ExampleAction('Mrs', 'Madonna')
    es.ListAction(['one', 'two', 'three'])
    es.ListAction([])
    es.ExampleAction('Bad', None)
Exemple #3
0
    def GetObject(self, BucketName, Key, PutData, Progress=None):
        def response(status, reason, data):
            if status == 200:
#                               print data
                return True
            raise AWSError(status, reason, data)

        return S3Request(BucketName + '.' + self._endpoint, '/' + Key, self._key, self._secret, BucketName, {}, response, verb='GET', body=PutData, progresscb=Progress)


if __name__ == '__main__':
    import proxy
    import sys

    key, secret = getBotoCredentials()
    s3 = S3('us-west-1', key, secret)
    buckets = s3.ListBuckets().execute(retries=0)
    print buckets
    if True:
        objects, info = s3.ListObjects(sys.argv[1], delimiter='/').execute(retries=0)
        for key, obj in objects.items():
            if obj:
                print key, obj['Size']
            else:
                print key

    # Upload a file
    def cb(sent, outof):
        print 'Sent %d bytes out of %d' % (sent, outof)
    print s3.PutObject(sys.argv[1], 'cloudwatch.py', file('cloudwatch.py', 'rb'), 'text/plain', Progress=cb).execute(retries=0)
Exemple #4
0
        digest = base64.b64encode(h.digest())
        #		print 'base64 digest %r (%s)' % (digest, h.hexdigest())
        parms.append('Signature=' + urllib.quote(digest, safe='-_~'))
        return urllib.quote(self._uri) + '?' + '&'.join(parms)

    def makeHeaders(self, verb='GET'):
        pass

    def makeBody(self):
        return ''

    def getContentLength(self):
        return len(self.makeBody())

if __name__ == '__main__':
    key, secret = aws.getBotoCredentials()

    if False:
        r = AWSRequest('sqs.us-west-1.amazonaws.com', '/', key, secret)
        print r.makeURL(
            'ListQueues',
            {
                #			'MessageBody': 'Your Message Text',
                'Version': '2009-02-01',
                #			'Expires': '2008-02-10T12:00:00Z',
            })
    r = AWSRequest('us-west-1.queue.amazonaws.com', '/', key, secret,
                   'CreateQueue', {
                       'Version': '2009-02-01',
                       'QueueName': 'pointstore',
                   })
Exemple #5
0
	def ListAction(self, Elements):
		"""listAction tests that lists pass correctly through the system

			Returns -- True if HTTP request succeeds
			"""

		def response(status, reason, data):
			if status == 200:
				return True
			raise AWSError(status, reason, data)

		r = request.AWSRequest(self._endpoint, '/', self._key, self._secret, 'ListAction', {
				'Version': self.version,
			}, response)
		for idx, e in enumerate(Elements):
			r.addParm('Element.%d' % idx, e)
		return r


if __name__ == '__main__':
	from proxy import ServiceProxy
	k, s = getBotoCredentials()
	es = ServiceProxy(ExampleService('localhost', k, s))
	es.ExampleAction('Mr', 'Joe', 'Bloggs')
	es.ExampleAction('Mrs', 'Madonna')
	es.ListAction(['one', 'two', 'three'])
	es.ListAction([])
	es.ExampleAction('Bad', None)

Exemple #6
0
			parms = variabledecode.variable_decode(parms, dict_char='-', list_char='.')
			try:
				parms = obj.schema.to_python(parms)
				return obj.invoke(**parms)
			except Invalid, e:
				return self.error(400)
			except:
				_, t, v, tbinfo = request.compact_traceback()
				self._errorHandler(t, v, tbinfo)
				return self.error(500)
		else:
			return self.error(404)


if __name__ == '__main__':
	key, secret = aws.getBotoCredentials()

	class ExampleAction(object):
		versions = ['2011-06-30']

		class schema(Schema):
			Title = validators.String()
			FirstName = validators.String()
			Surname = validators.String(if_missing=None)

		def invoke(self, Title, FirstName, Surname):
			print "Hello %s %s %s" % (Title, FirstName, Surname)
			return ((200, 'OK'), '')

	class ListAction(object):
		versions = ['2011-06-30']