コード例 #1
0
ファイル: __init__.py プロジェクト: delaballe/fcu-boto
 def _delete_object(self, id, etag, resource):
     uri = '/%s/%s/%s' % (self.Version, resource, id)
     response = self.make_request('DELETE', uri, {'If-Match': etag})
     body = response.read()
     fcu_boto.log.debug(body)
     if response.status != 204:
         raise CloudFrontServerError(response.status, response.reason, body)
コード例 #2
0
ファイル: __init__.py プロジェクト: delaballe/fcu-boto
 def _get_config(self, id, resource, config_class):
     uri = '/%s/%s/%s/config' % (self.Version, resource, id)
     response = self.make_request('GET', uri)
     body = response.read()
     fcu_boto.log.debug(body)
     if response.status >= 300:
         raise CloudFrontServerError(response.status, response.reason, body)
     d = config_class(connection=self)
     d.etag = self.get_etag(response)
     h = handler.XmlHandler(d, self)
     xml.sax.parseString(body, h)
     return d
コード例 #3
0
ファイル: __init__.py プロジェクト: delaballe/fcu-boto
 def _set_config(self, distribution_id, etag, config):
     if isinstance(config, StreamingDistributionConfig):
         resource = 'streaming-distribution'
     else:
         resource = 'distribution'
     uri = '/%s/%s/%s/config' % (self.Version, resource, distribution_id)
     headers = {'If-Match': etag, 'Content-Type': 'text/xml'}
     response = self.make_request('PUT', uri, headers, config.to_xml())
     body = response.read()
     fcu_boto.log.debug(body)
     if response.status != 200:
         raise CloudFrontServerError(response.status, response.reason, body)
     return self.get_etag(response)
コード例 #4
0
ファイル: __init__.py プロジェクト: delaballe/fcu-boto
 def invalidation_request_status(self,
                                 distribution_id,
                                 request_id,
                                 caller_reference=None):
     uri = '/%s/distribution/%s/invalidation/%s' % (
         self.Version, distribution_id, request_id)
     response = self.make_request('GET', uri, {'Content-Type': 'text/xml'})
     body = response.read()
     if response.status == 200:
         paths = InvalidationBatch([])
         h = handler.XmlHandler(paths, self)
         xml.sax.parseString(body, h)
         return paths
     else:
         raise CloudFrontServerError(response.status, response.reason, body)
コード例 #5
0
ファイル: __init__.py プロジェクト: delaballe/fcu-boto
 def _create_object(self, config, resource, dist_class):
     response = self.make_request('POST',
                                  '/%s/%s' % (self.Version, resource),
                                  {'Content-Type': 'text/xml'},
                                  data=config.to_xml())
     body = response.read()
     fcu_boto.log.debug(body)
     if response.status == 201:
         d = dist_class(connection=self)
         h = handler.XmlHandler(d, self)
         xml.sax.parseString(body, h)
         d.etag = self.get_etag(response)
         return d
     else:
         raise CloudFrontServerError(response.status, response.reason, body)
コード例 #6
0
ファイル: __init__.py プロジェクト: delaballe/fcu-boto
 def _get_info(self, id, resource, dist_class):
     uri = '/%s/%s/%s' % (self.Version, resource, id)
     response = self.make_request('GET', uri)
     body = response.read()
     fcu_boto.log.debug(body)
     if response.status >= 300:
         raise CloudFrontServerError(response.status, response.reason, body)
     d = dist_class(connection=self)
     response_headers = response.msg
     for key in response_headers.keys():
         if key.lower() == 'etag':
             d.etag = response_headers[key]
     h = handler.XmlHandler(d, self)
     xml.sax.parseString(body, h)
     return d
コード例 #7
0
ファイル: __init__.py プロジェクト: delaballe/fcu-boto
 def _get_all_objects(self,
                      resource,
                      tags,
                      result_set_class=None,
                      result_set_kwargs=None):
     if not tags:
         tags = [('DistributionSummary', DistributionSummary)]
     response = self.make_request('GET',
                                  '/%s/%s' % (self.Version, resource))
     body = response.read()
     fcu_boto.log.debug(body)
     if response.status >= 300:
         raise CloudFrontServerError(response.status, response.reason, body)
     rs_class = result_set_class or ResultSet
     rs_kwargs = result_set_kwargs or dict()
     rs = rs_class(tags, **rs_kwargs)
     h = handler.XmlHandler(rs, self)
     xml.sax.parseString(body, h)
     return rs
コード例 #8
0
ファイル: __init__.py プロジェクト: delaballe/fcu-boto
 def create_invalidation_request(self,
                                 distribution_id,
                                 paths,
                                 caller_reference=None):
     """Creates a new invalidation request
         :see: http://goo.gl/8vECq
     """
     # We allow you to pass in either an array or
     # an InvalidationBatch object
     if not isinstance(paths, InvalidationBatch):
         paths = InvalidationBatch(paths)
     paths.connection = self
     uri = '/%s/distribution/%s/invalidation' % (self.Version,
                                                 distribution_id)
     response = self.make_request('POST',
                                  uri, {'Content-Type': 'text/xml'},
                                  data=paths.to_xml())
     body = response.read()
     if response.status == 201:
         h = handler.XmlHandler(paths, self)
         xml.sax.parseString(body, h)
         return paths
     else:
         raise CloudFrontServerError(response.status, response.reason, body)