Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 29 additions & 71 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,81 +1,39 @@
# this file is *not* meant to cover or endorse the use of GitHub Actions, but rather to
# help make automated releases for this project
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries

name: Release
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Upload Python Package

on:
release:
types: [created]
types: [published]

permissions:
contents: read

jobs:
build-and-publish:
runs-on: ubuntu-22.04
deploy:

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v3
with:
python-version: "3.10.11"
- name: Install build dependencies
run: python -m pip install -U setuptools wheel build
- name: Build
run: python -m build .
- name: Publish
uses: pypa/gh-action-pypi-publish@master
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
password: ${{ secrets.pypi_test_password }}
skip_existing: true

generate_and_upload_coverage:
name: Generate and Upload Coverage Report
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
python-version: ["3.10.11"]

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Update Pip
run: pip install --upgrade pip
pip install --use-pep517

- name: Create and activate virtual environment
run: |
python -m venv venv
source venv/bin/activate

- name: Install build dependencies
run: python -m pip install -U setuptools wheel build

- name: Install dependencies
run: pip install -r requirements.txt

- name: Run tests and generate coverage report
run: |
coverage run -m pytest
coverage report -m > coverage.txt

- name: Archive coverage report
uses: actions/upload-artifact@v2
with:
name: coverage-report
path: coverage.txt

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.Test_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.Test_AWS_SECRET_ACCESS_KEY }}
aws-region: <your_aws_region> # Replace with your actual AWS region

- name: Upload coverage report to S3
run: aws s3 cp coverage.txt s3://<your_bucket_name>/coverage.txt
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
26 changes: 26 additions & 0 deletions .talismanrc
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,29 @@ fileignoreconfig:
- filename: contentstack_management/environments/environments.py
checksum: 68813381218aa355711e03dae52f87f367f103a05cf13475319a71f1984dbfca
version: ""

fileignoreconfig:
- filename: .github/workflows/release.yml
checksum: 0b4d09c0534e318d8cc49a57a2547b2ce494d01d2c67c9016babd9d7b85c8ded
- filename: contentstack_management/aliases/aliases.py
checksum: a47832f67e73f47e953d94082c7457ccd74c407a5b12e11a44621f42b6ea3f13
- filename: contentstack_management/assets/assets.py
checksum: f5c471138d63b91e50a2137748dd31848c299fbd71e7127f58d9c4a57163b9bc
version: ""

fileignoreconfig:
- filename: tests/mock/locales/test_locale_mock.py
checksum: 832eaede8c96d7a486b12d75492d792be240ab1d01be382cb7ed6a6521387dab
- filename: tests/api/locales/test_locale_api.py
checksum: 19632edc6c8fcbbf9284d7f9f205d813a0e97e89afed7cf28d35a010452cdbd4
- filename: tests/unit/locales/test_locale_unit.py
checksum: 7d272795c81f4ab17a9e47a4c208fd6cb40f86c52e304aa528b05cef16e86125
version: ""
fileignoreconfig:
- filename: tests/mock/taxonomies/test_taxonomy_mock.py
checksum: fab3e50d4f82a206b8d0250e0e48825def4505ff92d45f4883c230428fa350d9
- filename: tests/api/taxonomies/test_taxonomy_api.py
checksum: c02ddccee423f2f50e0428a3d151f35128a51c3a4a8b11e87a4f0042c83f3fa9
- filename: tests/unit/taxonomies/test_taxonomy_unit.py
checksum: 5dd2f73f683c293f71fd9002148747a7167a85981d6fb90e491cafddf7b96169
version: ""
49 changes: 48 additions & 1 deletion contentstack_management/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,53 @@
"""The __init__.py file that contains modules that need to import"""

from contentstack_management import contentstack
from .organizations.organization import Organization
from .stack.stack import Stack
from .user_session.user_session import UserSession
from .users.user import User
from .aliases.aliases import Alias
from .assets.assets import Assets
from .branches.branches import Branch
from .content_types.content_type import ContentType
from .global_fields.global_fields import GlobalFields
from .webhooks.webhook import Webhook
from .workflows.workflows import Workflows
from .metadata.metadata import Metadata
from .roles.roles import Roles
from .auditlogs.auditlog import Auditlog
from .environments.environment import Environment
from .entries.entry import Entry
from .contentstack import ContentstackClient, ContentstackRegion
from ._api_client import _APIClient
from .common import Parameter
from ._errors import ArgumentException
from .locale.locale import Locale
from .taxonomies.taxonomy import Taxonomy

__all__ = (
"ContentstackClient",
"ContentstackRegion",
"_APIClient",
"Parameter",
"ArgumentException",
"Organization",
"Stack",
"UserSession",
"User",
"Alias",
"Assets",
"Branch",
"ContentType",
"GlobalFields",
"Webhook",
"Workflows",
"Metadata",
"Roles",
"Auditlog",
"Environment",
"Entry",
"Locale",
"Taxonomy",
)

__title__ = 'contentstack-management-python'
__author__ = 'ishaileshmishra'
Expand Down
4 changes: 2 additions & 2 deletions contentstack_management/_constant.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import platform
from sys import _version_info
import sys


def _default_user_agent():
Expand All @@ -12,7 +12,7 @@ def _default_user_agent():
header = {
'sdk': {
'name': 'contentstack-management.python',
'version': _version_info
'version': sys.version_info
},
'app': {
'name': 'contentstack-management.python',
Expand Down
1 change: 1 addition & 0 deletions contentstack_management/aliases/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from contentstack_management import contentstack
17 changes: 8 additions & 9 deletions contentstack_management/aliases/aliases.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ def find(self):
:return: Returns all the aliases
--------------------------------
[Example:]
>>> import contentstack
>>> from contentstack_management import contentstack
>>> branch = contentstack.ContentstackClient().stack(api_key='api_key').branch_alias()
>>> response = branch.find()
>>> alias = contentstack.ContentstackClient().stack(api_key='api_key').alias()
>>> response = alias.find()
--------------------------------
"""
return self.client.get(_path, headers=self.client.headers, params=self.params)
Expand All @@ -43,8 +42,8 @@ def fetch(self):

[Example:]
>>> from contentstack_management import contentstack
>>> branch = contentstack.ContentstackClient().stack(api_key='api_key').branch_alias('branch_alias_uid')
>>> response = branch.fetch()
>>> alias = contentstack.ContentstackClient().stack(api_key='api_key').alias('alias_uid')
>>> response = alias.fetch()
--------------------------------
"""
if self.alias_uid is None or '':
Expand All @@ -68,8 +67,8 @@ def assign(self, data):
>>> "target_branch": "test"
>>> }
>>> }
>>> branch = contentstack.ContentstackClient().stack(api_key='api_key').alias("alias_uid")
>>> response = branch.assign(data)
>>> alias = contentstack.ContentstackClient().stack(api_key='api_key').alias("alias_uid")
>>> response = alias.assign(data)
--------------------------------
"""
url = f"{_path}/{self.alias_uid}"
Expand All @@ -84,8 +83,8 @@ def delete(self):
--------------------------------
[Example:]
>>> from contentstack_management import contentstack
>>> branch = contentstack.ContentstackClient().stack(api_key='api_key').branch(branch_uid="branch_uid")
>>> response = branch.delete()
>>> alias = contentstack.ContentstackClient().stack(api_key='api_key').alias(alias_uid="alias_uid")
>>> response = alias.delete()
--------------------------------
"""
url = f"{_path}/{self.alias_uid}"
Expand Down
1 change: 1 addition & 0 deletions contentstack_management/assets/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from contentstack_management import contentstack
9 changes: 3 additions & 6 deletions contentstack_management/assets/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@
the CRUD operations that can be performed on the API
"""
import json
from contentstack_management.common import Parameter
from tests.cred import get_credentials

credentials = get_credentials()
api_key = credentials["api_key"]
from ..common import Parameter

class Assets(Parameter):
"""
Expand All @@ -23,6 +19,7 @@ def __init__(self, client, asset_uid, branch):
self.client = client
self.asset_uid = asset_uid
self.branch = branch
self.api_key = self.client.headers['api_key']
super().__init__(self.client)

def find(self):
Expand Down Expand Up @@ -224,7 +221,7 @@ def download(self):
--------------------------------
"""

url = f"assets/{api_key}/{self.asset_uid}"
url = f"assets/{self.api_key}/{self.asset_uid}"
return self.client.get(url, headers = self.client.headers, params = self.params)

def rte(self):
Expand Down
1 change: 1 addition & 0 deletions contentstack_management/auditlogs/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from contentstack_management import contentstack
1 change: 1 addition & 0 deletions contentstack_management/branches/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from contentstack_management import contentstack
1 change: 1 addition & 0 deletions contentstack_management/content_types/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from contentstack_management import contentstack
4 changes: 2 additions & 2 deletions contentstack_management/content_types/content_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import json

from contentstack_management.common import Parameter
from ..entry.entry import Entry
from ..entries import entry

_path = 'content_types'

Expand Down Expand Up @@ -344,4 +344,4 @@ def imports(self, file_path):
def entry(self, entry_uid=None):
if self.content_type_uid is None:
raise Exception('Content type uid is required')
return Entry(self.client, self.content_type_uid, entry_uid)
return entry.Entry(self.client, self.content_type_uid, entry_uid)
12 changes: 6 additions & 6 deletions contentstack_management/contentstack.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

from contentstack_management import contentstack
from enum import Enum
from ._api_client import _APIClient
from .organizations import organizations
from .stack import stack
from .user_session import user_session
from .users import user
from contentstack_management.organizations import organization
from contentstack_management.stack import stack
from contentstack_management.user_session import user_session
from contentstack_management.users import user

version = '0.0.1'

Expand Down Expand Up @@ -81,7 +81,7 @@ def user(self):
return user.User(self.client)

def organizations(self, organization_uid: str = None):
return organizations.Organization(self.client, organization_uid)
return organization.Organization(self.client, organization_uid)

def stack(self, api_key: str = None):
return stack.Stack(self.client, api_key)
1 change: 1 addition & 0 deletions contentstack_management/entries/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from contentstack_management import contentstack
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def fetch(self):
def create(self, data: dict):
"""
The Add an environment call will add a publishing environment for a stack.
:param data: The `data` parameter is the payload that you want to send in the request body. It
:param data: The data parameter is the payload that you want to send in the request body. It
should be a dictionary or a JSON serializable object that you want to send as the request body
:return: Json, with environments details.

Expand Down Expand Up @@ -90,7 +90,7 @@ def create(self, data: dict):
def update(self, data: dict):
"""
The Update environment call will update the details of an existing publishing environment for a stack.
:param data: The `data` parameter is the data that you want to update. It should be a dictionary
:param data: The data parameter is the data that you want to update. It should be a dictionary
or an object that can be serialized to JSON
:return: Json, with updated environments details.
-------------------------------
Expand Down
1 change: 1 addition & 0 deletions contentstack_management/global_fields/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from contentstack_management import contentstack
1 change: 1 addition & 0 deletions contentstack_management/locale/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from contentstack_management import contentstack
Loading