'Acquire a lease on a dataset.
:param unicode dataset_id: The dataset whose lease is being
acquired.
:param unicode node_uuid: The node on which the lease is being aquired.
:param expires: ``None`` if no expiration, otherwise number of
seconds to expiration.
:return: A ``Deferred`` firing with an ``EndpointResponse`` or
serializable JSON.'

@app.route('/configuration/leases', methods=['POST'])
@user_documentation(u'\n                                Acquire    a    lease    on    a    particular    dataset    on    a    particular\n                                node.    Until    the    lease    is    released    or    expires    the    dataset    will    not\n                                be    deleted    or    moved    to    other    nodes.\n                                ', header=u'Acquire    a    lease    on    a    dataset', examples=[u'acquire    a    lease    without    expiration', u'acquire    a    lease    with    expiration', u'acquire    a    lease    that    is    already    held', u'renew    a    lease'], section=u'dataset')
@structured(inputSchema={'$ref': '/v1/endpoints.json#/definitions/lease'}, outputSchema={'$ref': '/v1/endpoints.json#/definitions/lease'}, schema_store=SCHEMAS)
def acquire_lease(self, dataset_id, node_uuid, expires):

    now = datetime.fromtimestamp(self.clock.seconds(), UTC)
    dataset_id = UUID(dataset_id)
    node_uuid = UUID(node_uuid)
    if (self.persistence_service.get().leases.get(dataset_id) is None):
        response_code = CREATED
    else:
        response_code = OK
    def acquire(leases):
        try:
            return leases.acquire(now, dataset_id, node_uuid, expires)
        except LeaseError:
            raise LEASE_HELD
    d = update_leases(acquire, self.persistence_service)
    d.addCallback((lambda leases: EndpointResponse(response_code, lease_response(leases[dataset_id], now))))
    return d
