Skip to content

Commit 031af0f

Browse files
sunil-lakshmanishaileshmishraharshithad0703
authored
Next (#28)
* Added users and organisations api methods User Session Logging in/out Users Get User Update User Activate User Request Password Reset Password Organizations Get All Organizations Get Single Organization Organization Roles Organization Users Transfer Organization Ownership Organization Stacks Organization Logs * added requirements.txt file * loaded install, changlog , codeowners and release.yml file * Organized package structure * Developed stack Implementation * Code Optimized * Added Mock test and Api Test cases * Added test cases and coverage packages * Added API documentation and added stacks test cases * Added coverage reports generartion in github action Added coverage report github action Changed methods name Changed unit test cases Code improvements API Documentation * Added global fields class * - General code improvements - Corrected few testcases - Single place for credentials - linting added * Feat/cs 40287 workflow class implemetation (#14) * feat: ✨ implemented branches and aliases with unit and api test cases * test: ✅ added mock tests for branches and aliases * docs: 📝 added api documentation for branches and aliases * feat: ✨ content type implementation with api references, unit test cases and api test cases * test: renamed the api, mock, unit test file names of branch and alias * test: renamed file path in branch and alias mock tests * test: improved coverage report for branches and aliases * test: Added mock test cases for content type * docs: 📝 Cleared typo errors * test: removed unwanted test files * refactor: Code improvement for branches, aliases and content type implementation * - General code improvements - Testcases improvements * - General code improvements - Testcases improvements * - General code improvements - Formats are updated * code enhancement * Created Entry class and test cases Created Entry Class created entry class test cases * feat: ✨ asset class implementation with tests and api docs * Code improvements and changed test cases to new structure * test: ✅ added resources and made some changes in api and unit test cases * Updated Unit test cases. * Webhook class Implementation * Created workflow class * Deleted secrets-scan.yml file * Updated variable name * Deleted sast-scan.yml file * Feat/cs 40545 metadata class implemetation (#15) * Metadata class implementation * Deleted sast-scan.yml file * Fixed PR comments * Code optimisation and handling custom error exception * Removed uids * Feat/cs 40549 roles class implementation (#16) * Created roles class with unit testcases, mock test cases and api test cases * Updated coverage report github workflow file * Added coverage install command * Added pytest install command * Updated stack class unit test file * Added html coverage * Added coverage reports and visualizations * Removed visualisation * Generating coverage report in svg format * Added coverage-badge install command * Fixed PR comments and code optimisation * Added coverage reports graphical visualisation in github page * Created readme file * changed variable name * Updated readme file * Update README.md * Added auditlog class and license file (#17) * Added auditlog class and license file * Added test case for invalid inputs * commented the idiom It Allows You to Execute Code When the File Runs as a Script, but Not When It’s Imported as a Module --------- Co-authored-by: Shailesh Mishra <[email protected]> --------- Co-authored-by: Shailesh Mishra <[email protected]> * Developed environment class implementation (#19) * Developed environment class implementation * Updated variable name * Added CI-CD implementation (#20) * Added CI-CD implementation Added CICD implemetation Updated code Optimization Updated code for check package in test environment. * Removed Unused files * Feat/cs 41198 locale class implementation (#21) * Added locale class implementation * Implemented taxonomy support (#22) --------- Co-authored-by: harshithad0703 <[email protected]> Co-authored-by: Shailesh Mishra <[email protected]> Co-authored-by: Shailesh Mishra <[email protected]> * Feat/cs 41199 label class implementation (#25) * Next (#23) * Added users and organisations api methods User Session Logging in/out Users Get User Update User Activate User Request Password Reset Password Organizations Get All Organizations Get Single Organization Organization Roles Organization Users Transfer Organization Ownership Organization Stacks Organization Logs * added requirements.txt file * loaded install, changlog , codeowners and release.yml file * Organized package structure * Developed stack Implementation * Code Optimized * Added Mock test and Api Test cases * Added test cases and coverage packages * Added API documentation and added stacks test cases * Added coverage reports generartion in github action Added coverage report github action Changed methods name Changed unit test cases Code improvements API Documentation * Added global fields class * - General code improvements - Corrected few testcases - Single place for credentials - linting added * Feat/cs 40287 workflow class implemetation (#14) * feat: ✨ implemented branches and aliases with unit and api test cases * test: ✅ added mock tests for branches and aliases * docs: 📝 added api documentation for branches and aliases * feat: ✨ content type implementation with api references, unit test cases and api test cases * test: renamed the api, mock, unit test file names of branch and alias * test: renamed file path in branch and alias mock tests * test: improved coverage report for branches and aliases * test: Added mock test cases for content type * docs: 📝 Cleared typo errors * test: removed unwanted test files * refactor: Code improvement for branches, aliases and content type implementation * - General code improvements - Testcases improvements * - General code improvements - Testcases improvements * - General code improvements - Formats are updated * code enhancement * Created Entry class and test cases Created Entry Class created entry class test cases * feat: ✨ asset class implementation with tests and api docs * Code improvements and changed test cases to new structure * test: ✅ added resources and made some changes in api and unit test cases * Updated Unit test cases. * Webhook class Implementation * Created workflow class * Deleted secrets-scan.yml file * Updated variable name * Deleted sast-scan.yml file * Feat/cs 40545 metadata class implemetation (#15) * Metadata class implementation * Deleted sast-scan.yml file * Fixed PR comments * Code optimisation and handling custom error exception * Removed uids * Feat/cs 40549 roles class implementation (#16) * Created roles class with unit testcases, mock test cases and api test cases * Updated coverage report github workflow file * Added coverage install command * Added pytest install command * Updated stack class unit test file * Added html coverage * Added coverage reports and visualizations * Removed visualisation * Generating coverage report in svg format * Added coverage-badge install command * Fixed PR comments and code optimisation * Added coverage reports graphical visualisation in github page * Created readme file * changed variable name * Updated readme file * Update README.md * Added auditlog class and license file (#17) * Added auditlog class and license file * Added test case for invalid inputs * commented the idiom It Allows You to Execute Code When the File Runs as a Script, but Not When It’s Imported as a Module --------- Co-authored-by: Shailesh Mishra <[email protected]> --------- Co-authored-by: Shailesh Mishra <[email protected]> * Developed environment class implementation (#19) * Developed environment class implementation * Updated variable name * Added CI-CD implementation (#20) * Added CI-CD implementation Added CICD implemetation Updated code Optimization Updated code for check package in test environment. * Removed Unused files * Feat/cs 41198 locale class implementation (#21) * Added locale class implementation * Implemented taxonomy support (#22) --------- Co-authored-by: harshithad0703 <[email protected]> Co-authored-by: Shailesh Mishra <[email protected]> Co-authored-by: Shailesh Mishra <[email protected]> --------- Co-authored-by: Shailesh Mishra <[email protected]> Co-authored-by: Shailesh Mishra <[email protected]> Co-authored-by: harshithad0703 <[email protected]> * Deleted .idea directory (#24) * Deleted .idea directory * Deleted Test apidoc files * Deleted coverage.txt file * Created label class implementation * Updated document data --------- Co-authored-by: Shailesh Mishra <[email protected]> Co-authored-by: Shailesh Mishra <[email protected]> Co-authored-by: harshithad0703 <[email protected]> * Feat/cs 41332 terms class implemetation (#27) * Next (#26) * Added users and organisations api methods User Session Logging in/out Users Get User Update User Activate User Request Password Reset Password Organizations Get All Organizations Get Single Organization Organization Roles Organization Users Transfer Organization Ownership Organization Stacks Organization Logs * added requirements.txt file * loaded install, changlog , codeowners and release.yml file * Organized package structure * Developed stack Implementation * Code Optimized * Added Mock test and Api Test cases * Added test cases and coverage packages * Added API documentation and added stacks test cases * Added coverage reports generartion in github action Added coverage report github action Changed methods name Changed unit test cases Code improvements API Documentation * Added global fields class * - General code improvements - Corrected few testcases - Single place for credentials - linting added * Feat/cs 40287 workflow class implemetation (#14) * feat: ✨ implemented branches and aliases with unit and api test cases * test: ✅ added mock tests for branches and aliases * docs: 📝 added api documentation for branches and aliases * feat: ✨ content type implementation with api references, unit test cases and api test cases * test: renamed the api, mock, unit test file names of branch and alias * test: renamed file path in branch and alias mock tests * test: improved coverage report for branches and aliases * test: Added mock test cases for content type * docs: 📝 Cleared typo errors * test: removed unwanted test files * refactor: Code improvement for branches, aliases and content type implementation * - General code improvements - Testcases improvements * - General code improvements - Testcases improvements * - General code improvements - Formats are updated * code enhancement * Created Entry class and test cases Created Entry Class created entry class test cases * feat: ✨ asset class implementation with tests and api docs * Code improvements and changed test cases to new structure * test: ✅ added resources and made some changes in api and unit test cases * Updated Unit test cases. * Webhook class Implementation * Created workflow class * Deleted secrets-scan.yml file * Updated variable name * Deleted sast-scan.yml file * Feat/cs 40545 metadata class implemetation (#15) * Metadata class implementation * Deleted sast-scan.yml file * Fixed PR comments * Code optimisation and handling custom error exception * Removed uids * Feat/cs 40549 roles class implementation (#16) * Created roles class with unit testcases, mock test cases and api test cases * Updated coverage report github workflow file * Added coverage install command * Added pytest install command * Updated stack class unit test file * Added html coverage * Added coverage reports and visualizations * Removed visualisation * Generating coverage report in svg format * Added coverage-badge install command * Fixed PR comments and code optimisation * Added coverage reports graphical visualisation in github page * Created readme file * changed variable name * Updated readme file * Update README.md * Added auditlog class and license file (#17) * Added auditlog class and license file * Added test case for invalid inputs * commented the idiom It Allows You to Execute Code When the File Runs as a Script, but Not When It’s Imported as a Module --------- Co-authored-by: Shailesh Mishra <[email protected]> --------- Co-authored-by: Shailesh Mishra <[email protected]> * Developed environment class implementation (#19) * Developed environment class implementation * Updated variable name * Added CI-CD implementation (#20) * Added CI-CD implementation Added CICD implemetation Updated code Optimization Updated code for check package in test environment. * Removed Unused files * Feat/cs 41198 locale class implementation (#21) * Added locale class implementation * Implemented taxonomy support (#22) --------- Co-authored-by: harshithad0703 <[email protected]> Co-authored-by: Shailesh Mishra <[email protected]> Co-authored-by: Shailesh Mishra <[email protected]> * Feat/cs 41199 label class implementation (#25) * Next (#23) * Added users and organisations api methods User Session Logging in/out Users Get User Update User Activate User Request Password Reset Password Organizations Get All Organizations Get Single Organization Organization Roles Organization Users Transfer Organization Ownership Organization Stacks Organization Logs * added requirements.txt file * loaded install, changlog , codeowners and release.yml file * Organized package structure * Developed stack Implementation * Code Optimized * Added Mock test and Api Test cases * Added test cases and coverage packages * Added API documentation and added stacks test cases * Added coverage reports generartion in github action Added coverage report github action Changed methods name Changed unit test cases Code improvements API Documentation * Added global fields class * - General code improvements - Corrected few testcases - Single place for credentials - linting added * Feat/cs 40287 workflow class implemetation (#14) * feat: ✨ implemented branches and aliases with unit and api test cases * test: ✅ added mock tests for branches and aliases * docs: 📝 added api documentation for branches and aliases * feat: ✨ content type implementation with api references, unit test cases and api test cases * test: renamed the api, mock, unit test file names of branch and alias * test: renamed file path in branch and alias mock tests * test: improved coverage report for branches and aliases * test: Added mock test cases for content type * docs: 📝 Cleared typo errors * test: removed unwanted test files * refactor: Code improvement for branches, aliases and content type implementation * - General code improvements - Testcases improvements * - General code improvements - Testcases improvements * - General code improvements - Formats are updated * code enhancement * Created Entry class and test cases Created Entry Class created entry class test cases * feat: ✨ asset class implementation with tests and api docs * Code improvements and changed test cases to new structure * test: ✅ added resources and made some changes in api and unit test cases * Updated Unit test cases. * Webhook class Implementation * Created workflow class * Deleted secrets-scan.yml file * Updated variable name * Deleted sast-scan.yml file * Feat/cs 40545 metadata class implemetation (#15) * Metadata class implementation * Deleted sast-scan.yml file * Fixed PR comments * Code optimisation and handling custom error exception * Removed uids * Feat/cs 40549 roles class implementation (#16) * Created roles class with unit testcases, mock test cases and api test cases * Updated coverage report github workflow file * Added coverage install command * Added pytest install command * Updated stack class unit test file * Added html coverage * Added coverage reports and visualizations * Removed visualisation * Generating coverage report in svg format * Added coverage-badge install command * Fixed PR comments and code optimisation * Added coverage reports graphical visualisation in github page * Created readme file * changed variable name * Updated readme file * Update README.md * Added auditlog class and license file (#17) * Added auditlog class and license file * Added test case for invalid inputs * commented the idiom It Allows You to Execute Code When the File Runs as a Script, but Not When It’s Imported as a Module --------- Co-authored-by: Shailesh Mishra <[email protected]> --------- Co-authored-by: Shailesh Mishra <[email protected]> * Developed environment class implementation (#19) * Developed environment class implementation * Updated variable name * Added CI-CD implementation (#20) * Added CI-CD implementation Added CICD implemetation Updated code Optimization Updated code for check package in test environment. * Removed Unused files * Feat/cs 41198 locale class implementation (#21) * Added locale class implementation * Implemented taxonomy support (#22) --------- Co-authored-by: harshithad0703 <[email protected]> Co-authored-by: Shailesh Mishra <[email protected]> Co-authored-by: Shailesh Mishra <[email protected]> --------- Co-authored-by: Shailesh Mishra <[email protected]> Co-authored-by: Shailesh Mishra <[email protected]> Co-authored-by: harshithad0703 <[email protected]> * Deleted .idea directory (#24) * Deleted .idea directory * Deleted Test apidoc files * Deleted coverage.txt file * Created label class implementation * Updated document data --------- Co-authored-by: Shailesh Mishra <[email protected]> Co-authored-by: Shailesh Mishra <[email protected]> Co-authored-by: harshithad0703 <[email protected]> --------- Co-authored-by: Shailesh Mishra <[email protected]> Co-authored-by: Shailesh Mishra <[email protected]> Co-authored-by: harshithad0703 <[email protected]> * Added terms class implementation --------- Co-authored-by: Shailesh Mishra <[email protected]> Co-authored-by: Shailesh Mishra <[email protected]> Co-authored-by: harshithad0703 <[email protected]> --------- Co-authored-by: Shailesh Mishra <[email protected]> Co-authored-by: Shailesh Mishra <[email protected]> Co-authored-by: harshithad0703 <[email protected]>
1 parent 839a041 commit 031af0f

File tree

14 files changed

+699
-0
lines changed

14 files changed

+699
-0
lines changed

.talismanrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,4 +260,12 @@ fileignoreconfig:
260260
- filename: tests/mock/labels/test_labels_mock.py
261261
checksum: 069ee74fe19848e7a5bc4510772c389421e03956c31ce8347f93cb67b7f16847
262262
version: ""
263+
fileignoreconfig:
264+
- filename: tests/api/terms/test_terms_api.py
265+
checksum: f8aecb8888884944bb18219e1437e46421140a534467df3ebcb579aa80089627
266+
- filename: tests/mock/terms/test_terms_mock.py
267+
checksum: d8816eddbcbcc993e123afd9d40a7c55cafc1f50e4dbe91084c2212d4715d2d3
268+
- filename: tests/unit/terms/test_terms_unit.py
269+
checksum: 1723d11c8e22d67e28409c0868781c3e4ec7e1d8e97d63e718716d26e486c8ad
270+
version: ""
263271

SECURITY.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## Security
2+
3+
Contentstack takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations.
4+
5+
If you believe you have found a security vulnerability in any Contentstack-owned repository, please report it to us as described below.
6+
7+
## Reporting Security Issues
8+
9+
**Please do not report security vulnerabilities through public GitHub issues.**
10+
11+
Send email to [[email protected]](mailto:[email protected]).
12+
13+
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message.
14+
15+
Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
16+
17+
* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
18+
* Full paths of source file(s) related to the manifestation of the issue
19+
* The location of the affected source code (tag/branch/commit or direct URL)
20+
* Any special configuration required to reproduce the issue
21+
* Step-by-step instructions to reproduce the issue
22+
* Proof-of-concept or exploit code (if possible)
23+
* Impact of the issue, including how an attacker might exploit the issue
24+
25+
This information will help us triage your report more quickly.
26+
27+
[https://www.contentstack.com/trust/](https://www.contentstack.com/trust/)

contentstack_management/taxonomies/__init__.py

Whitespace-only changes.

contentstack_management/taxonomies/taxonomy.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from ..common import Parameter
88
from urllib.parse import quote
99
from .._errors import ArgumentException
10+
from ..terms.terms import Terms
1011

1112
class Taxonomy(Parameter):
1213
"""
@@ -147,5 +148,9 @@ def validate_taxonomy_uid(self):
147148
if self.taxonomy_uid is None or '':
148149
raise ArgumentException('Taxonomy Uid is required')
149150

151+
def terms(self, terms_uid: str = None):
152+
self.validate_taxonomy_uid()
153+
return Terms(self.client, self.taxonomy_uid, terms_uid)
154+
150155

151156

contentstack_management/terms/__init__.py

Whitespace-only changes.
Lines changed: 298 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,298 @@
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 create(), read(), update(), and delete() methods each correspond to
4+
the CRUD operations that can be performed on the API """
5+
6+
import json
7+
from ..common import Parameter
8+
from urllib.parse import quote
9+
from .._errors import ArgumentException
10+
11+
class Terms(Parameter):
12+
"""
13+
This class takes a base URL as an argument when it's initialized,
14+
which is the endpoint for the RESTFUL API that
15+
we'll be interacting with. The create(), read(), update(), and delete()
16+
methods each correspond to the CRUD
17+
operations that can be performed on the API """
18+
19+
def __init__(self, client, taxonomy_uid: str, terms_uid: str):
20+
self.client = client
21+
self.taxonomy_uid = taxonomy_uid
22+
self.terms_uid = terms_uid
23+
super().__init__(self.client)
24+
self.path = f"taxonomies/{self.taxonomy_uid}/terms"
25+
26+
def find(self):
27+
"""
28+
This call fetches the list of all terms available for a taxonomies.
29+
:return: Json, with taxonomy details.
30+
31+
-------------------------------
32+
[Example:]
33+
34+
>>> from contentstack_management import contentstack
35+
>>> client = contentstack.client(authtoken='your_authtoken')
36+
>>> result = client.stack("api_key").taxonomy("taxonomy_uid").terms().find()
37+
38+
-------------------------------
39+
"""
40+
return self.client.get(self.path, headers = self.client.headers)
41+
42+
43+
44+
def fetch(self, terms_uid: str = None):
45+
"""
46+
The Get a terms call returns information about a specific taxonomy available on the stack.
47+
48+
:param terms_uid: The `terms_uid` parameter is a string that represents the unique identifier of
49+
the terms you want to fetch. It is an optional parameter, meaning it can be None or an empty
50+
string if you don't want to specify a specific terms_uid
51+
:type terms_uid: str
52+
:return: the result of the GET request made to the specified URL.
53+
-------------------------------
54+
[Example:]
55+
56+
>>> from contentstack_management import contentstack
57+
>>> client = contentstack.client(authtoken='your_authtoken')
58+
>>> result = client.stack('api_key').taxonomy('taxonomy_uid').terms('terms_uid').fetch()
59+
60+
-------------------------------
61+
"""
62+
63+
if terms_uid is not None and terms_uid != '':
64+
self.terms_uid = terms_uid
65+
66+
self.validate_taxonomy_uid()
67+
self.validate_terms_uid()
68+
url = f"{self.path}/{self.terms_uid}"
69+
return self.client.get(url, headers = self.client.headers)
70+
71+
72+
def create(self, data: dict):
73+
"""
74+
This call lets you add a new terms to your taxonomy.
75+
76+
:param data: The `data` parameter is a dictionary that contains the data to be sent in the
77+
request body. It will be converted to a JSON string using the `json.dumps()` function before
78+
being sent in the request
79+
:type data: dict
80+
:return: The code is returning the result of the `post` method call on the `self.client` object.
81+
82+
-------------------------------
83+
[Example:]
84+
>>> data ={
85+
>>> "term": {
86+
>>> "uid": "term_1",
87+
>>> "name": "Term 1"
88+
>>> },
89+
>>> "parent_uid": null
90+
>>> }
91+
>>> from contentstack_management import contentstack
92+
>>> client = contentstack.client(authtoken='your_authtoken')
93+
>>> result = client.stack('api_key').taxonomy('taxonomy_uid').terms().create(data)
94+
-------------------------------
95+
"""
96+
97+
data = json.dumps(data)
98+
return self.client.post(self.path, headers = self.client.headers, data=data)
99+
100+
def update(self, data: dict, terms_uid: str = None):
101+
"""
102+
The function updates a resource with the given data and terms UID.
103+
104+
:param data: A dictionary containing the data to be updated
105+
:type data: dict
106+
:param terms_uid: The `terms_uid` parameter is a string that represents the unique identifier of
107+
the terms you want to update
108+
:type terms_uid: str
109+
:return: the result of the `self.client.put()` method, which is the response from making a PUT
110+
request to the specified URL with the provided data and headers.
111+
112+
-------------------------------
113+
[Example:]
114+
>>> data ={
115+
>>> "term": {
116+
>>> "name": "Term 1"
117+
>>> }
118+
>>> }
119+
>>> from contentstack_management import contentstack
120+
>>> client = contentstack.client(authtoken='your_authtoken')
121+
>>> result = client.stack('api_key').taxonomy("taxonomy_uid").terms('terms_uid').update(data)
122+
123+
-------------------------------
124+
"""
125+
126+
if terms_uid is not None and terms_uid != '':
127+
self.terms_uid = terms_uid
128+
129+
self.validate_taxonomy_uid()
130+
url = url = f"{self.path}/{self.terms_uid}"
131+
data = json.dumps(data)
132+
return self.client.put(url, headers = self.client.headers, data=data)
133+
134+
135+
def delete(self, terms_uid: str = None):
136+
"""
137+
The Delete terms call deletes an existing terms from your taxonomy.
138+
139+
:param terms_uid: The `terms_uid` parameter is a string that represents the unique identifier of
140+
the terms you want to delete
141+
:type terms_uid: str
142+
:return: the result of the delete request made to the specified URL.
143+
144+
-------------------------------
145+
[Example:]
146+
147+
>>> from contentstack_management import contentstack
148+
>>> client = contentstack.client(authtoken='your_authtoken')
149+
>>> result = result = client.stack('api_key').taxonomy('taxonomy_uid').terms('terms_uid').delete('taxonomy_uid')
150+
151+
-------------------------------
152+
"""
153+
if terms_uid is not None and terms_uid != '':
154+
self.terms_uid = terms_uid
155+
156+
self.validate_taxonomy_uid()
157+
self.validate_terms_uid()
158+
url = f"{self.path}/{self.terms_uid}"
159+
return self.client.delete(url, headers = self.client.headers)
160+
161+
162+
def search(self, term_string: str):
163+
"""
164+
The "Get a terms" call returns information about a specified terms available on the taxonomy.
165+
166+
:param term_string: The term_string parameter is a string that represents the term you want to
167+
search for. It is used to specify the term you want to search for in the search function
168+
:type term_string: str
169+
:return:Json, with taxonomy details.
170+
-------------------------------
171+
[Example:]
172+
173+
>>> from contentstack_management import contentstack
174+
>>> client = contentstack.client(authtoken='your_authtoken')
175+
>>> result = client.stack('api_key').taxonomy('taxonomy_uid').terms('terms_uid').search("terms_string")
176+
177+
-------------------------------
178+
"""
179+
180+
self.validate_taxonomy_uid()
181+
self.validate_term_string(term_string)
182+
Parameter.add_param(self, "term", term_string)
183+
return self.client.get(self.path, headers = self.client.headers)
184+
185+
def move(self, data: dict, terms_uid: str = None):
186+
"""
187+
The "Move terms" call will let you update the details
188+
189+
:param data: The `data` parameter is a dictionary that contains the data to be sent in the
190+
request body. It will be converted to a JSON string before sending the request
191+
:type data: dict
192+
:param terms_uid: The `terms_uid` parameter is a string that represents the unique identifier of
193+
the terms you want to move
194+
:type terms_uid: str
195+
:return: Json, with updated taxonomy details.
196+
-------------------------------
197+
[Example:]
198+
>>> data ={
199+
>>> "term": {
200+
>>> "uid": "term_1"
201+
>>> },
202+
>>> "parent_uid": null
203+
>>> }
204+
>>> Under an existing Term:
205+
>>> {
206+
>>> "term": {
207+
>>> "uid": "term_3"
208+
>>> },
209+
>>> "parent_uid": "term_1"
210+
>>> }
211+
>>> from contentstack_management import contentstack
212+
>>> client = contentstack.client(authtoken='your_authtoken')
213+
>>> result = client.stack('api_key').taxonomy("taxonomy_uid").terms('terms_uid').move(data).json()
214+
215+
-------------------------------
216+
"""
217+
218+
if terms_uid is not None and terms_uid != '':
219+
self.terms_uid = terms_uid
220+
221+
self.validate_taxonomy_uid()
222+
self.validate_terms_uid()
223+
url = f"{self.path}/{self.terms_uid}"
224+
data = json.dumps(data)
225+
return self.client.put(url, headers = self.client.headers, data=data)
226+
227+
228+
def ancestors(self, terms_uid: str = None):
229+
"""
230+
The "Get a ancestors terms" call returns information about a specific terms available on the taxonomy.
231+
232+
:param terms_uid: The `terms_uid` parameter is a string that represents the unique identifier of
233+
a term in a taxonomy. It is used to specify the term for which you want to retrieve the
234+
ancestors
235+
:type terms_uid: str
236+
:return: The code is returning the result of a GET request to the specified URL, which is the
237+
ancestors of the terms with the given terms_uid.
238+
239+
-------------------------------
240+
[Example:]
241+
242+
>>> from contentstack_management import contentstack
243+
>>> client = contentstack.client(authtoken='your_authtoken')
244+
>>> result = client.stack('api_key').taxonomy('taxonomy_uid').terms('terms_uid').ancestors().json()
245+
246+
-------------------------------
247+
"""
248+
249+
if terms_uid is not None and terms_uid != '':
250+
self.terms_uid = terms_uid
251+
252+
self.validate_taxonomy_uid()
253+
self.validate_terms_uid()
254+
url = f"{self.path}/{self.terms_uid}/ancestors"
255+
return self.client.get(url, headers = self.client.headers)
256+
257+
def descendants(self, terms_uid: str = None):
258+
"""
259+
The "Get a descendants terms" call returns information about a specific terms available on the taxonomy.
260+
261+
:param terms_uid: The `terms_uid` parameter is a string that represents the unique identifier of
262+
a term in a taxonomy. It is used to specify the term for which you want to retrieve its
263+
descendants
264+
:type terms_uid: str
265+
:return: the result of a GET request to the specified URL.
266+
267+
-------------------------------
268+
[Example:]
269+
270+
>>> from contentstack_management import contentstack
271+
>>> client = contentstack.client(authtoken='your_authtoken')
272+
>>> result = client.stack('api_key').taxonomy('taxonomy_uid').terms('terms_uid').descendants().json()
273+
274+
-------------------------------
275+
"""
276+
277+
if terms_uid is not None and terms_uid != '':
278+
self.terms_uid = terms_uid
279+
280+
self.validate_taxonomy_uid()
281+
self.validate_terms_uid()
282+
url = f"{self.path}/{self.terms_uid}/descendants"
283+
return self.client.get(url, headers = self.client.headers)
284+
285+
def validate_taxonomy_uid(self):
286+
if self.taxonomy_uid is None or '':
287+
raise ArgumentException('Taxonomy Uid is required')
288+
289+
def validate_terms_uid(self):
290+
if self.terms_uid is None or '':
291+
raise ArgumentException('Terms Uid is required')
292+
293+
def validate_term_string(self, term_string):
294+
if term_string is None or '':
295+
raise ArgumentException('Term String is required')
296+
297+
298+

0 commit comments

Comments
 (0)