Skip to content

Commit d0897aa

Browse files
committed
add users commands
1 parent b3549e8 commit d0897aa

9 files changed

Lines changed: 703 additions & 113 deletions

File tree

docs/cli/users.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Users Commands
2+
3+
::: mkdocs-click
4+
:module: incydr.cli.cmds.users
5+
:command: list_
6+
7+
::: mkdocs-click
8+
:module: incydr.cli.cmds.users
9+
:command: show
10+
11+
::: mkdocs-click
12+
:module: incydr.cli.cmds.users
13+
:command: list_devices
14+
15+
::: mkdocs-click
16+
:module: incydr.cli.cmds.users
17+
:command: list_roles
18+
19+
::: mkdocs-click
20+
:module: incydr.cli.cmds.users
21+
:command: update_roles
22+
23+
::: mkdocs-click
24+
:module: incydr.cli.cmds.users
25+
:command: activate
26+
27+
::: mkdocs-click
28+
:module: incydr.cli.cmds.users
29+
:command: deactivate
30+
31+
::: mkdocs-click
32+
:module: incydr.cli.cmds.users
33+
:command: move
34+
35+
::: mkdocs-click
36+
:module: incydr.cli.cmds.users
37+
:command: bulk_update_roles
38+
39+
::: mkdocs-click
40+
:module: incydr.cli.cmds.users
41+
:command: bulk_activate
42+
43+
::: mkdocs-click
44+
:module: incydr.cli.cmds.users
45+
:command: bulk_deactivate
46+
47+
::: mkdocs-click
48+
:module: incydr.cli.cmds.users
49+
:command: bulk_move

incydr/_devices/models.py

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -45,125 +45,99 @@ class Device(ResponseModel):
4545
"""
4646

4747
device_id: Optional[str] = Field(
48-
allow_mutation=False,
4948
alias="deviceId",
5049
description="A globally unique ID (guid) for this device.",
5150
)
5251
legacy_device_id: Optional[str] = Field(
53-
allow_mutation=False,
5452
alias="legacyDeviceId",
5553
description="The device ID to use for older console-based APIs that require a device Id.",
5654
)
5755
name: Optional[str] = Field(None, description="Device name.")
5856
os_hostname: Optional[str] = Field(
59-
allow_mutation=False,
6057
alias="osHostname",
6158
description="Device Hostname according to the device's OS.",
6259
)
6360
status: Optional[str] = Field(
64-
allow_mutation=False,
6561
description="Device status. Values: Active, Deactivated, Blocked, Deauthorized (Active/Deactivated followed by optional Blocked and/or Deauthorized)",
6662
)
6763
active: Optional[bool] = Field(
68-
allow_mutation=False,
6964
description="True means the device will show up on reports, etc.",
7065
)
7166
blocked: Optional[bool] = Field(
72-
allow_mutation=False,
7367
description="True means device continues backing up, but restores and logins are disabled.",
7468
)
7569
alert_state: Optional[int] = Field(
76-
allow_mutation=False,
7770
alias="alertState",
7871
description="0=ok, 1=connection warning, 2=connection critical",
7972
)
8073
user_id: Optional[str] = Field(
81-
allow_mutation=False,
8274
alias="userId",
8375
description="A globally unique ID for this user.",
8476
)
8577
legacy_user_id: Optional[str] = Field(
86-
allow_mutation=False,
8778
alias="legacyUserId",
8879
description='The user ID to use for older console-based APIs that require a user Id.\r\nIf your endpoint domain starts with "console" instead of "api", use this Id for endpoints that require a userId.',
8980
)
9081
org_id: Optional[str] = Field(
91-
allow_mutation=False,
9282
alias="orgId",
9383
description="An ID for the Code42 organization of the user owning this device.",
9484
)
9585
legacy_org_id: Optional[str] = Field(
96-
allow_mutation=False,
9786
alias="legacyOrgId",
9887
description='The org ID to use for older console-based APIs that require an org Id.\r\nIf your endpoint domain starts with "console" instead of "api", use this Id for endpoints that require an orgId.',
9988
)
10089
org_guid: Optional[str] = Field(
101-
allow_mutation=False, alias="orgGuid", description="The globally unique org ID."
90+
alias="orgGuid", description="The globally unique org ID."
10291
)
10392
external_reference: Optional[str] = Field(
104-
allow_mutation=False,
10593
alias="externalReferenceInfo",
10694
description="Optional external reference information, such as a serial number, asset tag, employee ID, or help desk issue ID.",
10795
)
10896
notes: Optional[str] = Field(None, description="Optional descriptive information.")
10997
last_connected: Optional[datetime] = Field(
110-
allow_mutation=False,
11198
alias="lastConnected",
11299
description="The last day and time this device was connected to the server.",
113100
)
114101
os_name: Optional[str] = Field(
115-
allow_mutation=False,
116102
alias="osHostname",
117103
description="Operating system name. Values: Windows*, Mac OS X, Linux, Android, iOS, SunOS, etc",
118104
)
119105
os_version: Optional[str] = Field(
120-
allow_mutation=False,
121106
alias="osVersion",
122107
description="Operating system version. Values: 10.5.1, 6.2, etc",
123108
)
124109
os_arch: Optional[str] = Field(
125-
allow_mutation=False,
126110
alias="osArch",
127111
description="Hardware architecture. Values: i386, amd64, sparc, x86, etc",
128112
)
129113
address: Optional[str] = Field(
130-
allow_mutation=False,
131114
description="Internal IP address and port. Example: 192.168.42.1:4282",
132115
)
133116
remote_address: Optional[str] = Field(
134-
allow_mutation=False,
135117
alias="remoteAddress",
136118
description="External IP address and port. Example: 171.22.110.41:13958",
137119
)
138120
time_zone: Optional[str] = Field(
139-
allow_mutation=False,
140121
alias="timeZone",
141122
description="Examples: Australia/Canberra, Asia/Calcutta",
142123
)
143124
version: Optional[str] = Field(None, description="Device product display version.")
144125
build: Optional[int] = Field(
145-
allow_mutation=False,
146126
description="Device build version long number, will only be applicable to CP4/SP devices.",
147127
)
148128
creation_date: Optional[datetime] = Field(
149-
allow_mutation=False,
150129
alias="creationDate",
151130
description="Date and time this device was created.",
152131
)
153132
modification_date: Optional[datetime] = Field(
154-
allow_mutation=False,
155133
alias="modificationDate",
156134
description="Date and time this device was last modified.",
157135
)
158136
login_date: Optional[datetime] = Field(
159-
allow_mutation=False,
160137
alias="loginDate",
161138
description="Date and time this device was last logged in.",
162139
)
163140

164-
class Config:
165-
validate_assignment = True
166-
167141

168142
class DevicesPage(ResponseModel):
169143
"""

incydr/_users/client.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@
1818
from incydr.enums.devices import SortKeys
1919

2020

21+
class UsersClient:
22+
def __init__(self, parent):
23+
self._parent = parent
24+
self._v1 = None
25+
26+
@property
27+
def v1(self):
28+
if self._v1 is None:
29+
self._v1 = UsersV1(self._parent)
30+
return self._v1
31+
32+
2133
class UsersV1:
2234
"""Client for `/v1/users` endpoints.
2335
@@ -228,15 +240,3 @@ def deactivate(self, user_id: str) -> Response:
228240
229241
"""
230242
return self._parent.session.post(f"/v1/users/{user_id}/deactivate")
231-
232-
233-
class UsersClient:
234-
def __init__(self, parent):
235-
self._parent = parent
236-
self._v1 = None
237-
238-
@property
239-
def v1(self):
240-
if self._v1 is None:
241-
self._v1 = UsersV1(self._parent)
242-
return self._v1

incydr/_users/models.py

Lines changed: 6 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
from pydantic import BaseModel
88
from pydantic import Field
9+
from rich.markdown import Markdown
910

11+
from incydr._core.models import Model
1012
from incydr._core.models import ResponseModel
1113

1214

@@ -38,75 +40,59 @@ class User(ResponseModel):
3840
'user Id. If your endpoint domain starts with "console" '
3941
'instead of "api", use this Id for endpoints that require a '
4042
"userId.",
41-
allow_mutation=False,
4243
)
4344
user_id: Optional[str] = Field(
4445
alias="userId",
4546
description="A globally unique ID for this user.",
46-
allow_mutation=False,
4747
)
4848
username: Optional[str] = Field(
4949
description="The name the user uses to log in to Code42.",
50-
allow_mutation=False,
5150
)
5251
first_name: Optional[str] = Field(
5352
alias="firstName",
5453
description="The first (given) name of the user.",
55-
allow_mutation=False,
5654
)
5755
last_name: Optional[str] = Field(
5856
alias="lastName",
5957
description="The last (family) name of the user.",
60-
allow_mutation=False,
6158
)
6259
legacy_org_id: Optional[str] = Field(
6360
alias="legacyOrgId",
6461
description="The org ID to use for older console-based APIs that require an "
6562
'org Id. If your endpoint domain starts with "console" instead '
6663
'of "api", use this Id for endpoints that require an orgId.',
67-
allow_mutation=False,
6864
)
6965
org_id: Optional[str] = Field(
7066
alias="orgId",
7167
description="The ID of the Code42 organization this user belongs to.",
72-
allow_mutation=False,
7368
)
7469
org_guid: Optional[str] = Field(
7570
alias="orgGuid",
7671
description="The unique org ID of the Code42 organization this user belongs to. This value should be used for actions conducted through the org APIs.",
77-
allow_mutation=False,
7872
)
7973
org_name: Optional[str] = Field(
8074
alias="orgName",
8175
description="The name of the Code42 organization this user belongs to.",
82-
allow_mutation=False,
8376
)
8477
notes: Optional[str] = Field(
8578
description="Descriptive information about the user.",
86-
allow_mutation=False,
79+
table=lambda f: f if f is None else Markdown(f),
8780
)
8881
active: Optional[bool] = Field(
8982
description="Whether or not the user is enabled.",
90-
allow_mutation=False,
9183
)
9284
blocked: Optional[bool] = Field(
9385
description="Whether or not logins and restores are disabled for the user.",
94-
allow_mutation=False,
9586
)
9687
creation_date: Optional[datetime] = Field(
97-
allow_mutation=False,
9888
alias="creationDate",
9989
description="The date and time the user was created.",
10090
)
10191
modification_date: Optional[datetime] = Field(
102-
allow_mutation=False,
10392
alias="modificationDate",
10493
description="The date and time the user was last modified.",
10594
)
10695

107-
class Config:
108-
validate_assignment = True
109-
11096

11197
class UsersPage(ResponseModel):
11298
"""
@@ -124,16 +110,13 @@ class UsersPage(ResponseModel):
124110
)
125111

126112

127-
class QueryUsersRequest(BaseModel):
113+
class QueryUsersRequest(Model):
128114
active: Optional[bool]
129115
blocked: Optional[bool]
130116
username: Optional[str]
131117
page: Optional[int] = 1
132118
pageSize: Optional[int] = 100
133119

134-
class Config:
135-
use_enum_values = True
136-
137120

138121
class Role(ResponseModel):
139122
"""
@@ -148,31 +131,21 @@ class Role(ResponseModel):
148131
* **permission_ids**: `str` - The permission IDs associated with this role.
149132
"""
150133

151-
role_id: Optional[str] = Field(
152-
alias="roleId", description="A role ID.", allow_mutation=False
153-
)
154-
role_name: Optional[str] = Field(
155-
alias="roleName", description="A role name.", allow_mutation=False
156-
)
134+
role_id: Optional[str] = Field(alias="roleId", description="A role ID.")
135+
role_name: Optional[str] = Field(alias="roleName", description="A role name.")
157136
creation_date: Optional[datetime] = Field(
158-
allow_mutation=False,
159137
alias="creationDate",
160138
description="The date and time this role for the user was created.",
161139
)
162140
modification_date: Optional[datetime] = Field(
163-
allow_mutation=False,
164141
alias="modificationDate",
165142
description="The date and time this role for the user was last modified.",
166143
)
167144
permission_ids: Optional[List[str]] = Field(
168-
allow_mutation=False,
169145
alias="permissionIds",
170146
description="The permission IDs associated with this role.",
171147
)
172148

173-
class Config:
174-
validate_assignment = True
175-
176149

177150
class UpdateRolesRequest(BaseModel):
178151
roleIds: Optional[List[str]]
@@ -193,27 +166,20 @@ class UpdateRolesResponse(ResponseModel):
193166
processed_replacement_role_ids: Optional[List[str]] = Field(
194167
alias="processedReplacementRoleIds",
195168
description="The role IDs processed.",
196-
allow_mutation=False,
197169
)
198170
newly_assigned_roles_ids: Optional[List[str]] = Field(
199171
alias="newlyAssignedRolesIds",
200172
description="The role IDs newly assigned to the user.",
201-
allow_mutation=False,
202173
)
203174
unassigned_roles_ids: Optional[List[str]] = Field(
204175
alias="unassignedRolesIds",
205176
description="The role IDs unassigned from the user.",
206-
allow_mutation=False,
207177
)
208178
ignored_roles_ids: Optional[List[str]] = Field(
209179
alias="ignoredRolesIds",
210180
description="The role IDs ignored.",
211-
allow_mutation=False,
212181
)
213182

214-
class Config:
215-
validate_assignment = True
216-
217183

218184
class MoveUserRequest(BaseModel):
219185
orgGuid: Optional[str]

0 commit comments

Comments
 (0)