grafana/docs/sources/http_api/org.md

427 lines
6.5 KiB
Markdown
Raw Normal View History

+++
title = "Organisation HTTP API "
description = "Grafana Organisation HTTP API"
keywords = ["grafana", "http", "documentation", "api", "organisation"]
aliases = ["/http_api/organisation/"]
type = "docs"
[menu.docs]
name = "Organisation"
parent = "http_api"
+++
2016-02-03 14:59:22 +08:00
2016-02-05 17:47:34 +08:00
# Organisation API
2016-02-03 14:59:22 +08:00
2016-02-05 17:47:34 +08:00
## Get current Organisation
2016-02-03 14:59:22 +08:00
`GET /api/org`
**Example Request**:
```http
GET /api/org HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
2016-02-03 14:59:22 +08:00
**Example Response**:
```http
HTTP/1.1 200
Content-Type: application/json
2016-02-03 14:59:22 +08:00
{
"id":1,
"name":"Main Org."
}
```
2016-02-03 14:59:22 +08:00
2016-02-05 17:47:34 +08:00
## Get Organisation by Id
2016-02-03 14:59:22 +08:00
`GET /api/orgs/:orgId`
**Example Request**:
```http
GET /api/orgs/1 HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
2016-02-03 14:59:22 +08:00
**Example Response**:
```http
HTTP/1.1 200
Content-Type: application/json
{
"id":1,
"name":"Main Org.",
"address":{
"address1":"",
"address2":"",
"city":"",
"zipCode":"",
"state":"",
"country":""
}
}
```
2016-02-05 17:47:34 +08:00
## Get Organisation by Name
2016-02-03 14:59:22 +08:00
`GET /api/orgs/name/:orgName`
**Example Request**:
```http
GET /api/orgs/name/Main%20Org%2E HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
2016-02-03 14:59:22 +08:00
**Example Response**:
```http
HTTP/1.1 200
Content-Type: application/json
{
"id":1,
"name":"Main Org.",
"address":{
"address1":"",
"address2":"",
"city":"",
"zipCode":"",
"state":"",
"country":""
}
}
```
2016-02-03 14:59:22 +08:00
## Create Organisation
2016-12-09 04:08:04 +08:00
`POST /api/orgs`
**Example Request**:
```http
POST /api/orgs HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
{
"name":"New Org."
}
```
**Example Response**:
```http
HTTP/1.1 200
Content-Type: application/json
{
"orgId":"1",
"message":"Organization created"
}
```
2016-02-05 17:47:34 +08:00
## Update current Organisation
2016-02-03 14:59:22 +08:00
`PUT /api/org`
**Example Request**:
```http
PUT /api/org HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
2016-02-03 14:59:22 +08:00
{
"name":"Main Org."
}
```
2016-02-03 14:59:22 +08:00
**Example Response**:
```http
HTTP/1.1 200
Content-Type: application/json
2016-02-03 14:59:22 +08:00
{"message":"Organization updated"}
```
2016-02-03 14:59:22 +08:00
2016-02-05 17:47:34 +08:00
## Get all users within the actual organisation
2016-02-03 14:59:22 +08:00
`GET /api/org/users`
**Example Request**:
```http
GET /api/org/users HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
2016-02-03 14:59:22 +08:00
**Example Response**:
```http
HTTP/1.1 200
Content-Type: application/json
[
{
"orgId":1,
"userId":1,
"email":"admin@mygraf.com",
"login":"admin",
"role":"Admin"
}
]
```
2016-02-03 14:59:22 +08:00
2016-02-05 17:47:34 +08:00
## Add a new user to the actual organisation
2016-02-03 14:59:22 +08:00
`POST /api/org/users`
Adds a global user to the actual organisation.
**Example Request**:
```http
POST /api/org/users HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
2016-02-03 14:59:22 +08:00
{
"role": "Admin",
"loginOrEmail": "admin"
}
```
2016-02-03 14:59:22 +08:00
**Example Response**:
```http
HTTP/1.1 200
Content-Type: application/json
2016-02-03 14:59:22 +08:00
{"message":"User added to organization"}
```
2016-02-03 14:59:22 +08:00
2016-02-05 17:47:34 +08:00
## Updates the given user
2016-02-03 14:59:22 +08:00
`PATCH /api/org/users/:userId`
**Example Request**:
```http
PATCH /api/org/users/1 HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
2016-02-03 14:59:22 +08:00
{
"role": "Viewer",
}
```
2016-02-03 14:59:22 +08:00
**Example Response**:
```http
HTTP/1.1 200
Content-Type: application/json
2016-02-03 14:59:22 +08:00
{"message":"Organization user updated"}
```
2016-02-03 14:59:22 +08:00
2016-02-05 17:47:34 +08:00
## Delete user in actual organisation
2016-02-03 14:59:22 +08:00
`DELETE /api/org/users/:userId`
**Example Request**:
```http
DELETE /api/org/users/1 HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
2016-02-03 14:59:22 +08:00
**Example Response**:
```http
HTTP/1.1 200
Content-Type: application/json
2016-02-03 14:59:22 +08:00
{"message":"User removed from organization"}
```
2016-02-03 14:59:22 +08:00
2016-02-05 17:47:34 +08:00
# Organisations
2016-02-03 14:59:22 +08:00
2016-02-05 17:47:34 +08:00
## Search all Organisations
2016-02-03 14:59:22 +08:00
`GET /api/orgs`
**Example Request**:
```http
GET /api/orgs HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
2016-02-03 14:59:22 +08:00
**Example Response**:
```http
HTTP/1.1 200
Content-Type: application/json
2016-02-03 14:59:22 +08:00
[
{
"id":1,
"name":"Main Org."
}
]
```
2016-02-03 14:59:22 +08:00
2016-02-05 17:47:34 +08:00
## Update Organisation
2016-02-03 14:59:22 +08:00
`PUT /api/orgs/:orgId`
Update Organisation, fields *Adress 1*, *Adress 2*, *City* are not implemented yet.
**Example Request**:
```http
PUT /api/orgs/1 HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
2016-02-03 14:59:22 +08:00
{
"name":"Main Org 2."
}
```
2016-02-03 14:59:22 +08:00
**Example Response**:
```http
HTTP/1.1 200
Content-Type: application/json
2016-02-03 14:59:22 +08:00
{"message":"Organization updated"}
```
2016-02-03 14:59:22 +08:00
2016-02-05 17:47:34 +08:00
## Get Users in Organisation
2016-02-03 14:59:22 +08:00
`GET /api/orgs/:orgId/users`
**Example Request**:
```http
GET /api/orgs/1/users HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
2016-02-03 14:59:22 +08:00
**Example Response**:
```http
HTTP/1.1 200
Content-Type: application/json
[
{
"orgId":1,
"userId":1,
"email":"admin@mygraf.com",
"login":"admin",
"role":"Admin"
}
]
```
2016-02-03 14:59:22 +08:00
2016-02-05 17:47:34 +08:00
## Add User in Organisation
2016-02-03 14:59:22 +08:00
`POST /api/orgs/:orgId/users`
**Example Request**:
```http
POST /api/orgs/1/users HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
2016-02-03 14:59:22 +08:00
{
"loginOrEmail":"user",
"role":"Viewer"
}
```
2016-02-03 14:59:22 +08:00
**Example Response**:
```http
HTTP/1.1 200
Content-Type: application/json
2016-02-03 14:59:22 +08:00
{"message":"User added to organization"}
```
2016-02-03 14:59:22 +08:00
2016-02-05 17:47:34 +08:00
## Update Users in Organisation
2016-02-03 14:59:22 +08:00
`PATCH /api/orgs/:orgId/users/:userId`
**Example Request**:
```http
PATCH /api/orgs/1/users/2 HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
2016-02-03 14:59:22 +08:00
{
"role":"Admin"
}
```
2016-02-03 14:59:22 +08:00
**Example Response**:
```http
HTTP/1.1 200
Content-Type: application/json
2016-02-03 14:59:22 +08:00
{"message":"Organization user updated"}
```
2016-02-03 14:59:22 +08:00
2016-02-05 17:47:34 +08:00
## Delete User in Organisation
2016-02-03 14:59:22 +08:00
`DELETE /api/orgs/:orgId/users/:userId`
**Example Request**:
```http
DELETE /api/orgs/1/users/2 HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
```
2016-02-03 14:59:22 +08:00
**Example Response**:
```http
HTTP/1.1 200
Content-Type: application/json
2016-02-03 14:59:22 +08:00
{"message":"User removed from organization"}
```