cli2 4.2.3__tar.gz → 4.2.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cli2-4.2.3/cli2.egg-info → cli2-4.2.5}/PKG-INFO +1 -1
- {cli2-4.2.3 → cli2-4.2.5}/cli2/client.py +33 -16
- {cli2-4.2.3 → cli2-4.2.5/cli2.egg-info}/PKG-INFO +1 -1
- {cli2-4.2.3 → cli2-4.2.5}/setup.py +1 -1
- {cli2-4.2.3 → cli2-4.2.5}/MANIFEST.in +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/README.rst +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/classifiers.txt +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/cli2/__init__.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/cli2/ansible/__init__.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/cli2/ansible/action.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/cli2/ansible/playbook.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/cli2/ansible/variables.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/cli2/asyncio.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/cli2/cli.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/cli2/cli2.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/cli2/colors.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/cli2/configuration.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/cli2/decorators.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/cli2/display.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/cli2/examples/__init__.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/cli2/examples/client.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/cli2/examples/conf.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/cli2/examples/example.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/cli2/examples/example_obj.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/cli2/examples/nesting.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/cli2/examples/obj.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/cli2/examples/obj2.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/cli2/examples/test.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/cli2/lock.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/cli2/log.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/cli2/node.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/cli2/sphinx.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/cli2/table.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/cli2/test.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/cli2.egg-info/SOURCES.txt +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/cli2.egg-info/dependency_links.txt +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/cli2.egg-info/entry_points.txt +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/cli2.egg-info/requires.txt +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/cli2.egg-info/top_level.txt +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/setup.cfg +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/tests/test_ansible.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/tests/test_ansible_variables.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/tests/test_asyncio.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/tests/test_cli.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/tests/test_client.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/tests/test_command.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/tests/test_configuration.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/tests/test_decorators.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/tests/test_display.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/tests/test_entry_point.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/tests/test_group.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/tests/test_inject.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/tests/test_lock.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/tests/test_node.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/tests/test_restful.py +0 -0
- {cli2-4.2.3 → cli2-4.2.5}/tests/test_table.py +0 -0
|
@@ -923,12 +923,16 @@ class Model(metaclass=ModelMetaclass):
|
|
|
923
923
|
await obj.hydrate()
|
|
924
924
|
return obj
|
|
925
925
|
|
|
926
|
-
async def hydrate(self):
|
|
926
|
+
async def hydrate(self, data=None):
|
|
927
927
|
"""
|
|
928
928
|
Refresh data with GET requset on :py:attr:`url_detail`
|
|
929
|
+
|
|
930
|
+
:param data: Data dict, otherwise will get it
|
|
929
931
|
"""
|
|
930
|
-
|
|
931
|
-
|
|
932
|
+
if data is None:
|
|
933
|
+
response = await self.client.get(self.url)
|
|
934
|
+
data = response.json()
|
|
935
|
+
self.data.update(data)
|
|
932
936
|
self.changed_fields = dict()
|
|
933
937
|
|
|
934
938
|
async def save(self):
|
|
@@ -940,18 +944,9 @@ class Model(metaclass=ModelMetaclass):
|
|
|
940
944
|
You might want to override this.
|
|
941
945
|
"""
|
|
942
946
|
if self.id_value:
|
|
943
|
-
|
|
944
|
-
else:
|
|
945
|
-
response = await self.instanciate()
|
|
946
|
-
|
|
947
|
-
try:
|
|
948
|
-
data = response.json()
|
|
949
|
-
except json.JSONDecodeError:
|
|
950
|
-
pass
|
|
947
|
+
return await self.update()
|
|
951
948
|
else:
|
|
952
|
-
self.
|
|
953
|
-
|
|
954
|
-
return response
|
|
949
|
+
return await self.instanciate()
|
|
955
950
|
|
|
956
951
|
async def instanciate(self):
|
|
957
952
|
"""
|
|
@@ -962,7 +957,16 @@ class Model(metaclass=ModelMetaclass):
|
|
|
962
957
|
"""
|
|
963
958
|
if not self.url_list:
|
|
964
959
|
raise Exception(f'{type(self).__name__}.url_list not set')
|
|
965
|
-
|
|
960
|
+
response = await self.client.post(self.url_list, json=self.data)
|
|
961
|
+
|
|
962
|
+
try:
|
|
963
|
+
data = response.json()
|
|
964
|
+
except json.JSONDecodeError:
|
|
965
|
+
pass
|
|
966
|
+
else:
|
|
967
|
+
await self.hydrate(data)
|
|
968
|
+
|
|
969
|
+
return response
|
|
966
970
|
|
|
967
971
|
async def update(self):
|
|
968
972
|
"""
|
|
@@ -971,7 +975,16 @@ class Model(metaclass=ModelMetaclass):
|
|
|
971
975
|
|
|
972
976
|
You might want to override this.
|
|
973
977
|
"""
|
|
974
|
-
|
|
978
|
+
response = await self.client.post(self.url, json=self.data)
|
|
979
|
+
|
|
980
|
+
try:
|
|
981
|
+
data = response.json()
|
|
982
|
+
except json.JSONDecodeError:
|
|
983
|
+
pass
|
|
984
|
+
else:
|
|
985
|
+
await self.hydrate(data)
|
|
986
|
+
|
|
987
|
+
return response
|
|
975
988
|
|
|
976
989
|
@property
|
|
977
990
|
def id_value(self):
|
|
@@ -1757,6 +1770,10 @@ class Client(metaclass=ClientMetaclass):
|
|
|
1757
1770
|
kwargs[key] = yaml.safe_load(fh.read())
|
|
1758
1771
|
return await self.request(method, url, *args, **kwargs)
|
|
1759
1772
|
|
|
1773
|
+
async def patch(self, url, *args, **kwargs):
|
|
1774
|
+
""" PATCH Request """
|
|
1775
|
+
return await self.request('PATCH', url, *args, **kwargs)
|
|
1776
|
+
|
|
1760
1777
|
async def post(self, url, *args, **kwargs):
|
|
1761
1778
|
""" POST Request """
|
|
1762
1779
|
return await self.request('POST', url, *args, **kwargs)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|