'Create a new dataset in the cluster configuration.
:param unicode primary: The UUID of the node on which the primary
manifestation of the dataset will be created.
:param unicode dataset_id: A unique identifier to assign to the
dataset.  This is a string giving a UUID (per RFC 4122).  If no
value is given, one will be generated and returned in the response.
This is not for easy human use.  For human-friendly identifiers,
use items in ``metadata``.
:param maximum_size: Either the maximum number of bytes the dataset
will be capable of storing or ``None`` to make the dataset size
unlimited. This may be optional or required depending on the
dataset backend.
:param dict metadata: A small collection of unicode key/value pairs to
associate with the dataset.  These items are not interpreted.  They
are only stored and made available for later retrieval.  Use this
for things like human-friendly dataset naming, ownership
information, etc.
:return: A ``dict`` describing the dataset which has been added to the
cluster configuration or giving error information if this is not
possible.'

@app.route('/configuration/datasets', methods=['POST'])
@user_documentation(u"\n                                Create    a    new    dataset.\n\n                                Supports    ``X-If-Configuration-Matches``    header    in    the    request    to\n                                ensure    creation    only    happens    if    the    configuration    hasn't    changed.\n                                ", header=u'Create    new    dataset', examples=[u'create    dataset', u'create    dataset    with    dataset_id', u'create    dataset    with    duplicate    dataset_id', u'create    dataset    with    maximum_size', u'create    dataset    with    metadata'], section=u'dataset')
@_if_configuration_matches
@structured(inputSchema={'$ref': '/v1/endpoints.json#/definitions/configuration_datasets_create'}, outputSchema={'$ref': '/v1/endpoints.json#/definitions/configuration_datasets'}, schema_store=SCHEMAS)
def create_dataset_configuration(self, primary, dataset_id=None, maximum_size=None, metadata=None):

    if (dataset_id is None):
        dataset_id = unicode(uuid4())
    dataset_id = dataset_id.lower()
    if (metadata is None):
        metadata = {}
    primary = UUID(hex=primary)
    deployment = self.persistence_service.get()
    for node in deployment.nodes.itervalues():
        for manifestation in node.manifestations.values():
            if (manifestation.dataset.dataset_id == dataset_id):
                raise DATASET_ID_COLLISION
    dataset = Dataset(dataset_id=dataset_id, maximum_size=maximum_size, metadata=pmap(metadata))
    manifestation = Manifestation(dataset=dataset, primary=True)
    primary_node = deployment.get_node(primary)
    new_node_config = primary_node.transform(('manifestations', manifestation.dataset_id), manifestation)
    new_deployment = deployment.update_node(new_node_config)
    saving = self.persistence_service.save(new_deployment)
    def saved(ignored):
        result = api_dataset_from_dataset_and_node(dataset, primary)
        return EndpointResponse(CREATED, result)
    saving.addCallback(saved)
    return saving
