diff --git a/docs/docs/functions/api.md b/docs/docs/functions/api.md index 48055967..4145c627 100644 --- a/docs/docs/functions/api.md +++ b/docs/docs/functions/api.md @@ -36,3 +36,77 @@ SWAGGER_ENABLED = True Restart django: `sudo systemctl restart rmm` Then visit `https://api.example.com/api/schema/swagger-ui/` to see it in action. + +???+ abstract "Example Code" + + === ":fontawesome-brands-python: Python" + + Requests Windows Update check to run against agent ID + + ```python + import requests + + API = "http://api.example.com" + HEADERS = { + "Content-Type": "application/json", + "X-API-KEY": "DKNRPTHSAPCKT8A36MCAMNZREWWWFPWI", + } + + + def trigger_update_scan(): + agents = requests.get(f"{API}/agents/?detail=false", headers=HEADERS) + for agent in agents.json(): + r = requests.post(f"{API}/winupdate/{agent['agent_id']}/scan/", headers=HEADERS) + print(r.json()) + + + if __name__ == "__main__": + trigger_update_scan() + ``` + + === ":material-powershell: Powershell" + + ```powershell + # Example - Get all agents using API + + $headers = @{ + 'X-API-KEY' = 'ABC1234567890987654321' + } + + $url = "https://api.yourdomain.com/agents/" + + $agentsResult = Invoke-RestMethod -Method 'Get' -Uri $url -Headers $headers -ContentType "application/json" + + foreach ($agent in $agentsResult) { + Write-Host $agent + + #Write-Host $agent.hostname + } + ``` + + === ":material-powershell: Powershell" + + ```powershell + # Example - Send powershell command to agent. Make sure to pass {{agent.agent_id}} as a parameter + + param( + $AgentId + ) + + $headers = @{ + 'X-API-KEY' = 'ABC1234567890987654321' + } + + $url = "https://api.yourdomain.com/agents/$AgentId/cmd/" + + $body = @{ + "shell" = "powershell" + "cmd" = "dir c:\\users" + "timeout" = 30 + } + + + $commandResult = Invoke-RestMethod -Method 'Post' -Uri $url -Body ($body|ConvertTo-Json) -Headers $headers -ContentType "application/json" + + Write-Host $commandResult + ``` diff --git a/docs/docs/howitallworks.md b/docs/docs/howitallworks.md index 91ddbd7c..e41712b4 100644 --- a/docs/docs/howitallworks.md +++ b/docs/docs/howitallworks.md @@ -62,7 +62,7 @@ Nginx is the web server for the `rmm`, `api`, and `mesh` domains. All sites redi === ":material-web: `rmm.example.com`" - This serves the frontend website that you intereact with. + This serves the frontend website that you interact with. - Config: `/etc/nginx/sites-enabled/frontend.conf` - root: `/var/www/rmm/dist` @@ -91,8 +91,8 @@ Nginx is the web server for the `rmm`, `api`, and `mesh` domains. All sites redi - Config: `/etc/nginx/sites-enabled/meshcentral.conf` - Upstream: `http://127.0.0.1:4430/` - - Access log: `/var/log/nginx/access.log` (uses deafult) - - Error log: `/var/log/nginx/error.log` (uses deafult) + - Access log: `/var/log/nginx/access.log` (uses default) + - Error log: `/var/log/nginx/error.log` (uses default) - TLS certificate: `/etc/letsencrypt/live/example.com/fullchain.pem` === ":material-web: default" @@ -101,8 +101,8 @@ Nginx is the web server for the `rmm`, `api`, and `mesh` domains. All sites redi - Config: `/etc/nginx/sites-enabled/default` - root: `/var/www/rmm/dist` - - Access log: `/var/log/nginx/access.log` (uses deafult) - - Error log: `/var/log/nginx/error.log` (uses deafult) + - Access log: `/var/log/nginx/access.log` (uses default) + - Error log: `/var/log/nginx/error.log` (uses default) ???+ note "systemd config"