open-consul/website/pages/commands/namespace/write.mdx
Jasmine W 8ae3332165
docs: update structure (#8506)
- moved and renamed files/folders based on new structure
- updated docs navigation based on new structure
- moved CLI to top nav (created commands.jsx and commands-navigation.js)
- updated and added redirects
- updating to be consistent with standalone categories
- changing "overview" link in top nav to lead to where intro was moved (docs/intro)
- adding redirects for intro content
- deleting old intro folders
- format all data/navigation files
- deleting old commands folder
- reverting changes to glossary page
- adjust intro navigation for removal of 'vs' paths
- add helm page redirect
- fix more redirects
- add a missing redirect
- fix broken anchor links and formatting mistakes
- deleted duplicate section, added redirect, changed link
- removed duplicate glossary page
2020-09-01 11:14:13 -04:00

76 lines
1.6 KiB
Plaintext

---
layout: commands
page_title: 'Commands: Namespace Write'
sidebar_title: write
---
# Consul Namespace Write
Command: `consul namespace write`
<EnterpriseAlert />
This `namespace write` command creates or updates a namespace's configuration from its full definition. This was added in Consul Enterprise 1.7.0.
## 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
or HCL format. See [here](/docs/enterprise/namespaces#namespace-definition) for a description of the namespace definition.
#### API Options
@include 'http_api_options_client.mdx'
@include 'http_api_options_server.mdx'
#### Command Options
- `-format=<string>` - How to output the results. The choices are: pretty or json
- `-meta` - Indicates that namespace metadata such as the raft indices should be
shown for the namespace
## Examples
Create a new Namespace:
```shell-session
$ consul namespace write - <<< 'Name = "team-1"'
Name: team-1
Description:
```
Showing Raft Metadata:
```shell-session
$ consul namespace write -meta - <<< 'Name = "team-1"'
Name: team-1
Description:
Create Index: 339
Modify Index: 344
```
JSON Format:
```shell-session
$ 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
}
```