parent
dd5f7cbe6c
commit
5686c80af1
5 changed files with 23 additions and 57 deletions
|
@ -28,7 +28,6 @@ class APIRequestFailure(Exception):
|
|||
|
||||
_API_METHOD_INSERT = 'layers'
|
||||
_API_METHOD_GET_LAYER = 'layers/%s'
|
||||
_API_METHOD_DELETE_LAYER = 'layers/%s'
|
||||
_API_METHOD_MARK_NOTIFICATION_READ = 'notifications/%s'
|
||||
_API_METHOD_GET_NOTIFICATION = 'notifications/%s'
|
||||
_API_METHOD_PING = 'metrics'
|
||||
|
@ -123,26 +122,6 @@ class SecurityScannerAPI(object):
|
|||
'Layer': layer_request,
|
||||
}
|
||||
|
||||
def delete_layers(self, layers):
|
||||
""" Deletes the given layers in the security scanner. """
|
||||
if self._config is None:
|
||||
# Not configured.
|
||||
return
|
||||
|
||||
for layer in layers:
|
||||
layer_id = '%s.%s' % (layer.docker_image_id, layer.storage.uuid)
|
||||
self.delete_layer(layer_id)
|
||||
|
||||
def delete_layer(self, layer_id):
|
||||
""" Calls DELETE on the layer with the given ID in the security scanner, removing it from
|
||||
its database.
|
||||
"""
|
||||
try:
|
||||
response = self._call('DELETE', _API_METHOD_DELETE_LAYER % layer_id)
|
||||
return response.status_code / 100 == 2
|
||||
except requests.exceptions.RequestException:
|
||||
logger.exception('Failed to delete layer: %s', layer_id)
|
||||
return False
|
||||
|
||||
def ping(self):
|
||||
""" Calls GET on the metrics endpoint of the security scanner to ensure it is running
|
||||
|
|
Reference in a new issue