contentstack-management 1.3.3__tar.gz → 1.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/PKG-INFO +28 -2
  2. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/README.md +26 -0
  3. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/__init__.py +9 -3
  4. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/auditlogs/auditlog.py +0 -2
  5. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/bulk_operations/bulk_operation.py +92 -0
  6. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/content_types/content_type.py +1 -1
  7. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/contentstack.py +0 -1
  8. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/delivery_token/delivery_token.py +0 -1
  9. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/entries/entry.py +51 -5
  10. contentstack_management-1.5.0/contentstack_management/entry_variants/__init__.py +3 -0
  11. contentstack_management-1.5.0/contentstack_management/entry_variants/entry_variants.py +272 -0
  12. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/environments/environment.py +0 -1
  13. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/extensions/extension.py +0 -1
  14. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/global_fields/global_fields.py +46 -8
  15. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/labels/label.py +0 -1
  16. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/locale/locale.py +0 -1
  17. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/management_token/management_token.py +0 -1
  18. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/metadata/metadata.py +0 -1
  19. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/publish_queue/publish_queue.py +0 -2
  20. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/release_items/release_item.py +43 -2
  21. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/releases/release.py +6 -4
  22. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/roles/roles.py +0 -1
  23. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/stack/stack.py +13 -8
  24. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/taxonomies/taxonomy.py +0 -1
  25. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/terms/terms.py +0 -1
  26. contentstack_management-1.5.0/contentstack_management/variant_group/variant_group.py +221 -0
  27. contentstack_management-1.5.0/contentstack_management/variants/__init__.py +3 -0
  28. contentstack_management-1.5.0/contentstack_management/variants/variants.py +256 -0
  29. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/webhooks/webhook.py +1 -2
  30. contentstack_management-1.5.0/contentstack_management/workflows/__init__.py +1 -0
  31. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/workflows/workflows.py +2 -3
  32. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management.egg-info/PKG-INFO +28 -2
  33. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management.egg-info/SOURCES.txt +6 -0
  34. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/setup.py +0 -1
  35. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/LICENSE +0 -0
  36. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/_api_client.py +0 -0
  37. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/_constant.py +0 -0
  38. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/_errors.py +0 -0
  39. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/aliases/__init__.py +0 -0
  40. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/aliases/aliases.py +0 -0
  41. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/assets/__init__.py +0 -0
  42. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/assets/assets.py +0 -0
  43. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/auditlogs/__init__.py +0 -0
  44. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/branches/__init__.py +0 -0
  45. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/branches/branches.py +0 -0
  46. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/bulk_operations/__init__.py +0 -0
  47. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/common.py +0 -0
  48. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/content_types/__init__.py +0 -0
  49. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/delivery_token/__init__.py +0 -0
  50. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/entries/__init__.py +0 -0
  51. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/environments/__init__.py +0 -0
  52. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/extensions/__init__.py +0 -0
  53. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/global_fields/__init__.py +0 -0
  54. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/labels/__init__.py +0 -0
  55. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/locale/__init__.py +0 -0
  56. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/management_token/__init__.py +0 -0
  57. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/metadata/__init__.py +0 -0
  58. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/organizations/__init__.py +0 -0
  59. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/organizations/organization.py +0 -0
  60. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/publish_queue/__init__.py +0 -0
  61. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/release_items/__init__.py +0 -0
  62. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/releases/__init__.py +0 -0
  63. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/roles/__init__.py +0 -0
  64. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/stack/__init__.py +0 -0
  65. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/taxonomies/__init__.py +0 -0
  66. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/terms/__init__.py +0 -0
  67. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/user_session/__init__.py +0 -0
  68. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/user_session/user_session.py +0 -0
  69. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/users/__init__.py +0 -0
  70. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management/users/user.py +0 -0
  71. {contentstack_management-1.3.3/contentstack_management/webhooks → contentstack_management-1.5.0/contentstack_management/variant_group}/__init__.py +0 -0
  72. {contentstack_management-1.3.3/contentstack_management/workflows → contentstack_management-1.5.0/contentstack_management/webhooks}/__init__.py +0 -0
  73. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management.egg-info/dependency_links.txt +0 -0
  74. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management.egg-info/requires.txt +0 -0
  75. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/contentstack_management.egg-info/top_level.txt +0 -0
  76. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/setup.cfg +0 -0
  77. {contentstack_management-1.3.3 → contentstack_management-1.5.0}/tests/test_contentstack.py +0 -0
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: contentstack-management
3
- Version: 1.3.3
3
+ Version: 1.5.0
4
4
  Summary: Contentstack API Client Library for Python
5
5
  Home-page: https://github.com/contentstack/contentstack-management-python
6
- Author: ishaileshmishra
6
+ Author: dev-ex
7
7
  Author-email: mobile@contentstack.com
8
8
  License: MIT
9
9
  Classifier: License :: OSI Approved :: MIT License
@@ -124,6 +124,32 @@ asset = client().stack(api_key='api_key').assets()
124
124
  result = asset.upload(asset)
125
125
  ```
126
126
 
127
+ ### Development Setup
128
+
129
+ This repository includes Husky-style pre-commit hooks for security scanning and code quality checks. To set up the development environment:
130
+
131
+ ```bash
132
+ # Install required tools
133
+ brew install talisman
134
+ brew install snyk/tap/snyk
135
+
136
+ # Set up Snyk authentication
137
+ export SNYK_TOKEN=your_snyk_token_here
138
+ snyk auth
139
+
140
+ # Install git hooks
141
+ chmod +x .husky/pre-commit .husky/pre-push .husky/hooks/*.sh .husky/hooks/*.py
142
+ cp .husky/pre-commit .git/hooks/pre-commit
143
+ cp .husky/pre-push .git/hooks/pre-push
144
+ chmod +x .git/hooks/pre-commit .git/hooks/pre-push
145
+ ```
146
+
147
+ ### Security Features
148
+
149
+ - **Talisman**: Detects secrets and sensitive data in commits
150
+ - **Snyk**: Scans Python dependencies for vulnerabilities
151
+ - **Code Quality**: Black, isort, flake8 for consistent code style
152
+
127
153
  ### Helpful Links
128
154
 
129
155
  - [Contentstack Website](https://www.contentstack.com/)
@@ -90,6 +90,32 @@ asset = client().stack(api_key='api_key').assets()
90
90
  result = asset.upload(asset)
91
91
  ```
92
92
 
93
+ ### Development Setup
94
+
95
+ This repository includes Husky-style pre-commit hooks for security scanning and code quality checks. To set up the development environment:
96
+
97
+ ```bash
98
+ # Install required tools
99
+ brew install talisman
100
+ brew install snyk/tap/snyk
101
+
102
+ # Set up Snyk authentication
103
+ export SNYK_TOKEN=your_snyk_token_here
104
+ snyk auth
105
+
106
+ # Install git hooks
107
+ chmod +x .husky/pre-commit .husky/pre-push .husky/hooks/*.sh .husky/hooks/*.py
108
+ cp .husky/pre-commit .git/hooks/pre-commit
109
+ cp .husky/pre-push .git/hooks/pre-push
110
+ chmod +x .git/hooks/pre-commit .git/hooks/pre-push
111
+ ```
112
+
113
+ ### Security Features
114
+
115
+ - **Talisman**: Detects secrets and sensitive data in commits
116
+ - **Snyk**: Scans Python dependencies for vulnerabilities
117
+ - **Code Quality**: Black, isort, flake8 for consistent code style
118
+
93
119
  ### Helpful Links
94
120
 
95
121
  - [Contentstack Website](https://www.contentstack.com/)
@@ -16,6 +16,7 @@ from .roles.roles import Roles
16
16
  from .auditlogs.auditlog import Auditlog
17
17
  from .environments.environment import Environment
18
18
  from .entries.entry import Entry
19
+ from .entry_variants.entry_variants import EntryVariants
19
20
  from .contentstack import Client, Region
20
21
  from ._api_client import _APIClient
21
22
  from .common import Parameter
@@ -31,6 +32,8 @@ from .delivery_token.delivery_token import DeliveryToken
31
32
  from .management_token.management_token import ManagementToken
32
33
  from .publish_queue.publish_queue import PublishQueue
33
34
  from .extensions.extension import Extension
35
+ from .variant_group.variant_group import VariantGroup
36
+ from .variants.variants import Variants
34
37
 
35
38
 
36
39
  __all__ = (
@@ -55,6 +58,7 @@ __all__ = (
55
58
  "Auditlog",
56
59
  "Environment",
57
60
  "Entry",
61
+ "EntryVariants",
58
62
  "Locale",
59
63
  "Taxonomy",
60
64
  "Label",
@@ -65,14 +69,16 @@ __all__ = (
65
69
  "DeliveryToken",
66
70
  "ManagementToken",
67
71
  "PublishQueue",
68
- "Extension"
72
+ "Extension",
73
+ "VariantGroup",
74
+ "Variants"
69
75
  )
70
76
 
71
77
  __title__ = 'contentstack-management-python'
72
- __author__ = 'ishaileshmishra'
78
+ __author__ = 'dev-ex'
73
79
  __status__ = 'debug'
74
80
  __region__ = 'na'
75
- __version__ = '1.3.3'
81
+ __version__ = '1.5.0'
76
82
  __host__ = 'api.contentstack.io'
77
83
  __protocol__ = 'https://'
78
84
  __api_version__ = 'v3'
@@ -3,9 +3,7 @@ which is the endpoint for the RESTFUL API that we'll be interacting with.
3
3
  The create(), read(), update(), and delete() methods each correspond to
4
4
  the CRUD operations that can be performed on the API """
5
5
 
6
- import json
7
6
  from ..common import Parameter
8
- from urllib.parse import quote
9
7
  from .._errors import ArgumentException
10
8
 
11
9
  class Auditlog(Parameter):
@@ -227,4 +227,96 @@ class BulkOperation(Parameter):
227
227
  data = json.dumps(data)
228
228
  return self.client.post(url, headers = self.client.headers, data = data, params=self.params)
229
229
 
230
+ def add_items(self, data: dict, headers: dict = None):
231
+ """
232
+ The Add items to bulk operation request allows you to add multiple entries and assets to a bulk operation.
233
+
234
+ :return: The `add_items` method is returning the result of the `post` request made by the
235
+ `client.post` method.
236
+ -------------------------------
237
+ [Example:]
238
+ >>> data = {
239
+ >>> "release": "release_uid"
240
+ >>> "action": "publish",
241
+ >>> "locale": ["en-us", "hi-in"]
242
+ >>> "reference": true
243
+ >>> "items": [
244
+ >>> {
245
+ >>> "uid": "blt63177c0f00f20b61",
246
+ >>> "content_type_uid": "my_blog"
247
+ >>> }
248
+ >>> ]
249
+ >>> }
250
+ >>> import contentstack_management
251
+ >>> client = contentstack_management.Client(authtoken='your_authtoken')
252
+ >>> result = client.stack('api_key').bulk_operation().add_items(data).json()
253
+
254
+ -------------------------------
255
+ """
256
+ if headers is not None:
257
+ self.client.headers.update(headers)
258
+ url = f"{self.path}/release/items"
259
+ data = json.dumps(data)
260
+ return self.client.post(url, headers = self.client.headers, data = data, params=self.params)
261
+
262
+ def update_items(self, data: dict, headers: dict = None):
263
+ """
264
+ The update items to bulk operation request allows you to update multiple entries and assets to a bulk operation.
265
+
266
+ :return: The `update_items` method is returning the result of the `put` request made by the
267
+ `client.post` method.
268
+ -------------------------------
269
+ [Example:]
270
+ >>> data = {
271
+ >>> "release": "release_uid",
272
+ >>> "items": [
273
+ >>> {
274
+ >>> "uid": "entry_uid",
275
+ >>> "locale": "en-us"
276
+ >>> },
277
+ >>> {
278
+ >>> "uid": "entry_uid",
279
+ >>> "locale": "en-us",
280
+ >>> "variant_id": "entry_variant_id"
281
+ >>> }
282
+ >>> ]
283
+ >>> or
284
+ >>> [ '$all' ]
285
+ >>> }
286
+ >>> import contentstack_management
287
+ >>> client = contentstack_management.Client(authtoken='your_authtoken')
288
+ >>> result = client.stack('api_key').bulk_operation().update_items(data).json()
289
+
290
+ -------------------------------
291
+ """
292
+ if headers is not None:
293
+ self.client.headers.update(headers)
294
+ url = f"{self.path}/release/update_items"
295
+ data = json.dumps(data)
296
+ return self.client.put(url, headers = self.client.headers, data = data, params=self.params)
297
+
298
+ def job_status(self, job_uid: str, headers: dict = None):
299
+ """
300
+ The Job status request allows you to get the status of a bulk operation job.
301
+
302
+ :param job_uid: The `job_uid` parameter is a string that represents the unique identifier of the job
303
+ whose status you want to retrieve
304
+ :type job_uid: str
305
+ :return: The `job_status` method is returning the result of the `get` request made by the
306
+ `client.get` method.
307
+ -------------------------------
308
+ [Example:]
309
+ >>> import contentstack_management
310
+ >>> client = contentstack_management.Client(authtoken='your_authtoken')
311
+ >>> result = client.stack('api_key').bulk_operation().job_status('job_uid').json()
312
+
313
+ -------------------------------
314
+ """
315
+ if job_uid is None:
316
+ raise ArgumentException("job_uid", "job_uid cannot be None")
317
+ if headers is not None:
318
+ self.client.headers.update(headers)
319
+ url = f"{self.path}/jobs/{quote(job_uid)}"
320
+ return self.client.get(url, headers = self.client.headers, params=self.params)
321
+
230
322
 
@@ -340,7 +340,7 @@ class ContentType(Parameter):
340
340
  >>> response = content_type.imports()
341
341
  --------------------------------
342
342
  """
343
- url = f"content_types/import"
343
+ url = "content_types/import"
344
344
  self.client.headers['Content-Type'] = "multipart/form-data"
345
345
  files = {'content_type': open(f"{file_path}", 'rb')}
346
346
  return self.client.post(url, headers=self.client.headers, params=self.params, files=files)
@@ -1,4 +1,3 @@
1
- import contentstack_management
2
1
  from enum import Enum
3
2
  from ._api_client import _APIClient
4
3
  from contentstack_management.organizations import organization
@@ -5,7 +5,6 @@ the CRUD operations that can be performed on the API """
5
5
 
6
6
  import json
7
7
  from ..common import Parameter
8
- from urllib.parse import quote
9
8
  from .._errors import ArgumentException
10
9
 
11
10
  class DeliveryToken(Parameter):
@@ -5,6 +5,7 @@ the CRUD operations that can be performed on the API """
5
5
 
6
6
  import json
7
7
  from ..common import Parameter
8
+ from ..entry_variants.entry_variants import EntryVariants
8
9
 
9
10
  class Entry(Parameter):
10
11
  """
@@ -421,13 +422,58 @@ class Entry(Parameter):
421
422
  data = json.dumps(data)
422
423
  return self.client.post(url, headers = self.client.headers, data = data, params = self.params)
423
424
 
424
-
425
-
426
-
427
-
425
+ def variants(self, variant_uid: str = None):
426
+ """
427
+ Returns an EntryVariants instance for managing variant entries.
428
+
429
+ :param variant_uid: The `variant_uid` parameter is a string that represents the unique identifier of
430
+ the variant. It is used to specify which variant to work with
431
+ :type variant_uid: str
432
+ :return: EntryVariants instance for managing variant entries
433
+ -------------------------------
434
+ [Example:]
428
435
 
429
-
436
+ >>> import contentstack_management
437
+ >>> client = contentstack_management.Client(authtoken='your_authtoken')
438
+ >>> # Get all variant entries
439
+ >>> result = client.stack('api_key').content_types('content_type_uid').entry('entry_uid').variants().query().find().json()
440
+ >>> # Get specific variant entry
441
+ >>> result = client.stack('api_key').content_types('content_type_uid').entry('entry_uid').variants('variant_uid').fetch().json()
430
442
 
443
+ -------------------------------
444
+ """
445
+
446
+ return EntryVariants(self.client, self.content_type_uid, self.entry_uid, variant_uid)
431
447
 
448
+ def includeVariants(self, include_variants: str = 'true', variant_uid: str = None, params: dict = None):
449
+ """
450
+ The includeVariants method retrieves the details of a specific base entry with variant details.
451
+
452
+ :param include_variants: The `include_variants` parameter is a string that specifies whether to include variants
453
+ :type include_variants: str
454
+ :param variant_uid: The `variant_uid` parameter is a string that represents the unique identifier of
455
+ the variant. It is used to specify which variant to include
456
+ :type variant_uid: str
457
+ :param params: The `params` parameter is a dictionary that contains query parameters to be sent with the request
458
+ :type params: dict
459
+ :return: the result of the GET request made to the specified URL.
460
+ -------------------------------
461
+ [Example:]
432
462
 
463
+ >>> import contentstack_management
464
+ >>> client = contentstack_management.Client(authtoken='your_authtoken')
465
+ >>> result = client.stack('api_key').content_types('content_type_uid').entry('entry_uid').includeVariants('true', 'variant_uid').json()
466
+ >>> # With parameters
467
+ >>> result = client.stack('api_key').content_types('content_type_uid').entry('entry_uid').includeVariants('true', 'variant_uid', params={'locale': 'en-us'}).json()
433
468
 
469
+ -------------------------------
470
+ """
471
+ if self.entry_uid is None:
472
+ raise Exception('Entry uid is required')
473
+ if params is not None:
474
+ self.params.update(params)
475
+ self.params['include_variants'] = include_variants
476
+ if variant_uid is not None and variant_uid != '':
477
+ self.params['variant_uid'] = variant_uid
478
+ url = f"content_types/{self.content_type_uid}/entries/{self.entry_uid}"
479
+ return self.client.get(url, headers = self.client.headers, params = self.params)
@@ -0,0 +1,3 @@
1
+ from .entry_variants import EntryVariants
2
+
3
+ __all__ = ['EntryVariants']
@@ -0,0 +1,272 @@
1
+ """This class takes a base URL as an argument when it's initialized,
2
+ which is the endpoint for the RESTFUL API that we'll be interacting with.
3
+ The query(), create(), fetch(), delete(), update(), versions(), and includeVariants() methods each correspond to
4
+ the operations that can be performed on the API """
5
+
6
+ import json
7
+ from ..common import Parameter
8
+ from .._errors import ArgumentException
9
+
10
+ class EntryVariants(Parameter):
11
+ """
12
+ This class takes a base URL as an argument when it's initialized,
13
+ which is the endpoint for the RESTFUL API that
14
+ we'll be interacting with. The query(), create(), fetch(), delete(), update(), versions(), and includeVariants()
15
+ methods each correspond to the operations that can be performed on the API """
16
+
17
+ def __init__(self, client, content_type_uid: str, entry_uid: str, variant_uid: str = None):
18
+ self.client = client
19
+ self.content_type_uid = content_type_uid
20
+ self.entry_uid = entry_uid
21
+ self.variant_uid = variant_uid
22
+ super().__init__(self.client)
23
+ self.path = f"content_types/{content_type_uid}/entries/{entry_uid}/variants"
24
+
25
+
26
+ def find(self, params: dict = None):
27
+ """
28
+ The Find variant entries call fetches all the existing variant customizations for an entry.
29
+
30
+ :param params: The `params` parameter is a dictionary that contains query parameters to be sent with the request
31
+ :type params: dict
32
+ :return: Json, with variant entry details.
33
+
34
+ -------------------------------
35
+ [Example:]
36
+
37
+ >>> import contentstack_management
38
+ >>> client = contentstack_management.Client(authtoken='your_authtoken')
39
+ >>> result = client.stack("api_key").content_types('content_type_uid').entry('entry_uid').variants().query().find().json()
40
+ >>> # With parameters
41
+ >>> result = client.stack("api_key").content_types('content_type_uid').entry('entry_uid').variants().find({'limit': 10, 'skip': 0}).json()
42
+
43
+ -------------------------------
44
+ """
45
+ self.validate_content_type_uid()
46
+ self.validate_entry_uid()
47
+ if params is not None:
48
+ self.params.update(params)
49
+ return self.client.get(self.path, headers = self.client.headers, params = self.params)
50
+
51
+ def create(self, data: dict):
52
+ """
53
+ This call is used to create a variant entry for an entry.
54
+
55
+ :param data: The `data` parameter is the payload that you want to send in the request body. It
56
+ should be a dictionary or a JSON serializable object that you want to send as the request body
57
+ :return: Json, with variant entry details.
58
+
59
+ -------------------------------
60
+ [Example:]
61
+ >>> data = {
62
+ >>> "customized_fields": [
63
+ >>> "title",
64
+ >>> "url"
65
+ >>> ],
66
+ >>> "base_entry_version": 10, # optional
67
+ >>> "entry": {
68
+ >>> "title": "example",
69
+ >>> "url": "/example"
70
+ >>> }
71
+ >>> }
72
+ >>> import contentstack_management
73
+ >>> client = contentstack_management.Client(authtoken='your_authtoken')
74
+ >>> result = client.stack('api_key').content_types('content_type_uid').entry('entry_uid').variants().create(data).json()
75
+
76
+ -------------------------------
77
+ """
78
+ self.validate_content_type_uid()
79
+ self.validate_entry_uid()
80
+ data = json.dumps(data)
81
+ return self.client.post(self.path, headers = self.client.headers, data=data, params = self.params)
82
+
83
+ def fetch(self, variant_uid: str = None, params: dict = None):
84
+ """
85
+ The fetch Variant entry call fetches variant entry details.
86
+
87
+ :param variant_uid: The `variant_uid` parameter is a string that represents the unique identifier of
88
+ a variant. It is used to specify which variant to fetch from the server
89
+ :type variant_uid: str
90
+ :param params: The `params` parameter is a dictionary that contains query parameters to be sent with the request
91
+ :type params: dict
92
+ :return: the result of the GET request made to the specified URL.
93
+ -------------------------------
94
+ [Example:]
95
+
96
+ >>> import contentstack_management
97
+ >>> client = contentstack_management.Client(authtoken='your_authtoken')
98
+ >>> result = client.stack('api_key').content_types('content_type_uid').entry('entry_uid').variants('variant_uid').fetch().json()
99
+ >>> # With parameters
100
+ >>> result = client.stack('api_key').content_types('content_type_uid').entry('entry_uid').variants('variant_uid').fetch(params={'include_count': True}).json()
101
+
102
+ -------------------------------
103
+ """
104
+
105
+ if variant_uid is not None and variant_uid != '':
106
+ self.variant_uid = variant_uid
107
+
108
+ self.validate_content_type_uid()
109
+ self.validate_entry_uid()
110
+ self.validate_variant_uid()
111
+ if params is not None:
112
+ self.params.update(params)
113
+ url = f"{self.path}/{self.variant_uid}"
114
+ return self.client.get(url, headers = self.client.headers, params = self.params)
115
+
116
+ def delete(self, variant_uid: str = None):
117
+ """
118
+ The delete a variant entry call is used to delete a specific variant entry.
119
+
120
+ :param variant_uid: The `variant_uid` parameter is a string that represents the unique identifier of
121
+ the variant that you want to delete
122
+ :type variant_uid: str
123
+ :return: the result of the `client.delete()` method, which is likely a response object or a
124
+ boolean value indicating the success of the deletion operation.
125
+ -------------------------------
126
+ [Example:]
127
+
128
+ >>> import contentstack_management
129
+ >>> client = contentstack_management.Client(authtoken='your_authtoken')
130
+ >>> result = client.stack('api_key').content_types('content_type_uid').entry('entry_uid').variants('variant_uid').delete().json()
131
+
132
+ -------------------------------
133
+ """
134
+ if variant_uid is not None and variant_uid != '':
135
+ self.variant_uid = variant_uid
136
+ self.validate_content_type_uid()
137
+ self.validate_entry_uid()
138
+ self.validate_variant_uid()
139
+ url = f"{self.path}/{self.variant_uid}"
140
+ return self.client.delete(url, headers = self.client.headers, params = self.params)
141
+
142
+ def update(self, data: dict, variant_uid: str = None):
143
+ """
144
+ The update a variant entry call updates an entry of a selected variant entry.
145
+
146
+ :param data: The `data` parameter is a dictionary that contains the updated information that you
147
+ want to send to the server. This data will be converted to a JSON string before sending it in
148
+ the request
149
+ :type data: dict
150
+ :param variant_uid: The `variant_uid` parameter is a string that represents the unique identifier of
151
+ the variant. It is used to specify which variant should be updated with the provided data
152
+ :type variant_uid: str
153
+ :return: the result of the `put` request made to the specified URL.
154
+ -------------------------------
155
+ [Example:]
156
+ >>> data = {
157
+ >>> "customized_fields": [
158
+ >>> "title",
159
+ >>> "url"
160
+ >>> ],
161
+ >>> "base_entry_version": 10, # optional
162
+ >>> "entry": {
163
+ >>> "title": "example",
164
+ >>> "url": "/example"
165
+ >>> }
166
+ >>> }
167
+ >>> import contentstack_management
168
+ >>> client = contentstack_management.Client(authtoken='your_authtoken')
169
+ >>> result = client.stack('api_key').content_types('content_type_uid').entry('entry_uid').variants('variant_uid').update(data).json()
170
+
171
+ -------------------------------
172
+ """
173
+ if variant_uid is not None and variant_uid != '':
174
+ self.variant_uid = variant_uid
175
+ self.validate_content_type_uid()
176
+ self.validate_entry_uid()
177
+ self.validate_variant_uid()
178
+ url = f"{self.path}/{self.variant_uid}"
179
+ data = json.dumps(data)
180
+ return self.client.put(url, headers = self.client.headers, data=data, params = self.params)
181
+
182
+ def versions(self, variant_uid: str = None, params: dict = None):
183
+ """
184
+ The version method retrieves the details of a specific variant entry version details.
185
+
186
+ :param variant_uid: The `variant_uid` parameter is a string that represents the unique identifier of
187
+ the variant. It is used to specify which variant to get versions for
188
+ :type variant_uid: str
189
+ :param params: The `params` parameter is a dictionary that contains query parameters to be sent with the request
190
+ :type params: dict
191
+ :return: the result of the GET request made to the specified URL.
192
+ -------------------------------
193
+ [Example:]
194
+
195
+ >>> import contentstack_management
196
+ >>> client = contentstack_management.Client(authtoken='your_authtoken')
197
+ >>> result = client.stack('api_key').content_types('content_type_uid').entry('entry_uid').variants('variant_uid').versions().json()
198
+ >>> # With parameters
199
+ >>> result = client.stack('api_key').content_types('content_type_uid').entry('entry_uid').variants('variant_uid').versions(params={'limit': 10}).json()
200
+
201
+ -------------------------------
202
+ """
203
+ if variant_uid is not None and variant_uid != '':
204
+ self.variant_uid = variant_uid
205
+ self.validate_content_type_uid()
206
+ self.validate_entry_uid()
207
+ self.validate_variant_uid()
208
+ if params is not None:
209
+ self.params.update(params)
210
+ url = f"{self.path}/{self.variant_uid}/versions"
211
+ return self.client.get(url, headers = self.client.headers, params = self.params)
212
+
213
+ def includeVariants(self, include_variants: str = 'true', variant_uid: str = None, params: dict = None):
214
+ """
215
+ The includeVariants method retrieves the details of a specific base entry with variant details.
216
+
217
+ :param include_variants: The `include_variants` parameter is a string that specifies whether to include variants
218
+ :type include_variants: str
219
+ :param variant_uid: The `variant_uid` parameter is a string that represents the unique identifier of
220
+ the variant. It is used to specify which variant to include
221
+ :type variant_uid: str
222
+ :param params: The `params` parameter is a dictionary that contains query parameters to be sent with the request
223
+ :type params: dict
224
+ :return: the result of the GET request made to the specified URL.
225
+ -------------------------------
226
+ [Example:]
227
+
228
+ >>> import contentstack_management
229
+ >>> client = contentstack_management.Client(authtoken='your_authtoken')
230
+ >>> result = client.stack('api_key').content_types('content_type_uid').entry('entry_uid').includeVariants('true', 'variant_uid').json()
231
+ >>> # With parameters
232
+ >>> result = client.stack('api_key').content_types('content_type_uid').entry('entry_uid').includeVariants('true', 'variant_uid', params={'locale': 'en-us'}).json()
233
+
234
+ -------------------------------
235
+ """
236
+ if variant_uid is not None and variant_uid != '':
237
+ self.variant_uid = variant_uid
238
+ self.validate_content_type_uid()
239
+ self.validate_entry_uid()
240
+ self.validate_variant_uid()
241
+ if params is not None:
242
+ self.params.update(params)
243
+ self.params['include_variants'] = include_variants
244
+ url = f"content_types/{self.content_type_uid}/entries/{self.entry_uid}"
245
+ return self.client.get(url, headers = self.client.headers, params = self.params)
246
+
247
+ def validate_content_type_uid(self):
248
+ """
249
+ The function checks if the content_type_uid is None or an empty string and raises an ArgumentException
250
+ if it is.
251
+ """
252
+
253
+ if self.content_type_uid is None or self.content_type_uid == '':
254
+ raise ArgumentException("content type Uid is required")
255
+
256
+ def validate_entry_uid(self):
257
+ """
258
+ The function checks if the entry_uid is None or an empty string and raises an ArgumentException
259
+ if it is.
260
+ """
261
+
262
+ if self.entry_uid is None or self.entry_uid == '':
263
+ raise ArgumentException("entry Uid is required")
264
+
265
+ def validate_variant_uid(self):
266
+ """
267
+ The function checks if the variant_uid is None or an empty string and raises an ArgumentException
268
+ if it is.
269
+ """
270
+
271
+ if self.variant_uid is None or self.variant_uid == '':
272
+ raise ArgumentException("variant Uid is required")
@@ -5,7 +5,6 @@ the CRUD operations that can be performed on the API """
5
5
 
6
6
  import json
7
7
  from ..common import Parameter
8
- from urllib.parse import quote
9
8
  from .._errors import ArgumentException
10
9
 
11
10
  class Environment(Parameter):
@@ -5,7 +5,6 @@ the CRUD operations that can be performed on the API """
5
5
 
6
6
  import json
7
7
  from ..common import Parameter
8
- from urllib.parse import quote
9
8
  from .._errors import ArgumentException
10
9
  from requests_toolbelt.multipart.encoder import MultipartEncoder
11
10