Skip to content

Commit a2f7fa3

Browse files
committed
Add more examples
1 parent 7734bff commit a2f7fa3

File tree

32 files changed

+662
-3
lines changed

32 files changed

+662
-3
lines changed

specification/security/authenticate/examples/response/SecurityAuthenticateResponseExample1.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ value: |-
2121
"type" : "file"
2222
},
2323
"authentication_type": "realm"
24-
}
24+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
summary: Bulk delete example 1
2+
# method_request: DELETE /_security/role
3+
description: >
4+
Run DELETE /_security/role` to delete `my_admin_role` and `my_user_role` roles.
5+
# type: request
6+
value: |-
7+
{
8+
"names": ["my_admin_role", "my_user_role"]
9+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
summary: A successful response
2+
description: A successful response from `DELETE /_security/role`.
3+
# type: response
4+
# response_code:
5+
value: |-
6+
{
7+
"deleted": [
8+
"my_admin_role",
9+
"my_user_role"
10+
]
11+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
summary: A response with not_found roles
2+
description: >
3+
A partially successful response from `DELETE /_security/role`.
4+
If a role cannot be found, it appears in the `not_found` list in the response.
5+
# type: response
6+
# response_code:
7+
value: |-
8+
{
9+
"deleted": [
10+
"my_admin_role"
11+
],
12+
"not_found": [
13+
"not_an_existing_role"
14+
]
15+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
summary: A response with errors
2+
description: >
3+
A partially successful response from `DELETE /_security/role`.
4+
If part of a request fails or is invalid, the response includes `errors`.
5+
# type: response
6+
# response_code:
7+
value: |-
8+
{
9+
"deleted": [
10+
"my_admin_role"
11+
],
12+
"errors": {
13+
"count": 1,
14+
"details": {
15+
"superuser": {
16+
"type": "illegal_argument_exception",
17+
"reason": "role [superuser] is reserved and cannot be deleted"
18+
}
19+
}
20+
}
21+
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
summary: Bulk role success
2+
# method_request: POST /_security/role
3+
description: >
4+
Run `POST /_security/role` to add roles called `my_admin_role` and `my_user_role`.
5+
# type: request
6+
value: |-
7+
{
8+
"roles": {
9+
"my_admin_role": {
10+
"cluster": [
11+
"all"
12+
],
13+
"indices": [
14+
{
15+
"names": [
16+
"index1",
17+
"index2"
18+
],
19+
"privileges": [
20+
"all"
21+
],
22+
"field_security": {
23+
"grant": [
24+
"title",
25+
"body"
26+
]
27+
},
28+
"query": "{\"match\": {\"title\": \"foo\"}}"
29+
}
30+
],
31+
"applications": [
32+
{
33+
"application": "myapp",
34+
"privileges": [
35+
"admin",
36+
"read"
37+
],
38+
"resources": [
39+
"*"
40+
]
41+
}
42+
],
43+
"run_as": [
44+
"other_user"
45+
],
46+
"metadata": {
47+
"version": 1
48+
}
49+
},
50+
"my_user_role": {
51+
"cluster": [
52+
"all"
53+
],
54+
"indices": [
55+
{
56+
"names": [
57+
"index1"
58+
],
59+
"privileges": [
60+
"read"
61+
],
62+
"field_security": {
63+
"grant": [
64+
"title",
65+
"body"
66+
]
67+
},
68+
"query": "{\"match\": {\"title\": \"foo\"}}"
69+
}
70+
],
71+
"applications": [
72+
{
73+
"application": "myapp",
74+
"privileges": [
75+
"admin",
76+
"read"
77+
],
78+
"resources": [
79+
"*"
80+
]
81+
}
82+
],
83+
"run_as": [
84+
"other_user"
85+
],
86+
"metadata": {
87+
"version": 1
88+
}
89+
}
90+
}
91+
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
summary: Bulk role errors
2+
# method_request: POST /_security/role
3+
description: >
4+
Because errors are handled individually for each role create or update, the API allows partial success.
5+
For example, `POST /_security/role` would throw an error for `my_admin_role` because the privilege `bad_cluster_privilege` doesn't exist, but would be successful for the `my_user_role`.
6+
# type: request
7+
value: |-
8+
{
9+
"roles": {
10+
"my_admin_role": {
11+
"cluster": [
12+
"bad_cluster_privilege"
13+
],
14+
"indices": [
15+
{
16+
"names": [
17+
"index1",
18+
"index2"
19+
],
20+
"privileges": ["all"],
21+
"field_security": {
22+
"grant": [
23+
"title",
24+
"body"
25+
]
26+
},
27+
"query": "{\"match\": {\"title\": \"foo\"}}"
28+
}
29+
],
30+
"applications": [
31+
{
32+
"application": "myapp",
33+
"privileges": [
34+
"admin",
35+
"read"
36+
],
37+
"resources": [
38+
"*"
39+
]
40+
}
41+
],
42+
"run_as": [
43+
"other_user"
44+
],
45+
"metadata": {
46+
"version": 1
47+
}
48+
},
49+
"my_user_role": {
50+
"cluster": [
51+
"all"
52+
],
53+
"indices": [
54+
{
55+
"names": [
56+
"index1"
57+
],
58+
"privileges": [
59+
"read"
60+
],
61+
"field_security": {
62+
"grant": [
63+
"title",
64+
"body"
65+
]
66+
},
67+
"query": "{\"match\": {\"title\": \"foo\"}}"
68+
}
69+
],
70+
"applications": [
71+
{
72+
"application": "myapp",
73+
"privileges": [
74+
"admin",
75+
"read"
76+
],
77+
"resources": [
78+
"*"
79+
]
80+
}
81+
],
82+
"run_as": [
83+
"other_user"
84+
],
85+
"metadata": {
86+
"version": 1
87+
}
88+
}
89+
}
90+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
summary: Role example 3
2+
# method_request: POST /_security/role/only_remote_access_role
3+
description: Run `POST /_security/role/only_remote_access_role` to configure a role with remote indices and remote cluster privileges for a remote cluster.
4+
# type: request
5+
value: |-
6+
{
7+
"remote_indices": [
8+
{
9+
"clusters": ["my_remote"],
10+
"names": ["logs*"],
11+
"privileges": ["read", "read_cross_cluster", "view_index_metadata"]
12+
}
13+
],
14+
"remote_cluster": [
15+
{
16+
"clusters": ["my_remote"],
17+
"privileges": ["monitor_stats"]
18+
}
19+
]
20+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
summary: A successful response
2+
description: >
3+
A successful response from `POST /_security/role/my_admin_role` returns a JSON structure that shows whether the role has been created, updated, or had no changes made.
4+
# type: response
5+
# response_code:
6+
value: |-
7+
{
8+
"created": [
9+
"my_admin_role",
10+
"my_user_role"
11+
]
12+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
summary: A partially successful response
2+
description: >
3+
A partially successful response from `POST /_security/role`.
4+
Errors are handled individually for each role create or update, thus the API allows partial success.
5+
In this example, the creation of the `my_user_role` role succeeds and the `my_admin_role` role fails.
6+
# type: response
7+
# response_code:
8+
value: |-
9+
{
10+
"created": [
11+
"my_user_role"
12+
],
13+
"errors": {
14+
"count": 1,
15+
"details": {
16+
"my_admin_role": {
17+
"type": "action_request_validation_exception",
18+
"reason": "Validation Failed: 1: unknown cluster privilege [bad_cluster_privilege]. a privilege must be either one of the predefined cluster privilege names [manage_own_api_key,manage_data_stream_global_retention,monitor_data_stream_global_retention,none,cancel_task,cross_cluster_replication,cross_cluster_search,delegate_pki,grant_api_key,manage_autoscaling,manage_index_templates,manage_logstash_pipelines,manage_oidc,manage_saml,manage_search_application,manage_search_query_rules,manage_search_synonyms,manage_service_account,manage_token,manage_user_profile,monitor_connector,monitor_enrich,monitor_inference,monitor_ml,monitor_rollup,monitor_snapshot,monitor_stats,monitor_text_structure,monitor_watcher,post_behavioral_analytics_event,read_ccr,read_connector_secrets,read_fleet_secrets,read_ilm,read_pipeline,read_security,read_slm,transport_client,write_connector_secrets,write_fleet_secrets,create_snapshot,manage_behavioral_analytics,manage_ccr,manage_connector,manage_enrich,manage_ilm,manage_inference,manage_ml,manage_rollup,manage_slm,manage_watcher,monitor_data_frame_transforms,monitor_transform,manage_api_key,manage_ingest_pipelines,manage_pipeline,manage_data_frame_transforms,manage_transform,manage_security,monitor,manage,all] or a pattern over one of the available cluster actions;"
19+
}
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)