[https://github.com/ridvanaltun/guacamole-rest-api-documentation/tree/master/docs](https://github.com/ridvanaltun/guacamole-rest-api-documentation/tree/master/docs)

### Pedir um token:

`curl -d "username=cremotos&password=Gray-Hardiness-Straw1" http://10.0.0.15/guacamole/api/tokens/`

Exemplo de resposta:

```
{
	"authToken":"0DAAC10BA628E0EB5034DC33558800675F9D3C21D4631A5DC8E0798386D3B93D",
	"username":"cremotos", 
	"dataSource":"postgresql", 
	"availableDataSources": [
		"postgresql",
		"postgresql-shared"
	] 
} 
```

### Apagar um token:

`curl -X DELETE http://10.0.0.15/guacamole/api/tokens/0DAAC10BA628E0EB5034DC33558800675F9D3C21D4631A5DC8E0798386D3B93D`

Exemplo de resposta:

```
Devolve um Status Code 204 - No Content
Qualquer outra query utilizando o token apagado irá retornar:
{
  "message": "Permission Denied.",
  "translatableMessage": {
    "key": "APP.TEXT_UNTRANSLATED",
    "variables": {
      "MESSAGE": "Permission Denied."
    }
  },
  "statusCode": null,
  "expected": null,
  "patches": null,
  "type": "PERMISSION_DENIED"
}
```

### Pedir a lista de users:

`curl "http://10.0.0.15/guacamole/api/session/data/postgresql/users?token=0DAAC10BA628E0EB5034DC33558800675F9D3C21D4631A5DC8E0798386D3B93D"`

Exemplo de resposta:

```
{
  "test02": {
    "username": "test02",
    "disabled": false,
    "attributes": {
      "guac-email-address": null,
      "guac-organizational-role": null,
      "guac-full-name": null,
      "expired": null,
      "timezone": null,
      "access-window-start": null,
      "guac-organization": null,
      "access-window-end": null,
      "valid-until": null,
      "valid-from": null
    }
  },
  "test01": {
    "username": "test01",
    "disabled": false,
    "attributes": {
      "guac-email-address": null,
      "guac-organizational-role": null,
      "guac-full-name": null,
      "expired": null,
      "timezone": null,
      "access-window-start": null,
      "guac-organization": null,
      "access-window-end": null,
      "valid-until": null,
      "valid-from": null
    },
    "lastActive": 1768325939255
  },
  "test": {
    "username": "test",
    "disabled": false,
    "attributes": {
      "guac-email-address": null,
      "guac-organizational-role": null,
      "guac-full-name": null,
      "expired": null,
      "timezone": null,
      "access-window-start": null,
      "guac-organization": null,
      "access-window-end": null,
      "valid-until": null,
      "valid-from": null
    },
    "lastActive": 1764072964921
  }
}
```

### Detalhes de um user específico:

`curl "http://10.0.0.15/guacamole/api/session/data/postgresql/users/test01?token=0DAAC10BA628E0EB5034DC33558800675F9D3C21D4631A5DC8E0798386D3B93D"`

Exemplo de resposta:

```
{
  "username": "test01",
  "disabled": false,
  "attributes": {
    "guac-email-address": null,
    "guac-organizational-role": null,
    "guac-full-name": null,
    "expired": null,
    "timezone": null,
    "access-window-start": null,
    "guac-organization": null,
    "access-window-end": null,
    "valid-until": null,
    "valid-from": null
  },
  "lastActive": 1768325939255
}
```

### Listar grupos a que um user pertence:

`curl "http://10.0.0.15/guacamole/api/session/data/postgresql/users/test01/userGroups?token=0DAAC10BA628E0EB5034DC33558800675F9D3C21D4631A5DC8E0798386D3B93D"`

Exemplo de resposta:

```
[
  "REM23"
]
```

### Adicionar user a um grupo:

`curl -X PATCH http://10.0.0.15/guacamole/api/session/data/postgresql/users/test01/userGroups?token=0DAAC10BA628E0EB5034DC33558800675F9D3C21D4631A5DC8E0798386D3B93D \`  
`-H "Content-Type: application/json" \`  
`-d '[{"op": "add", "path": "/", "value": "REM22"}]'`

Exemplo de resposta:

```
Devolve um Status Code 204 - No Content
Outra query aos grupos do user devolve:
[
  "REM22",
  "REM23"
]
```

### Remover user de um grupo:

`curl -X PATCH http://10.0.0.15/guacamole/api/session/data/postgresql/users/test01/userGroups?token=0DAAC10BA628E0EB5034DC33558800675F9D3C21D4631A5DC8E0798386D3B93D \`  
`-H "Content-Type: application/json" \`  
`-d '[{"op": "remove", "path": "/", "value": "REM22"}]'`

Exemplo de resposta:

```
Devolve um Status Code 204 - No Content
Outra query aos grupos do user devolve:
[
  "REM23"
]
```

### Listar grupos:

`curl "http://10.0.0.15/guacamole/api/session/data/postgresql/userGroups?token=0DAAC10BA628E0EB5034DC33558800675F9D3C21D4631A5DC8E0798386D3B93D"`

Exemplo de resposta:

```
{
  "Users": {
    "identifier": "Users",
    "disabled": false,
    "attributes": {}
  },
  "REM31": {
    "identifier": "REM31",
    "disabled": false,
    "attributes": {}
  },
  "REM21": {
    "identifier": "REM21",
    "disabled": false,
    "attributes": {}
  },
  "REM32": {
    "identifier": "REM32",
    "disabled": false,
    "attributes": {}
  },
  "REM22": {
    "identifier": "REM22",
    "disabled": false,
    "attributes": {}
  },
  "REM33": {
    "identifier": "REM33",
    "disabled": false,
    "attributes": {}
  },
  "REM23": {
    "identifier": "REM23",
    "disabled": false,
    "attributes": {}
  },
  "REM34": {
    "identifier": "REM34",
    "disabled": false,
    "attributes": {}
  }
}
```

### Detalhes de um grupo específico:

`curl "http://10.0.0.15/guacamole/api/session/data/postgresql/userGroups/REM23?token=0DAAC10BA628E0EB5034DC33558800675F9D3C21D4631A5DC8E0798386D3B93D"`

Exemplo de resposta:

```
{
  "identifier": "REM23",
  "disabled": false,
  "attributes": {}
}
```