Skip to content

Commit

Permalink
Merge pull request #177 from Syncano/develop
Browse files Browse the repository at this point in the history
Release - version 5.0.0
  • Loading branch information
opalczynski committed Mar 23, 2016
2 parents ebe4660 + 9a35926 commit 66a2330
Show file tree
Hide file tree
Showing 52 changed files with 788 additions and 594 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ junit
reports
run_it.py
syncano.egg-info
.tox/*
test
2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
line_length=120
multi_line_output=3
default_section=THIRDPARTY
skip=base.py
skip=base.py,.tox,conf.py
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Syncano
Python QuickStart Guide
-----------------------

You can find quick start on installing and using Syncano's Python library in our [documentation](http://docs.syncano.com/v1.0/docs/python).
You can find quick start on installing and using Syncano's Python library in our [documentation](http://docs.syncano.com/docs/python).

For more detailed information on how to use Syncano and its features - our [Developer Manual](http://docs.syncano.com/v1.0/docs/getting-started-with-syncano) should be very helpful.
For more detailed information on how to use Syncano and its features - our [Developer Manual](http://docs.syncano.com/docs/getting-started-with-syncano) should be very helpful.

In case you need help working with the library - email us at [email protected] - we will be happy to help!

Expand Down
6 changes: 4 additions & 2 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ machine:
dependencies:
pre:
- pip install -U setuptools
- pip install -r requirements.txt
- pip install -r requirements-test.txt
post:
- pyenv local 3.4.3 2.7.6

test:
override:
- ./run_tests.sh
- tox

general:
artifacts:
Expand Down
4 changes: 4 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import sphinx_rtd_theme

sys.path.insert(1, dirname(dirname(dirname(abspath(__file__)))))
from syncano.models.fields import RelatedManagerField


needs_sphinx = '1.0'
extensions = [
Expand Down Expand Up @@ -108,3 +110,5 @@

autodoc_member_order = 'bysource'
highlight_language = 'python'

RelatedManagerField.__get__ = lambda self, *args, **kwargs: self
1 change: 0 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Contents:

getting_started
interacting
models
refs/syncano


Expand Down
10 changes: 0 additions & 10 deletions docs/source/models.rst

This file was deleted.

7 changes: 7 additions & 0 deletions docs/source/refs/syncano.models.accounts.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
syncano.models.accounts
=======================

.. automodule:: syncano.models.accounts
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/refs/syncano.models.archetypes.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
syncano.models.archetypes
=========================

.. automodule:: syncano.models.archetypes
:members:
:undoc-members:
:show-inheritance:
7 changes: 0 additions & 7 deletions docs/source/refs/syncano.models.base.rst

This file was deleted.

7 changes: 7 additions & 0 deletions docs/source/refs/syncano.models.billing.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
syncano.models.billing
======================

.. automodule:: syncano.models.billing
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/refs/syncano.models.channels.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
syncano.models.channels
=======================

.. automodule:: syncano.models.channels
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/refs/syncano.models.classes.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
syncano.models.classes
======================

.. automodule:: syncano.models.classes
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/refs/syncano.models.custom_response.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
syncano.models.custom_response
==============================

.. automodule:: syncano.models.custom_response
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/refs/syncano.models.data_views.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
syncano.models.data_views
=========================

.. automodule:: syncano.models.data_views
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/refs/syncano.models.incentives.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
syncano.models.incentives
=========================

.. automodule:: syncano.models.incentives
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/refs/syncano.models.instances.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
syncano.models.instances
========================

.. automodule:: syncano.models.instances
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/refs/syncano.models.push_notification.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
syncano.models.push_notification
================================

.. automodule:: syncano.models.push_notification
:members:
:undoc-members:
:show-inheritance:
14 changes: 12 additions & 2 deletions docs/source/refs/syncano.models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,21 @@ Submodules

.. toctree::

syncano.models.base
syncano.models.fields
syncano.models.manager
syncano.models.accounts
syncano.models.archetypes
syncano.models.billing
syncano.models.channels
syncano.models.classes
syncano.models.custom_response
syncano.models.data_views
syncano.models.incentives
syncano.models.instances
syncano.models.fields
syncano.models.options
syncano.models.push_notification
syncano.models.registry
syncano.models.traces

Module contents
---------------
Expand Down
7 changes: 7 additions & 0 deletions docs/source/refs/syncano.models.traces.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
syncano.models.traces
=====================

.. automodule:: syncano.models.traces
:members:
:undoc-members:
:show-inheritance:
1 change: 1 addition & 0 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tox==2.3.1
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ python-slugify==0.1.0
requests==2.7.0
six==1.9.0
validictory==1.0.0
wsgiref==0.1.2
8 changes: 4 additions & 4 deletions syncano/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os

__title__ = 'Syncano Python'
__version__ = '4.2.0'
__version__ = '5.0.0'
__author__ = "Daniel Kopka, Michal Kobus, and Sebastian Opalczynski"
__credits__ = ["Daniel Kopka",
"Michal Kobus",
Expand Down Expand Up @@ -64,13 +64,13 @@ def connect(*args, **kwargs):
:return: A models registry
Usage::
# Admin login
connection = syncano.connect(email='', password='')
# OR
connection = syncano.connect(api_key='')
# OR
connection = syncano.connect(social_backend='github',
token='sfdsdfsdf')
connection = syncano.connect(social_backend='github', token='sfdsdfsdf')
# User login
connection = syncano.connect(username='', password='', api_key='', instance_name='')
Expand All @@ -85,5 +85,5 @@ def connect(*args, **kwargs):
instance = kwargs.get('instance_name', INSTANCE)

if instance is not None:
registry.set_default_instance(instance)
registry.set_used_instance(instance)
return registry
4 changes: 2 additions & 2 deletions syncano/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,9 @@ def make_request(self, method_name, path, **kwargs):
files = data.pop('files', None)

if files is None:
files = {k: v for k, v in data.iteritems() if isinstance(v, file)}
files = {k: v for k, v in six.iteritems(data) if hasattr(v, 'read')}
if data:
kwargs['data'] = data = {k: v for k, v in data.iteritems() if k not in files}
kwargs['data'] = {k: v for k, v in six.iteritems(data) if k not in files}

params = self.build_params(kwargs)
method = getattr(self.session, method_name.lower(), None)
Expand Down
31 changes: 9 additions & 22 deletions syncano/models/accounts.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from __future__ import unicode_literals


from . import fields
from .base import Model
Expand All @@ -9,17 +9,14 @@

class Admin(Model):
"""
OO wrapper around instance admins `endpoint <http://docs.syncano.com/v4.0/docs/v1instancesinstanceadmins>`_.
OO wrapper around instance admins `link <http://docs.syncano.com/docs/administrators>`_.
:ivar first_name: :class:`~syncano.models.fields.StringField`
:ivar last_name: :class:`~syncano.models.fields.StringField`
:ivar email: :class:`~syncano.models.fields.EmailField`
:ivar role: :class:`~syncano.models.fields.ChoiceField`
:ivar links: :class:`~syncano.models.fields.HyperlinkedField`
"""
LINKS = (
{'type': 'detail', 'name': 'self'},
)
ROLE_CHOICES = (
{'display_name': 'full', 'value': 'full'},
{'display_name': 'write', 'value': 'write'},
Expand All @@ -30,7 +27,7 @@ class Admin(Model):
last_name = fields.StringField(read_only=True, required=False)
email = fields.EmailField(read_only=True, required=False)
role = fields.ChoiceField(choices=ROLE_CHOICES)
links = fields.HyperlinkedField(links=LINKS)
links = fields.LinksField()

class Meta:
parent = Instance
Expand All @@ -52,10 +49,6 @@ class Profile(DataObjectMixin, Object):

PREDEFINED_CLASS_NAME = 'user_profile'

LINKS = (
{'type': 'detail', 'name': 'self'},
)

PERMISSIONS_CHOICES = (
{'display_name': 'None', 'value': 'none'},
{'display_name': 'Read', 'value': 'read'},
Expand All @@ -71,7 +64,7 @@ class Profile(DataObjectMixin, Object):
channel = fields.StringField(required=False)
channel_room = fields.StringField(required=False, max_length=64)

links = fields.HyperlinkedField(links=LINKS)
links = fields.LinksField()
created_at = fields.DateTimeField(read_only=True, required=False)
updated_at = fields.DateTimeField(read_only=True, required=False)

Expand All @@ -93,7 +86,7 @@ class Meta:

class User(Model):
"""
OO wrapper around users `endpoint <http://docs.syncano.com/v4.0/docs/user-management>`_.
OO wrapper around users `link <http://docs.syncano.com/docs/user-management>`_.
:ivar username: :class:`~syncano.models.fields.StringField`
:ivar password: :class:`~syncano.models.fields.StringField`
Expand All @@ -102,17 +95,14 @@ class User(Model):
:ivar created_at: :class:`~syncano.models.fields.DateTimeField`
:ivar updated_at: :class:`~syncano.models.fields.DateTimeField`
"""
LINKS = (
{'type': 'detail', 'name': 'self'},
)

username = fields.StringField(max_length=64, required=True)
password = fields.StringField(read_only=False, required=True)
user_key = fields.StringField(read_only=True, required=False)

profile = fields.ModelField('Profile')
profile = fields.ModelField('Profile', read_only=False, default={})

links = fields.HyperlinkedField(links=LINKS)
links = fields.LinksField()
created_at = fields.DateTimeField(read_only=True, required=False)
updated_at = fields.DateTimeField(read_only=True, required=False)

Expand Down Expand Up @@ -166,22 +156,19 @@ def remove_from_group(self, group_id):

class Group(Model):
"""
OO wrapper around groups `endpoint <http://docs.syncano.com/v4.0/docs/groups>`_.
OO wrapper around groups `link <http://docs.syncano.com/docs/groups>`_.
:ivar label: :class:`~syncano.models.fields.StringField`
:ivar description: :class:`~syncano.models.fields.StringField`
:ivar links: :class:`~syncano.models.fields.HyperlinkedField`
:ivar created_at: :class:`~syncano.models.fields.DateTimeField`
:ivar updated_at: :class:`~syncano.models.fields.DateTimeField`
"""
LINKS = (
{'type': 'detail', 'name': 'self'},
)

label = fields.StringField(max_length=64, required=True)
description = fields.StringField(read_only=False, required=False)

links = fields.HyperlinkedField(links=LINKS)
links = fields.LinksField()
created_at = fields.DateTimeField(read_only=True, required=False)
updated_at = fields.DateTimeField(read_only=True, required=False)

Expand Down
7 changes: 4 additions & 3 deletions syncano/models/archetypes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from __future__ import unicode_literals


import inspect

Expand Down Expand Up @@ -39,7 +39,7 @@ def __new__(cls, name, bases, attrs):
new_class.add_to_class(n, v)

for abstract in abstracts:
for n, v in abstract.__dict__.iteritems():
for n, v in six.iteritems(abstract.__dict__):
if isinstance(v, fields.Field) or n in ['LINKS']: # extend this condition if required;
new_class.add_to_class(n, v)

Expand Down Expand Up @@ -83,6 +83,7 @@ def build_doc(cls, name, meta):
class Model(six.with_metaclass(ModelMetaclass)):
"""Base class for all models.
"""

def __init__(self, **kwargs):
self.is_lazy = kwargs.pop('is_lazy', False)
self._raw_data = {}
Expand Down Expand Up @@ -174,7 +175,7 @@ def delete(self, **kwargs):
connection = self._get_connection(**kwargs)
connection.request('DELETE', endpoint)
if self.__class__.__name__ == 'Instance': # avoid circular import;
registry.clear_instance_name()
registry.clear_used_instance()
self._raw_data = {}

def reload(self, **kwargs):
Expand Down
Loading

0 comments on commit 66a2330

Please sign in to comment.