@@ -64,27 +64,35 @@ def get_origins(self, unique_id, **kwargs):
6464
6565 return self .cdn_path .listOriginPath (unique_id , ** kwargs )
6666
67- def add_origin (self , unique_id , origin , path , origin_type = "server" , header = None ,
68- port = 80 , protocol = 'http' , bucket_name = None , file_extensions = None ,
69- optimize_for = "web" , cache_query = "include all" ):
67+ def add_origin (self , unique_id , origin , path , dynamic_path , origin_type = "server" , header = None ,
68+ http_port = 80 , https_port = None , protocol = 'http' , bucket_name = None , file_extensions = None ,
69+ optimize_for = "web" , compression = None , prefetching = None ,
70+ cache_query = "include all" ):
7071 """Creates an origin path for an existing CDN.
7172
7273 :param str unique_id: The unique ID associated with the CDN.
7374 :param str path: relative path to the domain provided, e.g. "/articles/video"
75+ :param str dynamic_path: The path that Akamai edge servers periodically fetch the test object from.
76+ example = /detection-test-object.html
7477 :param str origin: ip address or hostname if origin_type=server, API endpoint for
7578 your S3 object storage if origin_type=storage
7679 :param str origin_type: it can be 'server' or 'storage' types.
7780 :param str header: the edge server uses the host header to communicate with the origin.
7881 It defaults to hostname. (optional)
79- :param int port: the http port number (default: 80)
82+ :param int http_port: the http port number (default: 80)
83+ :param int https_port: the https port number
8084 :param str protocol: the protocol of the origin (default: HTTP)
8185 :param str bucket_name: name of the available resource
8286 :param str file_extensions: file extensions that can be stored in the CDN, e.g. "jpg,png"
8387 :param str optimize_for: performance configuration, available options: web, video, and file where:
8488
85- - 'web' = 'General web delivery'
86- - 'video' = 'Video on demand optimization'
87- - 'file' = 'Large file optimization'
89+ - 'web' = 'General web delivery'
90+ - 'video' = 'Video on demand optimization'
91+ - 'file' = 'Large file optimization'
92+ - 'dynamic' = 'Dynamic content acceleration'
93+ :param bool compression: Enable or disable compression of JPEG images for requests over
94+ certain network conditions.
95+ :param bool prefetching: Enable or disable the embedded object prefetching feature.
8896 :param str cache_query: rules with the following formats: 'include-all', 'ignore-all',
8997 'include: space separated query-names',
9098 'ignore: space separated query-names'.'
@@ -94,20 +102,29 @@ def add_origin(self, unique_id, origin, path, origin_type="server", header=None,
94102 performance_config = {
95103 'web' : 'General web delivery' ,
96104 'video' : 'Video on demand optimization' ,
97- 'file' : 'Large file optimization'
105+ 'file' : 'Large file optimization' ,
106+ "dynamic" : "Dynamic content acceleration"
98107 }
99108
100109 new_origin = {
101110 'uniqueId' : unique_id ,
102111 'path' : path ,
103112 'origin' : origin ,
104113 'originType' : types .get (origin_type ),
105- 'httpPort' : port ,
114+ 'httpPort' : http_port ,
115+ 'httpsPort' : https_port ,
106116 'protocol' : protocol .upper (),
107- 'performanceConfiguration' : performance_config .get (optimize_for , 'General web delivery' ),
108- 'cacheKeyQueryRule' : cache_query
117+ 'performanceConfiguration' : performance_config .get (optimize_for ),
118+ 'cacheKeyQueryRule' : cache_query ,
109119 }
110120
121+ if optimize_for == 'dynamic' :
122+ new_origin ['dynamicContentAcceleration' ] = {
123+ 'detectionPath' : "/" + str (dynamic_path ),
124+ 'prefetchEnabled' : bool (prefetching ),
125+ 'mobileImageCompressionEnabled' : bool (compression )
126+ }
127+
111128 if header :
112129 new_origin ['header' ] = header
113130
@@ -175,7 +192,7 @@ def end_date(self):
175192 return self ._end_date
176193
177194 def edit (self , identifier , header = None , http_port = None , https_port = None , origin = None ,
178- respect_headers = None , cache = None , performance_configuration = None ):
195+ respect_headers = None , cache = None , cache_description = None , performance_configuration = None ):
179196 """Edit the cdn object.
180197
181198 :param string identifier: The CDN identifier.
@@ -223,12 +240,12 @@ def edit(self, identifier, header=None, http_port=None, https_port=None, origin=
223240 if respect_headers :
224241 config ['respectHeaders' ] = respect_headers
225242
226- if cache :
243+ if cache or cache_description :
227244 if 'include-specified' in cache ['cacheKeyQueryRule' ]:
228- cache_key_rule = self .get_cache_key_query_rule ('include' , cache )
245+ cache_key_rule = self .get_cache_key_query_rule ('include' , cache_description )
229246 config ['cacheKeyQueryRule' ] = cache_key_rule
230247 elif 'ignore-specified' in cache ['cacheKeyQueryRule' ]:
231- cache_key_rule = self .get_cache_key_query_rule ('ignore' , cache )
248+ cache_key_rule = self .get_cache_key_query_rule ('ignore' , cache_description )
232249 config ['cacheKeyQueryRule' ] = cache_key_rule
233250 else :
234251 config ['cacheKeyQueryRule' ] = cache ['cacheKeyQueryRule' ]
@@ -254,18 +271,18 @@ def _get_ids_from_hostname(self, hostname):
254271 return result
255272
256273 @staticmethod
257- def get_cache_key_query_rule (cache_type , cache ):
274+ def get_cache_key_query_rule (cache_type , cache_description ):
258275 """Get the cdn object detail.
259276
260277 :param string cache_type: Cache type.
261278 :param cache: Cache description.
262279
263280 :return: string value.
264281 """
265- if 'description' not in cache :
282+ if cache_description is None :
266283 raise SoftLayer .SoftLayerError ('Please add a description to be able to update the'
267284 ' cache.' )
268- cache_result = '%s: %s' % (cache_type , cache [ 'description' ] )
285+ cache_result = '%s: %s' % (cache_type , cache_description )
269286
270287 return cache_result
271288
0 commit comments