Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(240)

Side by Side Diff: third_party/gsutil/boto/cloudfront/identity.py

Issue 12042069: Scripts to download files from google storage based on sha1 sums (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Removed gsutil/tests and gsutil/docs Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright (c) 2006-2009 Mitch Garnaat http://garnaat.org/
2 #
3 # Permission is hereby granted, free of charge, to any person obtaining a
4 # copy of this software and associated documentation files (the
5 # "Software"), to deal in the Software without restriction, including
6 # without limitation the rights to use, copy, modify, merge, publish, dis-
7 # tribute, sublicense, and/or sell copies of the Software, and to permit
8 # persons to whom the Software is furnished to do so, subject to the fol-
9 # lowing conditions:
10 #
11 # The above copyright notice and this permission notice shall be included
12 # in all copies or substantial portions of the Software.
13 #
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
16 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
17 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 # IN THE SOFTWARE.
21
22 import uuid
23
24 class OriginAccessIdentity:
25
26 def __init__(self, connection=None, config=None, id='',
27 s3_user_id='', comment=''):
28 self.connection = connection
29 self.config = config
30 self.id = id
31 self.s3_user_id = s3_user_id
32 self.comment = comment
33 self.etag = None
34
35 def startElement(self, name, attrs, connection):
36 if name == 'CloudFrontOriginAccessIdentityConfig':
37 self.config = OriginAccessIdentityConfig()
38 return self.config
39 else:
40 return None
41
42 def endElement(self, name, value, connection):
43 if name == 'Id':
44 self.id = value
45 elif name == 'S3CanonicalUserId':
46 self.s3_user_id = value
47 elif name == 'Comment':
48 self.comment = value
49 else:
50 setattr(self, name, value)
51
52 def update(self, comment=None):
53 new_config = OriginAccessIdentityConfig(self.connection,
54 self.config.caller_reference,
55 self.config.comment)
56 if comment != None:
57 new_config.comment = comment
58 self.etag = self.connection.set_origin_identity_config(self.id, self.eta g, new_config)
59 self.config = new_config
60
61 def delete(self):
62 return self.connection.delete_origin_access_identity(self.id, self.etag)
63
64 def uri(self):
65 return 'origin-access-identity/cloudfront/%s' % self.id
66
67 class OriginAccessIdentityConfig:
68
69 def __init__(self, connection=None, caller_reference='', comment=''):
70 self.connection = connection
71 if caller_reference:
72 self.caller_reference = caller_reference
73 else:
74 self.caller_reference = str(uuid.uuid4())
75 self.comment = comment
76
77 def to_xml(self):
78 s = '<?xml version="1.0" encoding="UTF-8"?>\n'
79 s += '<CloudFrontOriginAccessIdentityConfig xmlns="http://cloudfront.ama zonaws.com/doc/2009-09-09/">\n'
80 s += ' <CallerReference>%s</CallerReference>\n' % self.caller_reference
81 if self.comment:
82 s += ' <Comment>%s</Comment>\n' % self.comment
83 s += '</CloudFrontOriginAccessIdentityConfig>\n'
84 return s
85
86 def startElement(self, name, attrs, connection):
87 return None
88
89 def endElement(self, name, value, connection):
90 if name == 'Comment':
91 self.comment = value
92 elif name == 'CallerReference':
93 self.caller_reference = value
94 else:
95 setattr(self, name, value)
96
97 class OriginAccessIdentitySummary:
98
99 def __init__(self, connection=None, id='',
100 s3_user_id='', comment=''):
101 self.connection = connection
102 self.id = id
103 self.s3_user_id = s3_user_id
104 self.comment = comment
105 self.etag = None
106
107 def startElement(self, name, attrs, connection):
108 return None
109
110 def endElement(self, name, value, connection):
111 if name == 'Id':
112 self.id = value
113 elif name == 'S3CanonicalUserId':
114 self.s3_user_id = value
115 elif name == 'Comment':
116 self.comment = value
117 else:
118 setattr(self, name, value)
119
120 def get_origin_access_identity(self):
121 return self.connection.get_origin_access_identity_info(self.id)
122
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698