<commit_before>/*
 * Copyright (c) 2012, Joyent, Inc. All rights reserved.
 *
 * zfs.js: Endpoints to manage ZFS datasets and pools
 */

var common = require('../common');
var restify = require('restify');
var util = require('util');

function ZFS() {}

ZFS.listDatasets = function (req, res, next) {
    var model = this.model;
    var server = req.params.server;

    return (model.zfsTask('zfs_list_datasets', server, req.params,
    function (err, results) {
        if (err) {
            return (next(new restify.InternalError(
                'cannot list datasets:' + err.message)));
        }

        res.send(results);
        return (next());
    }));
};

ZFS.createDataset = function (req, res, next) {
    var model = this.model;
    var server = req.params.server;

    return (model.zfsTask('zfs_create_dataset', server, req.params,
    function (err) {
        if (err) {
            return (next(new restify.InternalError(
                'cannot crate dataset:' + err.message)));
        }

        res.send(204);
        return (next());
    }));
};

var findProps = function (params) {
    var properties = [];

    for (var key in params) {
        if (params.hasOwnProperty(key) &&
            key.substr(0, 4) === 'prop') {
            properties.push(params[key]);
        }
    }

    return (properties);
};

ZFS.getAllProperties = function (req, res, next) {
    var model = this.model;
    var server = req.params.server;

    var options = {};
    var properties = findProps(req.params);
    if (properties.length > 0)<commit_msg>CNAPI-87 rework ZFS endpoints for listing properties (spelling)<commit_after>/*
 * Copyright (c) 2012, Joyent, Inc. All rights reserved.
 *
 * zfs.js: Endpoints to manage ZFS datasets and pools
 */

var common = require('../common');
var restify = require('restify');
var util = require('util');

function ZFS() {}

ZFS.listDatasets = function (req, res, next) {
    var model = this.model;
    var server = req.params.server;

    return (model.zfsTask('zfs_list_datasets', server, req.params,
    function (err, results) {
        if (err) {
            return (next(new restify.InternalError(
                'cannot list datasets:' + err.message)));
        }

        res.send(results);
        return (next());
    }));
};

ZFS.createDataset = function (req, res, next) {
    var model = this.model;
    var server = req.params.server;

    return (model.zfsTask('zfs_create_dataset', server, req.params,
    function (err) {
        if (err) {
            return (next(new restify.InternalError(
                'cannot create dataset:' + err.message)));
        }

        res.send(204);
        return (next());
    }));
};

var findProps = function (params) {
    var properties = [];

    for (var key in params) {
        if (params.hasOwnProperty(key) &&
            key.substr(0, 4) === 'prop') {
            properties.push(params[key]);
        }
    }

    return (properties);
};

ZFS.getAllProperties = function (req, res, next) {
    var model = this.model;
    var server = req.params.server;

    var options = {};
    var properties = findProps(req.params);
    if (properties.length > 0)
{'fraction_non_alphanumeric': 0.14474929044465468, 'fraction_numerical': 0.006937874487543362, 'mean_word_length': 2.4217907227615965, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '193757', 'n_tokens_mistral': 1000, 'n_tokens_neox': 966, 'n_words': 260}