def reset_keys(request):
    '''
        POST endpoint to reset API keys for a given API
        (triggering a request for new keys)
    '''
    api_obj = get_object_or_404(Api, name=request.POST['api'])

    # check the signature
    if get_signature(request.POST, api_obj.signing_key) != request.POST['signature']:
        return HttpResponseBadRequest('bad signature')

    ReplicatedApiNames = getattr(settings, 'LOCKSMITH_REPLICATED_APIS', [])
    if api_obj.name in ReplicatedApiNames:
        for key in Key.objects.all():
            replicate_key.delay(key, api_obj)
    else:
        api_obj.pub_statuses.update(status=UNPUBLISHED)
        for key in Key.objects.all():
            push_key.delay(key, replicate_too=False)

    return HttpResponse('OK')
Exemple #2
0
 def mark_for_update(self):
     '''
         Note that a change has been made so all Statuses need update
     '''
     self.pub_statuses.exclude(status=UNPUBLISHED).update(status=NEEDS_UPDATE)
     push_key.delay(self)