Skip to content

Commit 5a7f3e3

Browse files
Merge pull request #1 from contentstack/dev
Dev
2 parents 768e54d + 82af963 commit 5a7f3e3

21 files changed

+289
-273
lines changed

.DS_Store

0 Bytes
Binary file not shown.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ wheels/
2424
.installed.cfg
2525
*.egg
2626
MANIFEST
27+
.DS_Store
28+
.DS_Store?
2729

2830
# PyInstaller
2931
# Usually these files are written by a python script from a template

.vscode/launch.json

Lines changed: 0 additions & 28 deletions
This file was deleted.

.vscode/settings.json

Lines changed: 0 additions & 19 deletions
This file was deleted.

READ.ME.md

Whitespace-only changes.

contentstack/HTTPConnection.py

Lines changed: 0 additions & 49 deletions
This file was deleted.

contentstack/__init__.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# __init__.py
4+
# Contentstack
5+
# Created by Shailesh on 22/06/19.
6+
# Copyright (c) 2012 - 2019 Contentstack. All rights reserved.
7+
8+
# [MIT License] :: Permission is hereby granted, free of charge, to any person
9+
# obtaining a copy of this software and associated documentation files (the "Software"),
10+
# to deal in the Software without restriction, including without limitation the rights
11+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
# copies of the Software, and to permit persons to whom the Software is
13+
# furnished to do so, subject to the following conditions:
14+
15+
# The above copyright notice and this permission notice shall be included in all
16+
# copies or substantial portions of the Software.
17+
18+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24+
# SOFTWARE.
25+
26+
"""Export module packages."""
27+
28+
from .entry import Entry
29+
from .asset import Asset
30+
from .asset_library import AssetLibrary
31+
from .config import Config
32+
from .sync_stack import SyncStack
33+
from .query_result import QueryResult
34+
from .content_type import ContentType
35+
from .entry_model import EntryModel
36+
from .errors import HTTPError, ConfigError
37+
from .group import Group
38+
from .http_request import HTTPRequestConnection
39+
40+
__author__ = 'contentstack - (www.github.con/contentstack)'
41+
__email__ = 'shailesh.mishra@contentstack.com'
42+
__version__ = '0.0.1'
43+
__endpoint__ = 'cdn.contentstack.io'

contentstack/asser_model.py

Lines changed: 0 additions & 33 deletions
This file was deleted.

contentstack/asset_library.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828

2929
class AssetLibrary():
30-
logging.info("Asset library")
3130

3231
def __init__(self):
33-
logging.info('Asset initialised')
32+
logging.info('Asset initialised')

contentstack/config.py

Lines changed: 29 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -25,40 +25,34 @@
2525

2626
import logging
2727

28-
class Config(object):
29-
30-
31-
def __init__(self):
32-
self.host_url = 'cdn.contentstack.io'
33-
self.api_version = 'v3'
34-
self.environment = None
35-
self.SDK_VERSION = 0.0.1
36-
self.SDK_NAME = 'contentstack-python'
37-
38-
39-
def set_host(self, host_url= 'cdn.contentstack.io'):
40-
logging.info("set host")
41-
if host_url != None:
42-
self.url = host_url
43-
return self
44-
45-
46-
def set_environment(self, environment):
47-
logging.info("set environment")
48-
if environment != None:
49-
self.environment = environment
50-
return self
51-
52-
def get_host(self):
53-
logging.info('getting host url')
54-
return self.host_url
55-
56-
57-
def get_version(self):
58-
logging.info('getting api version')
59-
return self.api_version
6028

29+
class Config(object):
6130

62-
def get_environment(self):
63-
logging.info('get invironment')
64-
return self.environment
31+
def __init__(self, host_url: str = 'cdn.contentstack.io'):
32+
self.host_url = host_url
33+
self.api_version: str = 'v3'
34+
self.http_protocol: str = 'https://'
35+
36+
def set_host(self, host_url=None):
37+
logging.info("set host", host_url)
38+
self.host_url = host_url
39+
return self
40+
41+
def get_host(self):
42+
logging.info('getting host url', self.host_url)
43+
return self.host_url
44+
45+
def get_version(self):
46+
logging.info('getting api version', self.api_version)
47+
return self.api_version
48+
49+
def get_http_protocol(self):
50+
logging.info('get http protocol', self.http_protocol)
51+
return self.http_protocol
52+
53+
def get_endpoint(self, url_path):
54+
api_version: str = self.get_version()
55+
host_url = self.get_host()
56+
http_protocol = self.get_http_protocol()
57+
config_url = "{0}{1}/{2}/{3}".format(http_protocol, host_url, api_version, url_path)
58+
return config_url

0 commit comments

Comments
 (0)