2424__version__ = '1.7.0'
2525
2626log = logging .getLogger (__name__ )
27+ default_host = 'cdn.contentstack.io'
2728
2829
2930class ContentstackRegion (enum .Enum ):
@@ -44,7 +45,6 @@ class Stack:
4445 together to create, edit, approve, and publish content.
4546 (API Reference)[https://www.contentstack.com/docs/developers/apis/content-delivery-api/#stack]:
4647 """
47- default_host = cdn .contentstack .io
4848
4949 def __init__ (self , api_key : str , delivery_token : str , environment : str ,
5050 host = default_host ,
@@ -82,7 +82,9 @@ def __init__(self, api_key: str, delivery_token: str, environment: str,
8282 :param retry_strategy (optional) custom retry_strategy can be set.
8383 # Method to create retry_strategy: create object of Retry() and provide the
8484 # required parameters like below
85+
8586 **Example:**
87+
8688 >>> _strategy = Retry(total=5, backoff_factor=1, status_forcelist=[408, 429])
8789 >>> stack = contentstack.Stack("api_key", "delivery_token", "environment",
8890 live_preview={enable=True, authorization='your auth token'}, retry_strategy= _strategy)
@@ -107,7 +109,6 @@ def __init__(self, api_key: str, delivery_token: str, environment: str,
107109 self .retry_strategy = retry_strategy
108110 self .live_preview_dict = live_preview
109111
110- # validate stack
111112 self ._validate_stack ()
112113
113114 def _validate_stack (self ):
@@ -121,7 +122,7 @@ def _validate_stack(self):
121122 raise PermissionError (
122123 'You are not permitted to the stack without valid Environment' )
123124
124- # prepare endpoint for the url:
125+
125126 if self .region .value == 'eu' and self .host == default_host :
126127 self .host = 'eu-cdn.contentstack.com'
127128 elif self .region .value == 'azure-na' and self .host == default_host :
@@ -130,12 +131,14 @@ def _validate_stack(self):
130131 self .host = '{}-{}' .format (self .region .value , default_host )
131132
132133 self .endpoint = 'https://{}/{}' .format (self .host , self .version )
133- # prepare Headers:`
134134
135135 self .headers = {
136- 'api_key' : self .api_key ,
137- 'access_token' : self .delivery_token ,
138- 'environment' : self .environment
136+ 'api_key' :
137+ self .api_key ,
138+ 'access_token' :
139+ self .delivery_token ,
140+ 'environment' :
141+ self .environment
139142 }
140143
141144 if self .branch is not None :
0 commit comments