33this as a container that holds authentication related data.
44"""
55
6- # ************* Module stack **************
7- # Your code has been rated at 10.00/10
8-
96import enum
107import logging
118from urllib import parse
129from urllib3 .util import Retry
10+
11+ import contentstack
1312from contentstack .asset import Asset
1413from contentstack .assetquery import AssetQuery
1514from contentstack .contenttype import ContentType
1615from contentstack .https_connection import HTTPSConnection
1716from contentstack .image_transform import ImageTransform
1817
19-
2018__author__ = "ishaileshmishra (ishaileshmishra@gmail.com)"
2119__license__ = "MIT"
2220__version__ = '1.7.0'
@@ -35,14 +33,12 @@ class ContentstackRegion(enum.Enum):
3533
3634
3735class Stack :
38-
3936 """
4037 A stack can be defined as a pool of data or a container that holds all
4138 the content/assets related to a site. It is a collaboration space where multiple users can work
4239 together to create, edit, approve, and publish content.
4340 (API Reference)[https://www.contentstack.com/docs/developers/apis/content-delivery-api/#stack]:
4441 """
45- #from urllib3.util import Retry
4642
4743 def __init__ (self , api_key : str , delivery_token : str , environment : str ,
4844 host = DEFAULT_HOST ,
@@ -58,7 +54,7 @@ def __init__(self, api_key: str, delivery_token: str, environment: str,
5854 Class that wraps the credentials of the authenticated user. Think of
5955 this as a container that holds authentication related data.
6056
61- : param api_key: api_key of the stack
57+ param api_key: api_key of the stack
6258 :param delivery_token: delivery_token of the stack
6359 :param environment: environment of the stack
6460 :param host: (optional) host of the stack default is cdm.contentstack.io
@@ -78,14 +74,14 @@ def __init__(self, api_key: str, delivery_token: str, environment: str,
7874 'edit_tags_type': object | str,
7975 }
8076 ```
81- :param retry_strategy (optional) custom retry_strategy can be set.
82- # Method to create retry_strategy: create object of Retry() and provide the
83- # required parameters like below
77+ :param retry_strategy: (optional) custom retry_strategy can be set.
78+ Method to create retry_strategy: create object of Retry() and provide the
79+ required parameters like below
8480 **Example:**
8581
8682 >>> _strategy = Retry(total=5, backoff_factor=1, status_forcelist=[408, 429])
8783 >>> stack = contentstack.Stack("api_key", "delivery_token", "environment",
88- live_preview={enable=True, authorization='your auth token'}, retry_strategy= _strategy)
84+ live_preview={enable=True, authorization='your auth token'}, retry_strategy= _strategy)
8985 ```
9086 """
9187 if live_preview is None :
@@ -120,19 +116,17 @@ def _validate_stack(self):
120116 raise PermissionError (
121117 'You are not permitted to the stack without valid Environment' )
122118
123-
124119 if self .region .value == 'eu' and self .host == DEFAULT_HOST :
125120 self .host = 'eu-cdn.contentstack.com'
126121 elif self .region .value == 'azure-na' and self .host == DEFAULT_HOST :
127122 self .host = 'azure-na-cdn.contentstack.com'
128123 elif self .region .value != 'us' :
129- #self.host = '{}-{}'.format(self.region.value, DEFAULT_HOST)
130124 self .host = f'{ self .region .value } -{ DEFAULT_HOST } '
131125 self .endpoint = f'https://{ self .host } /{ self .version } '
132126
133127 self .headers = {
134128 'api_key' : self .api_key ,
135- 'access_token' :self .delivery_token ,
129+ 'access_token' : self .delivery_token ,
136130 'environment' : self .environment
137131 }
138132
@@ -156,7 +150,6 @@ def _validate_live_preview(self):
156150 if 'host' not in self .live_preview_dict :
157151 raise PermissionError ("host is required" )
158152 self .headers ['authorization' ] = self .live_preview_dict ['authorization' ]
159- # remove deliveryToken and environment
160153 self .host = self .live_preview_dict ['host' ]
161154 self .endpoint = f'https://{ self .host } /{ self .version } '
162155 self .headers .pop ('access_token' )
0 commit comments