Skip to content

Commit c88b7d3

Browse files
authored
Merge pull request ceph#58951 from rhcs-dashboard/ceph-users-doc-fix
mgr/dashboard: fix ceph-users api Reviewed-by: Zac Dover <[email protected]>
2 parents 6b5076b + d8ce3da commit c88b7d3

File tree

2 files changed

+63
-25
lines changed

2 files changed

+63
-25
lines changed

src/pybind/mgr/dashboard/controllers/ceph_users.py

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from ..security import Scope
77
from ..services.ceph_service import CephService, SendCommandError
88
from . import APIDoc, APIRouter, CRUDCollectionMethod, CRUDEndpoint, \
9-
EndpointDoc, RESTController, SecretStr
9+
EndpointDoc, Param, RESTController, SecretStr
1010
from ._crud import ArrayHorizontalContainer, CRUDMeta, Form, FormField, \
1111
FormTaskInfo, Icon, MethodType, SelectionType, TableAction, Validator, \
1212
VerticalContainer
@@ -40,17 +40,15 @@ def _run_auth_command(command: str, *args, **kwargs):
4040
@staticmethod
4141
def user_list(_):
4242
"""
43-
Get list of ceph users and its respective data
43+
Get list of ceph users and its associated data
4444
"""
4545
return CephUserEndpoints._run_auth_command('auth ls')["auth_dump"]
4646

4747
@staticmethod
4848
def user_create(_, user_entity: str = '', capabilities: Optional[List[Cap]] = None,
4949
import_data: str = ''):
5050
"""
51-
Add a ceph user with its defined capabilities.
52-
:param user_entity: Entity to change
53-
:param capabilities: List of capabilities to add to user_entity
51+
Add a Ceph user, with its defined capabilities.
5452
"""
5553
# Caps are represented as a vector in mon auth add commands.
5654
# Look at AuthMonitor.cc::valid_caps for reference.
@@ -75,7 +73,6 @@ def user_create(_, user_entity: str = '', capabilities: Optional[List[Cap]] = No
7573
def user_delete(_, user_entity: str):
7674
"""
7775
Delete a ceph user and it's defined capabilities.
78-
:param user_entity: Entity to delete
7976
"""
8077
logger.debug("Sending command 'auth del' of entity '%s'", user_entity)
8178
CephUserEndpoints._run_auth_command('auth del', entity=user_entity)
@@ -94,8 +91,6 @@ def user_edit(_, user_entity: str = '', capabilities: List[Cap] = None):
9491
"""
9592
Change the ceph user capabilities.
9693
Setting new capabilities will overwrite current ones.
97-
:param user_entity: Entity to change
98-
:param capabilities: List of updated capabilities to user_entity
9994
"""
10095
caps = []
10196
for cap in capabilities:
@@ -188,19 +183,36 @@ def model(user_entity: str):
188183
resource='user',
189184
get_all=CRUDCollectionMethod(
190185
func=CephUserEndpoints.user_list,
191-
doc=EndpointDoc("Get Ceph Users")
186+
doc=EndpointDoc("Get list of ceph users")
192187
),
193188
create=CRUDCollectionMethod(
194189
func=CephUserEndpoints.user_create,
195-
doc=EndpointDoc("Create Ceph User")
190+
doc=EndpointDoc("Create Ceph User",
191+
parameters={
192+
"user_entity": Param(str, "Entity to add"),
193+
'capabilities': Param([{
194+
"entity": (str, "Entity to add"),
195+
"cap": (str, "Capability to add; eg. allow *")
196+
}], 'List of capabilities to add to user_entity')
197+
})
196198
),
197199
edit=CRUDCollectionMethod(
198200
func=CephUserEndpoints.user_edit,
199-
doc=EndpointDoc("Edit Ceph User")
201+
doc=EndpointDoc("Edit Ceph User Capabilities",
202+
parameters={
203+
"user_entity": Param(str, "Entity to edit"),
204+
'capabilities': Param([{
205+
"entity": (str, "Entity to edit"),
206+
"cap": (str, "Capability to edit; eg. allow *")
207+
}], 'List of updated capabilities to user_entity')
208+
})
200209
),
201210
delete=CRUDCollectionMethod(
202211
func=CephUserEndpoints.user_delete,
203-
doc=EndpointDoc("Delete Ceph User")
212+
doc=EndpointDoc("Delete Ceph User",
213+
parameters={
214+
"user_entity": Param(str, "Entity to delete")
215+
})
204216
),
205217
extra_endpoints=[
206218
('export', CRUDCollectionMethod(

src/pybind/mgr/dashboard/openapi.yaml

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3740,7 +3740,7 @@ paths:
37403740
- Upgrade
37413741
/api/cluster/user:
37423742
get:
3743-
description: "\n Get list of ceph users and its respective data\n \
3743+
description: "\n Get list of ceph users and its associated data\n \
37443744
\ "
37453745
parameters: []
37463746
responses:
@@ -3760,26 +3760,39 @@ paths:
37603760
trace.
37613761
security:
37623762
- jwt: []
3763-
summary: Get Ceph Users
3763+
summary: Get list of ceph users
37643764
tags:
37653765
- Cluster
37663766
post:
3767-
description: "\n Add a ceph user with its defined capabilities.\n \
3768-
\ :param user_entity: Entity to change\n :param capabilities: List\
3769-
\ of capabilities to add to user_entity\n "
3767+
description: "\n Add a Ceph user, with its defined capabilities.\n \
3768+
\ "
37703769
parameters: []
37713770
requestBody:
37723771
content:
37733772
application/json:
37743773
schema:
37753774
properties:
37763775
capabilities:
3777-
type: string
3776+
description: List of capabilities to add to user_entity
3777+
items:
3778+
properties:
3779+
cap:
3780+
description: Capability to add; eg. allow *
3781+
type: string
3782+
entity:
3783+
description: Entity to add
3784+
type: string
3785+
required:
3786+
- entity
3787+
- cap
3788+
type: object
3789+
type: array
37783790
import_data:
37793791
default: ''
37803792
type: string
37813793
user_entity:
37823794
default: ''
3795+
description: Entity to add
37833796
type: string
37843797
type: object
37853798
responses:
@@ -3809,19 +3822,31 @@ paths:
38093822
- Cluster
38103823
put:
38113824
description: "\n Change the ceph user capabilities.\n Setting\
3812-
\ new capabilities will overwrite current ones.\n :param user_entity:\
3813-
\ Entity to change\n :param capabilities: List of updated capabilities\
3814-
\ to user_entity\n "
3825+
\ new capabilities will overwrite current ones.\n "
38153826
parameters: []
38163827
requestBody:
38173828
content:
38183829
application/json:
38193830
schema:
38203831
properties:
38213832
capabilities:
3822-
type: string
3833+
description: List of updated capabilities to user_entity
3834+
items:
3835+
properties:
3836+
cap:
3837+
description: Capability to edit; eg. allow *
3838+
type: string
3839+
entity:
3840+
description: Entity to edit
3841+
type: string
3842+
required:
3843+
- entity
3844+
- cap
3845+
type: object
3846+
type: array
38233847
user_entity:
38243848
default: ''
3849+
description: Entity to edit
38253850
type: string
38263851
type: object
38273852
responses:
@@ -3846,7 +3871,7 @@ paths:
38463871
trace.
38473872
security:
38483873
- jwt: []
3849-
summary: Edit Ceph User
3874+
summary: Edit Ceph User Capabilities
38503875
tags:
38513876
- Cluster
38523877
/api/cluster/user/export:
@@ -3890,9 +3915,10 @@ paths:
38903915
/api/cluster/user/{user_entity}:
38913916
delete:
38923917
description: "\n Delete a ceph user and it's defined capabilities.\n\
3893-
\ :param user_entity: Entity to delete\n "
3918+
\ "
38943919
parameters:
3895-
- in: path
3920+
- description: Entity to delete
3921+
in: path
38963922
name: user_entity
38973923
required: true
38983924
schema:

0 commit comments

Comments
 (0)