Skip to content

Commit

Permalink
Merge pull request #944 from silversword411/develop
Browse files Browse the repository at this point in the history
docs - api examples and more
  • Loading branch information
wh1te909 committed Jan 18, 2022
2 parents 04de799 + e9e98eb commit 1ca63ed
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 5 deletions.
74 changes: 74 additions & 0 deletions docs/docs/functions/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
10 changes: 5 additions & 5 deletions docs/docs/howitallworks.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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"
Expand All @@ -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"

Expand Down

0 comments on commit 1ca63ed

Please sign in to comment.