open-nomad/website/pages/api-docs/namespaces.mdx

187 lines
4.6 KiB
Plaintext
Raw Normal View History

2017-09-19 14:47:10 +00:00
---
layout: api
page_title: Namespace - HTTP API
2020-02-06 23:45:31 +00:00
sidebar_title: Namespaces
description: The /namespace endpoints are used to query for and interact with namespaces.
2017-09-19 14:47:10 +00:00
---
# Namespace HTTP API
The `/namespace` endpoints are used to query for and interact with namespaces.
2020-10-22 21:59:40 +00:00
~> Prior to Nomad 1.0 Namespaces were an Enterprise-only feature.
2017-09-19 14:47:10 +00:00
## List Namespaces
This endpoint lists all namespaces.
2020-02-06 23:45:31 +00:00
| Method | Path | Produces |
| ------ | ---------------- | ------------------ |
| `GET` | `/v1/namespaces` | `application/json` |
2017-09-19 14:47:10 +00:00
The table below shows this endpoint's support for
[blocking queries](/api-docs#blocking-queries) and
[required ACLs](/api-docs#acls).
2017-09-19 14:47:10 +00:00
2020-02-06 23:45:31 +00:00
| Blocking Queries | ACL Required |
| ---------------- | -------------------------------------------------------------------------- |
| `YES` | `namespace:*`<br />Any capability on the namespace authorizes the endpoint |
2017-09-19 14:47:10 +00:00
### Parameters
- `prefix` `(string: "")`- Specifies a string to filter namespaces on based on
2019-05-08 19:14:31 +00:00
an index prefix. This is specified as a query string parameter.
2017-09-19 14:47:10 +00:00
### Sample Request
2020-05-18 20:53:06 +00:00
```shell-session
$ curl \
https://localhost:4646/v1/namespaces
2017-09-19 14:47:10 +00:00
```
2020-05-18 20:53:06 +00:00
```shell-session
$ curl \
https://localhost:4646/v1/namespaces?prefix=prod
2017-09-19 14:47:10 +00:00
```
### Sample Response
```json
[
2020-02-06 23:45:31 +00:00
{
"CreateIndex": 31,
"Description": "Production API Servers",
"ModifyIndex": 31,
"Name": "api-prod",
"Quota": ""
},
{
"CreateIndex": 5,
"Description": "Default shared namespace",
"ModifyIndex": 5,
"Name": "default",
"Quota": ""
}
2017-09-19 14:47:10 +00:00
]
```
## Read Namespace
This endpoint reads information about a specific namespace.
2020-02-06 23:45:31 +00:00
| Method | Path | Produces |
| ------ | -------------------------- | ------------------ |
| `GET` | `/v1/namespace/:namespace` | `application/json` |
2017-09-19 14:47:10 +00:00
The table below shows this endpoint's support for
[blocking queries](/api-docs#blocking-queries) and
[required ACLs](/api-docs#acls).
2017-09-19 14:47:10 +00:00
2020-02-06 23:45:31 +00:00
| Blocking Queries | ACL Required |
| ---------------- | -------------------------------------------------------------------------- |
| `YES` | `namespace:*`<br />Any capability on the namespace authorizes the endpoint |
2017-09-19 14:47:10 +00:00
### Parameters
- `:namespace` `(string: <required>)`- Specifies the namespace to query.
### Sample Request
2020-05-18 20:53:06 +00:00
```shell-session
$ curl \
https://localhost:4646/v1/namespace/api-prod
2017-09-19 14:47:10 +00:00
```
### Sample Response
```json
{
2020-02-06 23:45:31 +00:00
"CreateIndex": 31,
"Description": "Production API Servers",
"Quota": "",
"Hash": "N8WvePwqkp6J354eLJMKyhvsFdPELAos0VuBfMoVKoU=",
"ModifyIndex": 31,
"Name": "api-prod"
2017-09-19 14:47:10 +00:00
}
```
## Create or Update Namespace
This endpoint is used to create or update a namespace.
2020-02-06 23:45:31 +00:00
| Method | Path | Produces |
| ------ | ------------------------------------------------- | ------------------ |
| `POST` | `/v1/namespace/:namespace` <br /> `/v1/namespace` | `application/json` |
2017-09-19 14:47:10 +00:00
The table below shows this endpoint's support for
[blocking queries](/api-docs#blocking-queries) and
[required ACLs](/api-docs#acls).
2017-09-19 14:47:10 +00:00
| Blocking Queries | ACL Required |
| ---------------- | ------------ |
| `NO` | `management` |
### Parameters
- `Name` `(string: <required>)`- Specifies the namespace to create or
2017-09-19 14:47:10 +00:00
update.
- `Description` `(string: "")` - Specifies an optional human-readable
description of the namespace.
- `Quota` `(string: "")` - Specifies an quota to attach to the namespace.
2017-09-19 14:47:10 +00:00
### Sample Payload
```javascript
{
"Name": "api-prod",
"Description": "Production API Servers",
"Quota": "prod-quota"
2017-09-19 14:47:10 +00:00
}
2020-02-06 23:45:31 +00:00
```
2017-09-19 14:47:10 +00:00
### Sample Request
2020-05-18 20:53:06 +00:00
```shell-session
$ curl \
2017-09-19 14:47:10 +00:00
--request POST \
--data @namespace.json \
https://localhost:4646/v1/namespace/api-prod
2017-09-19 14:47:10 +00:00
```
2020-05-18 20:53:06 +00:00
```shell-session
$ curl \
2017-09-19 14:47:10 +00:00
--request POST \
--data @namespace.json \
https://localhost:4646/v1/namespace
2017-09-19 14:47:10 +00:00
```
## Delete Namespace
This endpoint is used to delete a namespace.
2020-02-06 23:45:31 +00:00
| Method | Path | Produces |
| -------- | -------------------------- | ------------------ |
| `DELETE` | `/v1/namespace/:namespace` | `application/json` |
2017-09-19 14:47:10 +00:00
The table below shows this endpoint's support for
[blocking queries](/api-docs#blocking-queries) and
[required ACLs](/api-docs#acls).
2017-09-19 14:47:10 +00:00
| Blocking Queries | ACL Required |
| ---------------- | ------------ |
| `NO` | `management` |
### Parameters
- `:namespace` `(string: <required>)`- Specifies the namespace to delete.
### Sample Request
2020-05-18 20:53:06 +00:00
```shell-session
$ curl \
2017-09-19 14:47:10 +00:00
--request DELETE \
https://localhost:4646/v1/namespace/api-prod
2017-09-19 14:47:10 +00:00
```