2019-12-06 16:14:56 +00:00
|
|
|
---
|
2020-04-07 18:55:19 +00:00
|
|
|
layout: docs
|
|
|
|
page_title: 'Commands: Namespace Write'
|
2020-04-13 18:40:26 +00:00
|
|
|
sidebar_title: write
|
2019-12-06 16:14:56 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
# Consul Namespace Write
|
|
|
|
|
2020-04-07 23:56:08 +00:00
|
|
|
<EnterpriseAlert product="consul" />
|
|
|
|
|
2019-12-06 16:14:56 +00:00
|
|
|
Command: `consul namespace write`
|
|
|
|
|
2020-03-16 13:42:39 +00:00
|
|
|
This `namespace write` command creates or updates a namespace's configuration from its full definition. This was added in Consul Enterprise 1.7.0.
|
2019-12-06 16:14:56 +00:00
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
Usage: `consul namespace write <namespace definition>`
|
|
|
|
|
|
|
|
The `<namespace definition>` must either be a file path or `-` to indicate that
|
|
|
|
the definition should be read from stdin. The definition can be in either JSON
|
2020-04-09 23:20:00 +00:00
|
|
|
or HCL format. See [here](/docs/enterprise/namespaces#namespace-definition) for a description of the namespace definition.
|
2019-12-06 16:14:56 +00:00
|
|
|
|
|
|
|
#### API Options
|
|
|
|
|
2020-04-07 18:55:19 +00:00
|
|
|
@include 'http_api_options_client.mdx'
|
2020-04-07 23:56:08 +00:00
|
|
|
|
2020-04-07 18:55:19 +00:00
|
|
|
@include 'http_api_options_server.mdx'
|
2019-12-06 16:14:56 +00:00
|
|
|
|
|
|
|
#### Command Options
|
|
|
|
|
2020-04-07 18:55:19 +00:00
|
|
|
- `-format=<string>` - How to output the results. The choices are: pretty or json
|
2019-12-06 16:14:56 +00:00
|
|
|
|
2020-04-07 18:55:19 +00:00
|
|
|
- `-meta` - Indicates that namespace metadata such as the raft indices should be
|
2019-12-06 16:14:56 +00:00
|
|
|
shown for the namespace
|
2020-04-07 18:55:19 +00:00
|
|
|
|
2019-12-06 16:14:56 +00:00
|
|
|
## Examples
|
|
|
|
|
|
|
|
Create a new Namespace:
|
|
|
|
|
2020-04-07 23:56:08 +00:00
|
|
|
```shell
|
2019-12-06 16:14:56 +00:00
|
|
|
$ consul namespace write - <<< 'Name = "team-1"'
|
|
|
|
Name: team-1
|
|
|
|
Description:
|
|
|
|
```
|
|
|
|
|
|
|
|
Showing Raft Metadata:
|
|
|
|
|
2020-04-07 23:56:08 +00:00
|
|
|
```shell
|
2019-12-06 16:14:56 +00:00
|
|
|
$ consul namespace write -meta - <<< 'Name = "team-1"'
|
|
|
|
Name: team-1
|
|
|
|
Description:
|
|
|
|
Create Index: 339
|
|
|
|
Modify Index: 344
|
|
|
|
```
|
|
|
|
|
|
|
|
JSON Format:
|
|
|
|
|
2020-04-07 23:56:08 +00:00
|
|
|
```shell
|
2019-12-06 16:14:56 +00:00
|
|
|
$ cat ns.hcl
|
|
|
|
Name = "foo"
|
|
|
|
Description = "Example Namespace"
|
|
|
|
Meta {
|
|
|
|
team-id = "574407f3-8b26-4c84-8e51-028bb8cbdd37"
|
|
|
|
}
|
|
|
|
$ consul namespace write -format=json ns.hcl
|
|
|
|
{
|
|
|
|
"Name": "foo",
|
|
|
|
"Description": "Example Namespace",
|
|
|
|
"Meta": {
|
|
|
|
"team-id": "574407f3-8b26-4c84-8e51-028bb8cbdd37"
|
|
|
|
},
|
|
|
|
"CreateIndex": 352,
|
|
|
|
"ModifyIndex": 352
|
|
|
|
}
|
|
|
|
```
|