def post(self): """ A ``POST`` to this endpoint will create a new path map. A path map will list the equivalent path prefixes for all three supported families of operating systems, Linux, Windows and OS X. A path map can optionally be restricted to one tag, in which case it will only apply to agents with that tag. If a tag is specified that does not exist yet, that tag will be transparently created. .. http:post:: /api/v1/pathmaps/ HTTP/1.1 **Request** .. sourcecode:: http POST /api/v1/pathmaps/ HTTP/1.1 Accept: application/json { "path_linux": "/mnt/nfs", "path_windows": "\\domain\cifs_server", "path_osx": "/mnt/nfs", "tag": "production" } **Response** .. sourcecode:: http HTTP/1.1 201 CREATED Content-Type: application/json { "id": 1, "path_linux": "/mnt/nfs", "path_windows": "\\domain\cifs_server", "path_osx": "/mnt/nfs", "tag": "production" } :statuscode 201: a new pathmap was created :statuscode 400: there was something wrong with the request (such as invalid columns being included) """ tagname = g.json.pop("tag", None) if tagname: if not isinstance(tagname, STRING_TYPES): return jsonify(error="tag must be of type string"), BAD_REQUEST pathmap = PathMap(**g.json) if tagname: tag = Tag.query.filter_by(tag=tagname).first() if not tag: tag = Tag(tag=tagname) db.session.add(tag) pathmap.tag = tag db.session.add(pathmap) db.session.commit() out = pathmap.to_dict(unpack_relationships=False) if pathmap.tag: out["tag"] = pathmap.tag.tag logger.info("New pathmap created with values: %r", pathmap) return jsonify(out), CREATED