Skip to content

Commit 7716b41

Browse files
committed
Raise NoPermission exception when the user does not have download access for a quad
1 parent ca4849d commit 7716b41

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

planet/api/client.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import json
1717
from .dispatch import RequestsDispatcher
1818
from . import auth
19-
from .exceptions import (InvalidIdentity, APIException)
19+
from .exceptions import (InvalidIdentity, APIException, NoPermission)
2020
from . import models
2121
from . import filters
2222

@@ -357,14 +357,18 @@ def download_quad(self, quad, callback=None):
357357
be invoked asynchronously. Otherwise it is up to the caller to handle
358358
the response Body.
359359
360-
:param asset dict: A mosaic quad representation from the API
360+
:param quad dict: A mosaic quad representation from the API
361361
:param callback: An optional function to aysnchronsously handle the
362362
download. See :py:func:`planet.api.write_to_file`
363363
:returns: :py:Class:`planet.api.models.Response` containing a
364364
:py:Class:`planet.api.models.Body` of the asset.
365365
:raises planet.api.exceptions.APIException: On API error.
366366
'''
367-
download_url = quad['_links']['download']
367+
try:
368+
download_url = quad['_links']['download']
369+
except KeyError:
370+
msg = 'You do not have download permissions for quad {}'
371+
raise NoPermission(msg.format(quad['id']))
368372
return self._get(download_url, models.Body, callback=callback)
369373

370374
def check_analytics_connection(self):

0 commit comments

Comments
 (0)