Skip to content

Commit

Permalink
Allow return_only arg in TableModel.get
Browse files Browse the repository at this point in the history
  • Loading branch information
rbw committed Oct 14, 2020
1 parent baefce3 commit 15d287e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions aiosnow/models/attachment/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from aiosnow.models.table import TableModel
from aiosnow.query import Condition, Selector
from aiosnow.request import methods
from aiosnow.request.response import ClientResponse
from aiosnow.request.response import ClientResponse, Response

from .file import FileHandler, FileReader, FileWriter

Expand Down Expand Up @@ -63,14 +63,17 @@ async def download(

return f

async def update(self, selection: Union[Condition, str], payload: dict) -> Response:
pass

async def upload(
self, table_name: str, record_sys_id: str, file_name: str, **kwargs: Any
) -> ClientResponse:
with FileReader(file_name, **kwargs) as f:
content = await self.loop.run_in_executor(self.io_pool_exc, f.read)

content_type, _ = guess_type(file_name)
response = await self._session.request(
response = await self.request(
methods.POST,
url=f"{self._api_url}/file",
params=dict(
Expand All @@ -79,5 +82,4 @@ async def upload(
headers={"Content-type": content_type},
data=content,
)

return response
1 change: 1 addition & 0 deletions aiosnow/models/table/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ async def get(

return await self.request(
methods.GET,
fields=kwargs.pop("return_only", self._config["return_only"]),
query=select(selection).sysparms,
nested_fields=self.nested_fields,
**kwargs,
Expand Down

0 comments on commit 15d287e

Please sign in to comment.