Update API reference endpoints documentation links:

- Removed old documentation links
  - Updated generate API 4.0 script
  - Updated API endpoints documentations links
This commit is contained in:
Desvelao 2020-10-02 15:38:31 +02:00
parent d6d9bc454a
commit a00a506a19
No known key found for this signature in database
GPG Key ID: DC70AEDF0377DBC1
3 changed files with 161 additions and 653 deletions

View File

@ -1,483 +0,0 @@
{
"GET": [
{
"path": "/agents",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-all-agents"
},
{
"path": "/agents/:agent_id",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-an-agent"
},
{
"path": "/agents/:agent_id/config/:component/:configuration",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-active-configuration"
},
{
"path": "/agents/:agent_id/group/is_sync",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-sync-status-of-agent"
},
{
"path": "/agents/:agent_id/key",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-agent-key"
},
{
"path": "/agents/:agent_id/upgrade_result",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-upgrade-result-from-agent"
},
{
"path": "/agents/groups",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-groups"
},
{
"path": "/agents/groups/:group_id",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-agents-in-a-group"
},
{
"path": "/agents/groups/:group_id/configuration",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-group-configuration"
},
{
"path": "/agents/groups/:group_id/files",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-group-files"
},
{
"path": "/agents/groups/:group_id/files/:filename",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-a-file-in-group"
},
{
"path": "/agents/name/:agent_name",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-an-agent-by-its-name"
},
{
"path": "/agents/no_group",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-agents-without-group"
},
{
"path": "/agents/outdated",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-outdated-agents"
},
{
"path": "/agents/stats/distinct",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-distinct-fields-in-agents"
},
{
"path": "/agents/summary",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-agents-summary"
},
{
"path": "/agents/summary/os",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-os-summary"
},
{
"path": "/cache",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-cache-index"
},
{
"path": "/cache/config",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#return-cache-configuration"
},
{
"path": "/ciscat/:agent_id/results",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-cis-cat-results-from-an-agent"
},
{
"path": "/cluster/:node_id/configuration",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-node-node-id-s-configuration"
},
{
"path": "/cluster/:node_id/configuration/validation",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#check-wazuh-configuration-in-a-cluster-node"
},
{
"path": "/cluster/:node_id/files",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-local-file-from-any-cluster-node"
},
{
"path": "/cluster/:node_id/info",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-node-id-s-information"
},
{
"path": "/cluster/:node_id/logs",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-ossec-log-from-a-specific-node-in-cluster"
},
{
"path": "/cluster/:node_id/logs/summary",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-summary-of-ossec-log-from-a-specific-node-in-cluster"
},
{
"path": "/cluster/:node_id/stats",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-node-node-id-s-stats"
},
{
"path": "/cluster/:node_id/stats/analysisd",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-node-node-id-s-analysisd-stats"
},
{
"path": "/cluster/:node_id/stats/hourly",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-node-node-id-s-stats-by-hour"
},
{
"path": "/cluster/:node_id/stats/remoted",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-node-node-id-s-remoted-stats"
},
{
"path": "/cluster/:node_id/stats/weekly",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-node-node-id-s-stats-by-week"
},
{
"path": "/cluster/:node_id/status",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-node-node-id-s-status"
},
{
"path": "/cluster/config",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-the-cluster-configuration"
},
{
"path": "/cluster/configuration/validation",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#check-wazuh-configuration-in-all-cluster-nodes"
},
{
"path": "/cluster/healthcheck",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#show-cluster-health"
},
{
"path": "/cluster/node",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-local-node-info"
},
{
"path": "/cluster/nodes",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-nodes-info"
},
{
"path": "/cluster/nodes/:node_name",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-node-info"
},
{
"path": "/cluster/status",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-info-about-cluster-status"
},
{
"path": "/manager/stats/remoted",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-remoted-stats"
},
{
"path": "/sca/:agent_id",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-security-configuration-assessment-sca-database"
},
{
"path": "/sca/:agent_id/checks/:policy_id",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-security-configuration-assessment-sca-checks-database"
},
{
"path": "/summary/agents",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-a-full-summary-of-agents"
},
{
"path": "/decoders",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-all-decoders"
},
{
"path": "/decoders/:decoder_name",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-decoders-by-name"
},
{
"path": "/decoders/files",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-all-decoders-files"
},
{
"path": "/decoders/parents",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-all-parent-decoders"
},
{
"path": "/lists",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-all-lists"
},
{
"path": "/lists/files",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-paths-from-all-lists"
},
{
"path": "/manager/configuration",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-manager-configuration"
},
{
"path": "/manager/configuration/validation",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#check-wazuh-configuration"
},
{
"path": "/manager/files",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-local-file"
},
{
"path": "/manager/info",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-manager-information"
},
{
"path": "/manager/logs",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-ossec-log"
},
{
"path": "/manager/logs/summary",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-summary-of-ossec-log"
},
{
"path": "/manager/stats",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-manager-stats"
},
{
"path": "/manager/stats/analysisd",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-analysisd-stats"
},
{
"path": "/manager/stats/hourly",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-manager-stats-by-hour"
},
{
"path": "/manager/stats/remoted",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-remoted-stats"
},
{
"path": "/manager/stats/weekly",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-manager-stats-by-week"
},
{
"path": "/manager/status",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-manager-status"
},
{
"path": "/rootcheck/:agent_id",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-rootcheck-database"
},
{
"path": "/rootcheck/:agent_id/cis",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-rootcheck-cis-requirements"
},
{
"path": "/rootcheck/:agent_id/last_scan",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-last-rootcheck-scan"
},
{
"path": "/rootcheck/:agent_id/pci",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-rootcheck-pci-requirements"
},
{
"path": "/rules",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-all-rules"
},
{
"path": "/rules/:rule_id",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-rules-by-id"
},
{
"path": "/rules/files",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-files-of-rules"
},
{
"path": "/rules/gdpr",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-rule-gdpr-requirements"
},
{
"path": "/rules/groups",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-rule-groups"
},
{
"path": "/rules/pci",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-rule-pci-requirements"
},
{
"path": "/rules/hipaa",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-rule-hipaa-requirements"
},
{
"path": "/rules/nist-800-53",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-rule-nist-800-53-requirements"
},
{
"path": "/rules/tsc",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-rule-tsc-requirements"
},
{
"path": "/syscheck/:agent_id",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-syscheck-files"
},
{
"path": "/syscheck/:agent_id/last_scan",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-last-syscheck-scan"
},
{
"path": "/syscollector/:agent_id/hardware",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-hardware-info"
},
{
"path": "/syscollector/:agent_id/netaddr",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-network-address-info-of-an-agent"
},
{
"path": "/syscollector/:agent_id/netiface",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-network-interface-info-of-an-agent"
},
{
"path": "/syscollector/:agent_id/netproto",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-network-protocol-info-of-an-agent"
},
{
"path": "/syscollector/:agent_id/os",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-os-info"
},
{
"path": "/syscollector/:agent_id/packages",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-packages-info"
},
{
"path": "/syscollector/:agent_id/ports",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-ports-info-of-an-agent"
},
{
"path": "/syscollector/:agent_id/processes",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#get-processes-info"
}
],
"POST": [
{
"path": "/agents",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#add-agent"
},
{
"path": "/agents/group/:group_id",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#add-a-list-of-agents-to-a-group"
},
{
"path": "/agents/groups/:group_id/configuration",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#put-configuration-file-agent-conf-into-a-group"
},
{
"path": "/agents/groups/:group_id/files/:file_name",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#upload-file-into-a-group"
},
{
"path": "/agents/insert",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#insert-agent"
},
{
"path": "/agents/restart",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#restart-a-list-of-agents"
},
{
"path": "/cluster/:node_id/files",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#update-local-file-at-any-cluster-node"
},
{
"path": "/manager/files",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#update-local-file"
}
],
"PUT": [
{
"path": "/active-response/:agent_id",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#run-an-ar-command-in-the-agent"
},
{
"path": "/agents/:agent_id/group/:group_id",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#add-agent-group"
},
{
"path": "/agents/:agent_id/restart",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#restart-an-agent"
},
{
"path": "/agents/:agent_id/upgrade",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#upgrade-agent-using-online-repository"
},
{
"path": "/agents/:agent_id/upgrade_custom",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#upgrade-agent-using-custom-file"
},
{
"path": "/agents/:agent_name",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#add-agent-quick-method"
},
{
"path": "/agents/groups/:group_id",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#create-a-group"
},
{
"path": "/agents/restart",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#restart-all-agents"
},
{
"path": "/cluster/:node_id/restart",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#restart-a-specific-node-in-cluster"
},
{
"path": "/cluster/restart",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#restart-all-nodes-in-cluster"
},
{
"path": "/manager/restart",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#restart-wazuh-manager"
},
{
"path": "/rootcheck",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#run-rootcheck-scan-in-all-agents"
},
{
"path": "/rootcheck/:agent_id",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#run-rootcheck-scan-in-an-agent"
},
{
"path": "/syscheck",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#run-syscheck-scan-in-all-agents"
},
{
"path": "/syscheck/:agent_id",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#run-syscheck-scan-in-an-agent"
}
],
"DELETE": [
{
"path": "/agents",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#delete-agents"
},
{
"path": "/agents/:agent_id",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#delete-an-agent"
},
{
"path": "/agents/:agent_id/group",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#remove-a-single-group-of-an-agent"
},
{
"path": "/agents/:agent_id/group/:group_id",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#remove-a-single-group-of-an-agent"
},
{
"path": "/agents/group/:group_id",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#remove-a-single-group-of-multiple-agents"
},
{
"path": "/agents/groups",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#delete-a-list-of-groups"
},
{
"path": "/agents/groups/:group_id",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#remove-group"
},
{
"path": "/cache",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#delete-cache-index"
},
{
"path": "/rootcheck",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#clear-rootcheck-database"
},
{
"path": "/rootcheck/:agent_id",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#clear-rootcheck-database-of-an-agent"
},
{
"path": "/syscheck/:agent_id",
"documentation": "https://documentation.wazuh.com/current/user-manual/api/reference.html#clear-syscheck-database-of-an-agent"
}
],
"HEAD": []
}

View File

@ -28,8 +28,8 @@ const reFormatter = /--full/
const OUTPUT_ENDPOINTS_FILENAME = `${(consoleInput.match(reFilename) || [])[1] || 'api-4.0-endpoints'}.json`;
const OUTPUT_ENDPOINTS_DIRECTORY = `./endpoints`;
const OUTPUT_ENDPOINTS_PATH = `${OUTPUT_ENDPOINTS_DIRECTORY}/${OUTPUT_ENDPOINTS_FILENAME}`;
const DOCUMENTATION_FILE_PATH = `./documentation`;
const OUTPUT_MODE_FULL = consoleInput.match(reFormatter) && true;
const WAZUH_DOCUMENTATION_API_REFERENCE_URL = 'https://documentation.wazuh.com/current/user-manual/api/reference.html'
// Define console color codes
const CONSOLE_COLORS_CODES = {
@ -53,13 +53,6 @@ const main = async () => {
if(!WAZUH_API_URL.startsWith('http') ){
exitWithMessage(`Wazuh API url is not valid. It should start with "http". Example: https://172.16.1.2:55000`);
};
// Try to load the documentation data
let documentationData;
try{
documentationData = require(DOCUMENTATION_FILE_PATH);
}catch(error){
logger.warning(`Documentation file doesn't exist`);
}
try{
// Log the configuration:
@ -67,7 +60,6 @@ const main = async () => {
console.log(`Wazuh API url: ${WAZUH_API_URL}`);
console.log(`Output file path: ${OUTPUT_ENDPOINTS_PATH}`);
console.log(`Output mode: ${OUTPUT_MODE_FULL ? 'Full': 'Simple'}`);
console.log(`Documentation path: ${DOCUMENTATION_FILE_PATH}`);
console.log('----------------------------------------------')
// Request to API swagger.json file
@ -79,7 +71,7 @@ const main = async () => {
const endpointData = jsonData.paths[endpointPath];
Object.keys(endpointData).forEach(httpMethod => {
const httpMethodUppercase = httpMethod.toUpperCase();
accum[httpMethodUppercase] = [...accum[httpMethodUppercase], formatEndpoint({...endpointData[httpMethod], path: endpointPath, method: httpMethodUppercase}, jsonData, documentationData)]
accum[httpMethodUppercase] = [...accum[httpMethodUppercase], formatEndpoint({...endpointData[httpMethod], path: endpointPath, method: httpMethodUppercase}, jsonData)]
});
return accum;
}, ['GET', 'PUT', 'POST', 'DELETE'].reduce((accum, httpMethod) => ({...accum, [httpMethod]: []}), {}));
@ -96,9 +88,6 @@ const main = async () => {
return logger.error('An error appeared saving the output file:', error);
}
logger.success(`File was created! Path: ${OUTPUT_ENDPOINTS_PATH}`);
if(!documentationData){
logger.warning(`Documentation file doesn't exist and the endpoints have not documentation links`);
};
});
}catch(error){
logger.error('An error appeared:', error);
@ -138,7 +127,7 @@ const request = apiEndpoint => {
}
// Formatters
// Format the endpoint to use in the Wazuh app
const formatEndpoint = (endpointData, jsonData, documentationData) => {
const formatEndpoint = (endpointData, jsonData) => {
const formattedParameters = endpointData.parameters && endpointData.parameters
.filter(parameter => parameter.$ref)
.map(parameter => getNestedObject(jsonData, parameter.$ref.split('/').splice(1)))
@ -162,13 +151,10 @@ const formatEndpoint = (endpointData, jsonData, documentationData) => {
)
)) || [];
const endpointPath = formatEndpointPath(endpointData.path);
const endpointDocumentation = (documentationData && documentationData[endpointData.method].find(documentationEndpoint => documentationEndpoint.path === endpointPath) || {}).documentation || '';
const endpointDocumentation = generateEndpointDocumentationLink(endpointData);
const endpointSummary = endpointData.summary || '';
const endpointDescription = endpointData.description || '';
const endpointTags = endpointData.tags || [];
if(!endpointDocumentation){
logger.warning(`[${endpointData.method} ${endpointPath}] has not documentation link`);
};
return {
name: endpointPath,
documentation: endpointDocumentation,
@ -245,9 +231,14 @@ const logger = {
error: createLog('ERROR', CONSOLE_COLORS_CODES.RED),
};
// Log a message and end script
const exitWithMessage = message => {
logger.error(message);
process.exit(1);
}
};
// Generate the endpoint documentation link
const generateEndpointDocumentationLink = endpointData => `${WAZUH_DOCUMENTATION_API_REFERENCE_URL}#operation/${endpointData.operationId}`;
// Run the method
main();

File diff suppressed because it is too large Load Diff