2017-09-19 14:47:10 +00:00
|
|
|
---
|
|
|
|
layout: api
|
|
|
|
page_title: Namespace - HTTP API
|
2020-02-06 23:45:31 +00:00
|
|
|
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
|
2020-03-20 22:24:56 +00:00
|
|
|
[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 \
|
2018-01-29 16:27:52 +00:00
|
|
|
https://localhost:4646/v1/namespaces
|
2017-09-19 14:47:10 +00:00
|
|
|
```
|
|
|
|
|
2020-05-18 20:53:06 +00:00
|
|
|
```shell-session
|
|
|
|
$ curl \
|
2018-01-29 16:27:52 +00:00
|
|
|
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
|
2020-03-20 22:24:56 +00:00
|
|
|
[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 \
|
2018-01-29 16:27:52 +00:00
|
|
|
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
|
2020-03-20 22:24:56 +00:00
|
|
|
[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
|
|
|
|
|
2019-08-01 14:49:41 +00:00
|
|
|
- `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.
|
|
|
|
|
2019-09-09 20:48:58 +00:00
|
|
|
- `Quota` `(string: "")` - Specifies an quota to attach to the namespace.
|
|
|
|
|
2017-09-19 14:47:10 +00:00
|
|
|
### Sample Payload
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
{
|
2019-07-31 21:05:48 +00:00
|
|
|
"Name": "api-prod",
|
2019-09-09 20:48:58 +00:00
|
|
|
"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 \
|
2018-01-29 16:27:52 +00:00
|
|
|
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 \
|
2018-01-29 16:27:52 +00:00
|
|
|
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
|
2020-03-20 22:24:56 +00:00
|
|
|
[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 \
|
2018-01-29 16:27:52 +00:00
|
|
|
https://localhost:4646/v1/namespace/api-prod
|
2017-09-19 14:47:10 +00:00
|
|
|
```
|