consul/website/content/commands/namespace/read.mdx

82 lines
2.0 KiB
Plaintext
Raw Normal View History

---
layout: commands
2020-04-07 18:55:19 +00:00
page_title: 'Commands: Namespace Read'
---
# Consul Namespace Read
Command: `consul namespace read`
2022-01-11 13:26:58 +00:00
Corresponding HTTP API Endpoint: [\[GET\] /v1/namespace/:name](/api-docs/namespaces#read-a-namespace)
<EnterpriseAlert />
This `namespace read` command reads a namespaces configuration. This was added in Consul Enterprise 1.7.0. If
ACLs are enabled then this command will require a token with `operator:read` privileges or any `read` privileges
within the target namespace.
The table below shows this command's [required ACLs](/api#authentication). Configuration of
[blocking queries](/api-docs/features/blocking) and [agent caching](/api-docs/features/caching)
are not supported from commands, but may be from the corresponding HTTP endpoint.
| ACL Required |
| ------------------------------------------------- |
| `operator:read` or `namespace:*:read`<sup>1</sup> |
<sup>1</sup> Access can be granted to list the Namespace if the token used when making
the request has been granted any access in the namespace (read, list or write).
## Usage
Usage: `consul namespace read <name>`
#### Command Options
2020-04-07 18:55:19 +00:00
- `-format=<string>` - How to output the results. The choices are: pretty or json
2020-04-07 18:55:19 +00:00
- `-meta` - Indicates that namespace metadata such as the raft indices should be
shown for the namespace
2020-04-07 18:55:19 +00:00
#### API Options
@include 'http_api_partition_options.mdx'
@include 'http_api_options_client.mdx'
@include 'http_api_options_server.mdx'
## Examples
Read a Namespace:
2020-05-19 18:32:38 +00:00
```shell-session
$ consul namespace read "team-1"
Name: team-1
Description:
```
Showing Raft Metadata:
2020-05-19 18:32:38 +00:00
```shell-session
$ consul namespace read -meta "team-1"
Name: team-1
Description:
Create Index: 339
Modify Index: 344
```
JSON Format:
2020-05-19 18:32:38 +00:00
```shell-session
$ consul namespace read -format=json foo
{
"Name": "foo",
"Description": "Example Namespace",
"Meta": {
"team-id": "574407f3-8b26-4c84-8e51-028bb8cbdd37"
},
"CreateIndex": 352,
"ModifyIndex": 352
}
```