This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Track(models.Model): | |
""" Track is a song that we've found | |
on MusixMatch based on the recipients' interests. | |
""" | |
card = models.ManyToManyField(Card) | |
track_mbid = models.CharField(max_length=50) | |
track_name = models.CharField(max_length=200) | |
album_coverart_100x100 = models.URLField(max_length=200) | |
artist_name = models.CharField(max_length=200) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ curl -X POST -H 'Content-Type: application/json' -u nate:nate | |
--data '{"recipient_name" : "Anna", | |
"track_set" : "", | |
"interests" : "hamburgers, skating"}' | |
http://localhost:8000/api/card/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CardResource(ModelResource): | |
... | |
def post_list(self, request, **kwargs): | |
deserialized = self.deserialize(request, request.raw_post_data, \ | |
format=request.META.get('CONTENT_TYPE', 'application/json')) | |
bundle = self.build_bundle(data=dict_strip_unicode_keys(deserialized)) | |
self.is_valid(bundle, request) | |
updated_bundle = self.obj_create(bundle, request=request, user=request.user) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> from boto.ec2.connection import EC2Connection | |
>>> conn = EC2Connection('<aws access key>', '<aws secret key>') | |
>>> conn = EC2Connection() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import boto | |
>>> conn = boto.connect_ec2() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> reservation = conn.run_instances(image_id='ami-ccf405a5') | |
>>> reservation.instances | |
[Instance:i-6761850e] | |
>>> instance = reservation.instances[0] | |
>>> instance.state | |
u'pending' | |
>>> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> instance.update() | |
>>> instance.state | |
u'pending' | |
>>> # wait a few minutes | |
>>> instance.update() | |
>>> instance.state | |
u'running' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> instance.public_dns_name | |
u'ec2-72-44-40-153.z-2.compute-1.amazonaws.com' | |
>>> instance.private_dns_name | |
u'domU-12-31-35-00-42-33.z-2.compute-1.internal' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> instance.stop() | |
>>> instance.update() | |
>>> instance.state | |
u'shutting-down' | |
>>> # wait a minute | |
>>> instance.update() | |
>>> instance.state | |
u'terminated' | |
>>> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> rs = conn.get_all_security_groups() | |
>>> print rs | |
[SecurityGroup:appserver, SecurityGroup:default, \ | |
SecurityGroup:vnc, SecurityGroup:webserver] | |
>>> sg = rs[1] | |
>>> sg.name | |
u'default' | |
>>> sg.rules | |
[IPPermissions:tcp(0-65535), | |
IPPermissions:udp(0-65535), |