Skip to content

Commit 98e5e30

Browse files
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)
1 parent 92e2a31 commit 98e5e30

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1700
-154
lines changed

.github/workflows/release.yml

Lines changed: 29 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,39 @@
1-
# this file is *not* meant to cover or endorse the use of GitHub Actions, but rather to
2-
# help make automated releases for this project
1+
# This workflow will upload a Python Package using Twine when a release is created
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
33

4-
name: Release
4+
# This workflow uses actions that are not certified by GitHub.
5+
# They are provided by a third-party and are governed by
6+
# separate terms of service, privacy policy, and support
7+
# documentation.
8+
9+
name: Upload Python Package
510

611
on:
712
release:
8-
types: [created]
13+
types: [published]
14+
15+
permissions:
16+
contents: read
917

1018
jobs:
11-
build-and-publish:
12-
runs-on: ubuntu-22.04
19+
deploy:
20+
21+
runs-on: ubuntu-latest
22+
1323
steps:
14-
- name: Checkout
15-
uses: actions/checkout@v2
24+
- uses: actions/checkout@v3
1625
- name: Set up Python
17-
uses: actions/setup-python@v1
26+
uses: actions/setup-python@v3
1827
with:
19-
python-version: "3.10.11"
20-
- name: Install build dependencies
21-
run: python -m pip install -U setuptools wheel build
22-
- name: Build
23-
run: python -m build .
24-
- name: Publish
25-
uses: pypa/gh-action-pypi-publish@master
28+
python-version: '3.x'
29+
- name: Install dependencies
30+
run: |
31+
python -m pip install --upgrade pip
32+
pip install build
33+
- name: Build package
34+
run: python -m build
35+
- name: Publish package
36+
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
2637
with:
27-
password: ${{ secrets.pypi_test_password }}
28-
skip_existing: true
29-
30-
generate_and_upload_coverage:
31-
name: Generate and Upload Coverage Report
32-
runs-on: ubuntu-22.04
33-
strategy:
34-
fail-fast: false
35-
matrix:
36-
python-version: ["3.10.11"]
37-
38-
steps:
39-
- name: Checkout code
40-
uses: actions/checkout@v2
41-
42-
- name: Set up Python
43-
uses: actions/setup-python@v2
44-
with:
45-
python-version: ${{ matrix.python-version }}
46-
47-
- name: Update Pip
48-
run: pip install --upgrade pip
49-
pip install --use-pep517
50-
51-
- name: Create and activate virtual environment
52-
run: |
53-
python -m venv venv
54-
source venv/bin/activate
55-
56-
- name: Install build dependencies
57-
run: python -m pip install -U setuptools wheel build
58-
59-
- name: Install dependencies
60-
run: pip install -r requirements.txt
61-
62-
- name: Run tests and generate coverage report
63-
run: |
64-
coverage run -m pytest
65-
coverage report -m > coverage.txt
66-
67-
- name: Archive coverage report
68-
uses: actions/upload-artifact@v2
69-
with:
70-
name: coverage-report
71-
path: coverage.txt
72-
73-
- name: Configure AWS credentials
74-
uses: aws-actions/configure-aws-credentials@v1
75-
with:
76-
aws-access-key-id: ${{ secrets.Test_AWS_ACCESS_KEY_ID }}
77-
aws-secret-access-key: ${{ secrets.Test_AWS_SECRET_ACCESS_KEY }}
78-
aws-region: <your_aws_region> # Replace with your actual AWS region
79-
80-
- name: Upload coverage report to S3
81-
run: aws s3 cp coverage.txt s3://<your_bucket_name>/coverage.txt
38+
user: __token__
39+
password: ${{ secrets.PYPI_API_TOKEN }}

.talismanrc

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,3 +209,45 @@ fileignoreconfig:
209209
- filename: tests/unit/auditlogs/test_auditlog_unit.py
210210
checksum: 1b8b24cc7f7921d209b983a99c0305d5fb27c1fe8e3fc74f1d525a7327eba830
211211
version: ""
212+
fileignoreconfig:
213+
- filename: contentstack_management/environments/environments.py
214+
checksum: d2289d750bcc3fc7197d3c853fd0fcbde5e9a971ed332cb6477edcb6620ad58b
215+
- filename: tests/api/environments/test_environments_api.py
216+
checksum: 7cd53aff15a83f45f2520e989604cd87d44787bec1068ce94614735d1c57fdce
217+
- filename: tests/mock/environments/test_environments_mock.py
218+
checksum: 3b9d9b2b91d6145a8d4ed1ec962fa61eedf63229022d2df4ad695c265f84dc5b
219+
- filename: tests/unit/environments/test_environment_unit.py
220+
checksum: 3e362120a05306a0495a1103ea5a7c0152516b72703ab9d7609848aa15f90400
221+
- filename: contentstack_management/contentstack.py
222+
checksum: 89896be10ec6f47b814a0256dd6db9763202006180ec67e99d091f65c221f1d2
223+
version: ""
224+
fileignoreconfig:
225+
- filename: contentstack_management/environments/environments.py
226+
checksum: 68813381218aa355711e03dae52f87f367f103a05cf13475319a71f1984dbfca
227+
version: ""
228+
229+
fileignoreconfig:
230+
- filename: .github/workflows/release.yml
231+
checksum: 0b4d09c0534e318d8cc49a57a2547b2ce494d01d2c67c9016babd9d7b85c8ded
232+
- filename: contentstack_management/aliases/aliases.py
233+
checksum: a47832f67e73f47e953d94082c7457ccd74c407a5b12e11a44621f42b6ea3f13
234+
- filename: contentstack_management/assets/assets.py
235+
checksum: f5c471138d63b91e50a2137748dd31848c299fbd71e7127f58d9c4a57163b9bc
236+
version: ""
237+
238+
fileignoreconfig:
239+
- filename: tests/mock/locales/test_locale_mock.py
240+
checksum: 832eaede8c96d7a486b12d75492d792be240ab1d01be382cb7ed6a6521387dab
241+
- filename: tests/api/locales/test_locale_api.py
242+
checksum: 19632edc6c8fcbbf9284d7f9f205d813a0e97e89afed7cf28d35a010452cdbd4
243+
- filename: tests/unit/locales/test_locale_unit.py
244+
checksum: 7d272795c81f4ab17a9e47a4c208fd6cb40f86c52e304aa528b05cef16e86125
245+
version: ""
246+
fileignoreconfig:
247+
- filename: tests/mock/taxonomies/test_taxonomy_mock.py
248+
checksum: fab3e50d4f82a206b8d0250e0e48825def4505ff92d45f4883c230428fa350d9
249+
- filename: tests/api/taxonomies/test_taxonomy_api.py
250+
checksum: c02ddccee423f2f50e0428a3d151f35128a51c3a4a8b11e87a4f0042c83f3fa9
251+
- filename: tests/unit/taxonomies/test_taxonomy_unit.py
252+
checksum: 5dd2f73f683c293f71fd9002148747a7167a85981d6fb90e491cafddf7b96169
253+
version: ""

contentstack_management/__init__.py

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,53 @@
11
"""The __init__.py file that contains modules that need to import"""
22

3-
from contentstack_management import contentstack
3+
from .organizations.organization import Organization
4+
from .stack.stack import Stack
5+
from .user_session.user_session import UserSession
6+
from .users.user import User
7+
from .aliases.aliases import Alias
8+
from .assets.assets import Assets
9+
from .branches.branches import Branch
10+
from .content_types.content_type import ContentType
11+
from .global_fields.global_fields import GlobalFields
12+
from .webhooks.webhook import Webhook
13+
from .workflows.workflows import Workflows
14+
from .metadata.metadata import Metadata
15+
from .roles.roles import Roles
16+
from .auditlogs.auditlog import Auditlog
17+
from .environments.environment import Environment
18+
from .entries.entry import Entry
19+
from .contentstack import ContentstackClient, ContentstackRegion
20+
from ._api_client import _APIClient
21+
from .common import Parameter
22+
from ._errors import ArgumentException
23+
from .locale.locale import Locale
24+
from .taxonomies.taxonomy import Taxonomy
25+
26+
__all__ = (
27+
"ContentstackClient",
28+
"ContentstackRegion",
29+
"_APIClient",
30+
"Parameter",
31+
"ArgumentException",
32+
"Organization",
33+
"Stack",
34+
"UserSession",
35+
"User",
36+
"Alias",
37+
"Assets",
38+
"Branch",
39+
"ContentType",
40+
"GlobalFields",
41+
"Webhook",
42+
"Workflows",
43+
"Metadata",
44+
"Roles",
45+
"Auditlog",
46+
"Environment",
47+
"Entry",
48+
"Locale",
49+
"Taxonomy",
50+
)
451

552
__title__ = 'contentstack-management-python'
653
__author__ = 'ishaileshmishra'
@@ -12,4 +59,4 @@
1259
__api_version__ = 'v3'
1360
__endpoint__ = 'https://api.contentstack.io/v3/'
1461
__email__ = 'mobile@contentstack.com'
15-
__issues__ = 'customer_care@contentstack.com'
62+
__issues__ = 'support@contentstack.com'

contentstack_management/_constant.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import platform
2-
from sys import _version_info
2+
import sys
33

44

55
def _default_user_agent():
@@ -12,7 +12,7 @@ def _default_user_agent():
1212
header = {
1313
'sdk': {
1414
'name': 'contentstack-management.python',
15-
'version': _version_info
15+
'version': sys.version_info
1616
},
1717
'app': {
1818
'name': 'contentstack-management.python',
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from contentstack_management import contentstack

contentstack_management/aliases/aliases.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@ def find(self):
2525
:return: Returns all the aliases
2626
--------------------------------
2727
[Example:]
28-
>>> import contentstack
2928
>>> from contentstack_management import contentstack
30-
>>> branch = contentstack.ContentstackClient().stack(api_key='api_key').branch_alias()
31-
>>> response = branch.find()
29+
>>> alias = contentstack.ContentstackClient().stack(api_key='api_key').alias()
30+
>>> response = alias.find()
3231
--------------------------------
3332
"""
3433
return self.client.get(_path, headers=self.client.headers, params=self.params)
@@ -43,8 +42,8 @@ def fetch(self):
4342
4443
[Example:]
4544
>>> from contentstack_management import contentstack
46-
>>> branch = contentstack.ContentstackClient().stack(api_key='api_key').branch_alias('branch_alias_uid')
47-
>>> response = branch.fetch()
45+
>>> alias = contentstack.ContentstackClient().stack(api_key='api_key').alias('alias_uid')
46+
>>> response = alias.fetch()
4847
--------------------------------
4948
"""
5049
if self.alias_uid is None or '':
@@ -68,8 +67,8 @@ def assign(self, data):
6867
>>> "target_branch": "test"
6968
>>> }
7069
>>> }
71-
>>> branch = contentstack.ContentstackClient().stack(api_key='api_key').alias("alias_uid")
72-
>>> response = branch.assign(data)
70+
>>> alias = contentstack.ContentstackClient().stack(api_key='api_key').alias("alias_uid")
71+
>>> response = alias.assign(data)
7372
--------------------------------
7473
"""
7574
url = f"{_path}/{self.alias_uid}"
@@ -84,8 +83,8 @@ def delete(self):
8483
--------------------------------
8584
[Example:]
8685
>>> from contentstack_management import contentstack
87-
>>> branch = contentstack.ContentstackClient().stack(api_key='api_key').branch(branch_uid="branch_uid")
88-
>>> response = branch.delete()
86+
>>> alias = contentstack.ContentstackClient().stack(api_key='api_key').alias(alias_uid="alias_uid")
87+
>>> response = alias.delete()
8988
--------------------------------
9089
"""
9190
url = f"{_path}/{self.alias_uid}"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from contentstack_management import contentstack

contentstack_management/assets/assets.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@
55
the CRUD operations that can be performed on the API
66
"""
77
import json
8-
from contentstack_management.common import Parameter
9-
from tests.cred import get_credentials
10-
11-
credentials = get_credentials()
12-
api_key = credentials["api_key"]
8+
from ..common import Parameter
139

1410
class Assets(Parameter):
1511
"""
@@ -23,6 +19,7 @@ def __init__(self, client, asset_uid, branch):
2319
self.client = client
2420
self.asset_uid = asset_uid
2521
self.branch = branch
22+
self.api_key = self.client.headers['api_key']
2623
super().__init__(self.client)
2724

2825
def find(self):
@@ -224,7 +221,7 @@ def download(self):
224221
--------------------------------
225222
"""
226223

227-
url = f"assets/{api_key}/{self.asset_uid}"
224+
url = f"assets/{self.api_key}/{self.asset_uid}"
228225
return self.client.get(url, headers = self.client.headers, params = self.params)
229226

230227
def rte(self):
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from contentstack_management import contentstack
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from contentstack_management import contentstack

0 commit comments

Comments
 (0)