Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
12cda74
[LIB-837][WIP] working on custom sockets in LIB
opalczynski Aug 10, 2016
460006f
[LIB-837] Add missing docs about custom_sockets; move utils to anothe…
opalczynski Aug 11, 2016
5eca906
[LIB-837] add missing fields in doc string;
opalczynski Aug 11, 2016
c0f75cb
[LIB-837] correct documentation; add possibility to read all endpoint…
opalczynski Aug 12, 2016
e108b5a
[LIB-837] Correct after tests;
opalczynski Aug 12, 2016
5eab464
[LIB-837] another portion of corrects;
opalczynski Aug 12, 2016
1afcd9f
[LIB-837] correct tests again;
opalczynski Aug 12, 2016
48eb08e
[LIB-837] change tests instead of doing a magic in ModelField;
opalczynski Aug 12, 2016
4e2ee33
Language updates
MariuszWisniewski Aug 12, 2016
fe52e7a
[ci skip] readme
MariuszWisniewski Aug 12, 2016
7bc974a
[ci skip] Endpoints readme update
MariuszWisniewski Aug 15, 2016
bc71ad1
[LIB-837] revert ModelField on script in script endpoint model;
opalczynski Aug 16, 2016
327a3fc
[LIB-837] correct data passing on run methods;
opalczynski Aug 16, 2016
d50344b
[LIB-837] correct custom socket behaviour;
opalczynski Aug 16, 2016
c2ffd3a
Merge branch 'LIB-837' of github.com:Syncano/syncano-python into LIB-837
opalczynski Aug 16, 2016
42e4373
[LIB-837] corrects after qa;
opalczynski Aug 16, 2016
04c5ef6
[LIB-837] corrects after qa;
opalczynski Aug 16, 2016
9f5adba
[LIB-837] correct docs examples, polish the tests;
opalczynski Aug 16, 2016
69f3a11
[LIB-837] remove default custom socket in setupclass;
opalczynski Aug 16, 2016
3d1f4dd
[LIB-837] remove default custom socket in setupclass;
opalczynski Aug 16, 2016
d982fd0
[LIB-837] final test correction;
opalczynski Aug 16, 2016
8662e42
Update language
devintyler Aug 16, 2016
0864163
[LIB-837] add possibility to directly point instance name when gettin…
opalczynski Aug 18, 2016
9246b98
[LIB-837] change interface: publish to install in custom socket context;
opalczynski Aug 19, 2016
31c51b9
Merge branch 'LIB-837' of github.com:Syncano/syncano-python into LIB-837
opalczynski Aug 19, 2016
14f6ff7
[LIB-837] add status badges to README
opalczynski Aug 19, 2016
2372986
[LIB-837] small changes after CORE change;
opalczynski Aug 22, 2016
515e50b
[LIB-837] correct SocketEndpoint behaviour (run mainly);
opalczynski Aug 22, 2016
16795dd
[LIB-837] correct run in CustomSocket;
opalczynski Aug 22, 2016
b8c252f
[LIB-837] add possiblity to install from url;
opalczynski Aug 23, 2016
3cf2465
[LIB-837] update documentation for installing socket from url;
opalczynski Aug 23, 2016
ef39be6
[LIB-837] fixes after qa;
opalczynski Aug 24, 2016
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
Prev Previous commit
Next Next commit
[LIB-837] correct SocketEndpoint behaviour (run mainly);
  • Loading branch information
opalczynski committed Aug 22, 2016
commit 515e50b83e582be4ea83702f0797f3eb000ebcb2
13 changes: 5 additions & 8 deletions syncano/models/custom_sockets.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def run(self, endpoint_name, method='GET', data=None):
def _find_endpoint(self, endpoint_name):
endpoints = self.get_endpoints()
for endpoint in endpoints:
if endpoint_name == endpoint.name:
if '{}/{}'.format(self.name, endpoint_name) == endpoint.name:
return endpoint
raise SyncanoValueError('Endpoint {} not found.'.format(endpoint_name))

Expand Down Expand Up @@ -127,14 +127,15 @@ class Meta:

def run(self, method='GET', data=None):
endpoint_path = self.links.self
_, endpoint_name = self.name.split('/', 1)
connection = self._get_connection()
if not self._validate_method(method):
raise SyncanoValueError('Method: {} not specified in calls for this custom socket.'.format(method))
method = method.lower()
if method in ['get', 'delete']:
response = connection.request(method, endpoint_path)
response = connection.request(method, "{}/{}".format(endpoint_path, endpoint_name))
elif method in ['post', 'put', 'patch']:
response = connection.request(method, endpoint_path, data=data or {})
response = connection.request(method, "{}/{}".format(endpoint_path, endpoint_name), data=data or {})
else:
raise SyncanoValueError('Method: {} not supported.'.format(method))
return response
Expand All @@ -150,10 +151,6 @@ def get_all_endpoints(cls, instance_name=None):
return [cls(**endpoint) for endpoint in response['objects']]

def _validate_method(self, method):

methods = []
for call in self.calls:
methods.extend(call['methods'])
if '*' in methods or method in methods:
if '*' in self.allowed_methods or method in self.allowed_methods:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not return '*' in self.allowed_methods or method in self.allowed_methods ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because personally do not like long lines which return something :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm convinced.

return True
return False