Skip to content

Commit

Permalink
Merge pull request #9 from Lumen5/topic-prioritize-prores
Browse files Browse the repository at this point in the history
Add ability to query an individual asset by ID. API similar to search.
  • Loading branch information
klardotsh committed Oct 4, 2018
2 parents 7604971 + ef5cc04 commit 22c8c3b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pygetty/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

__doc__ = 'Wrapper for Getty v3 API'
__author__ = 'Josh Klar <josh@lumen5.com>'
__version__ = '1.1.6'
__version__ = '1.1.7'
47 changes: 47 additions & 0 deletions pygetty/assets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from __future__ import absolute_import, unicode_literals

from copy import deepcopy

import requests

from .auth import flex_auth
from .search import asset_formatters
from .util import gen_v3_url


def individual_asset(
id,
asset_type,
detailed=False,
fields=set(),
query_params={},
auth_token_manager=None,
api_key=None,
client_secret=None,
):
assert asset_type in asset_formatters

auth_token_manager = flex_auth(
auth_token_manager=auth_token_manager,
api_key=api_key,
client_secret=client_secret,
)
params = deepcopy(query_params)
new_fields = fields.copy()

if detailed:
new_fields.add('detail_set')

params['fields'] = ','.join(new_fields)

url = gen_v3_url(asset_type, str(id))

res = requests.get(
url,
headers=auth_token_manager.request_headers(),
params=params,
)

res.raise_for_status()

return asset_formatters[asset_type](res.json())

0 comments on commit 22c8c3b

Please sign in to comment.