Skip to content

Commit 52a4725

Browse files
authored
Chore/rename exception catch (#360)
* rename exception catching * upgrade black to 22.3.0 * upgrade cla assistant * improved error checking * bump py42 version
1 parent e19405f commit 52a4725

34 files changed

+431
-161
lines changed

.github/workflows/cla.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- name: "CLA Assistant"
1313
if: (github.event.comment.body == 'recheckcla' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
1414
# Alpha Release
15-
uses: cla-assistant/github-action@v2.0.1-alpha
15+
uses: cla-assistant/github-action@v2.13.0
1616
env:
1717
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1818
# the below token should have repo scope and must be manually added by you in the repository's secret
@@ -22,7 +22,7 @@ jobs:
2222
path-to-cla-document: 'https://code42.github.io/code42-cla/Code42_Individual_Contributor_License_Agreement'
2323
# branch should not be protected
2424
branch: 'main'
25-
allowlist: alang13,unparalleled-js,kiran-chaudhary,timabrmsn,ceciliastevens,DiscoRiver,annie-payseur,amoravec,patelsagar192
25+
allowlist: alang13,unparalleled-js,kiran-chaudhary,timabrmsn,ceciliastevens,DiscoRiver,annie-payseur,amoravec,patelsagar192,tora-kozic
2626

2727
#below are the optional inputs - If the optional inputs are not given, then default values will be taken
2828
#remote-organization-name: enter the remote organization name where the signatures should be stored (Default is storing the signatures in the same repository)

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ repos:
1010
- id: reorder-python-imports
1111
args: ["--application-directories", "src"]
1212
- repo: https://github.com/psf/black
13-
rev: 19.10b0
13+
rev: 22.3.0
1414
hooks:
1515
- id: black
1616
- repo: https://gitlab.com/pycqa/flake8

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,15 @@ how a consumer would use the library (e.g. adding unit tests, updating documenta
1111
## Unreleased
1212

1313
### Added
14-
- `users add-alias`, `users remove-alias`, `users bulk add-alias`, and `users bulk remove-alias` for managing cloud aliases for users.
14+
- `departing-employee bulk remove` and `high-risk-employee bulk remove` commands now accept an optional header, as well as extraneous columns if a header is provided.
15+
- Added `devices rename` and `devices bulk rename` commands to rename devices.
16+
- *Note: Incydr devices cannot be renamed.*
17+
- Added the following commands for managing users' cloud aliases:
18+
- `users add-alias`
19+
- `users remove-alias`
20+
- `users list-aliases`
21+
- `users bulk add-alias`
22+
- `users bulk remove-alias`
1523

1624
## 1.12.1 - 2022-01-21
1725

CONTRIBUTING.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ pyenv virtualenv 3.6.10 code42cli
5050
pyenv activate code42cli
5151
```
5252

53+
**Note**: The CLI supports pythons versions 3.6 through 3.9 - any versions within that range should work for your virtual environment. Use `pyenv --versions` to see all versions available for install. There are some known issues installing python 3.6 with pyenv on certain OS.
54+
5355
Use `source deactivate` to exit the virtual environment and `pyenv activate code42cli` to reactivate it.
5456

5557
### Windows/Linux
@@ -76,7 +78,7 @@ Next, with your virtual environment activated, install code42cli and its develop
7678
["editable mode"](https://pip.pypa.io/en/stable/reference/pip_install/#editable-installs).
7779

7880
```bash
79-
pip install -e .[dev]
81+
pip install -e .'[dev]'
8082
```
8183

8284
Open the project in your IDE of choice and change the python environment to

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"keyrings.alt==3.2.0",
4040
"ipython==7.16.3",
4141
"pandas>=1.1.3",
42-
"py42>=1.21.1",
42+
"py42>=1.22.0",
4343
],
4444
extras_require={
4545
"dev": [

src/code42cli/cmds/alerts.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,9 @@ def handle_row(id, state, note):
432432
_update_alert(sdk, id, state, note)
433433

434434
run_bulk_process(
435-
handle_row, csv_rows, progress_label="Updating alerts:",
435+
handle_row,
436+
csv_rows,
437+
progress_label="Updating alerts:",
436438
)
437439

438440

src/code42cli/cmds/cases.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@
2424
case_number_option = click.option(
2525
"--case-number", type=int, help="The number assigned to the case.", required=True
2626
)
27-
name_option = click.option("--name", help="The name of the case.",)
27+
name_option = click.option(
28+
"--name",
29+
help="The name of the case.",
30+
)
2831
assignee_option = click.option(
2932
"--assignee", help="The UID of the user to assign to the case."
3033
)
@@ -117,7 +120,8 @@ def update(state, case_number, name, subject, assignee, description, findings, s
117120

118121
@cases.command("list")
119122
@click.option(
120-
"--name", help="Filter by name of a case. Supports partial name matches.",
123+
"--name",
124+
help="Filter by name of a case. Supports partial name matches.",
121125
)
122126
@click.option("--subject", help="Filter by the user UID of the subject of a case.")
123127
@click.option("--assignee", help="Filter by the user UID of an assignee.")
@@ -299,7 +303,9 @@ def handle_row(number, event_id):
299303
sdk.cases.file_events.add(number, event_id)
300304

301305
run_bulk_process(
302-
handle_row, csv_rows, progress_label="Associating file events to cases:",
306+
handle_row,
307+
csv_rows,
308+
progress_label="Associating file events to cases:",
303309
)
304310

305311

src/code42cli/cmds/departing_employee.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ def _list(state, format, filter):
4949
"""Lists the users on the Departing Employees list."""
5050
employee_generator = _get_departing_employees(state.sdk, filter)
5151
list_employees(
52-
employee_generator, format, {"departureDate": "Departure Date"},
52+
employee_generator,
53+
format,
54+
{"departureDate": "Departure Date"},
5355
)
5456

5557

src/code42cli/cmds/devices.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from pandas import Series
99
from pandas import to_datetime
1010
from py42 import exceptions
11+
from py42.clients.settings.device_settings import IncydrDeviceSettings
1112
from py42.exceptions import Py42NotFoundError
1213

1314
from code42cli.bulk import generate_template_cmd_factory
@@ -35,7 +36,9 @@ def devices(state):
3536

3637

3738
device_guid_argument = click.argument(
38-
"device-guid", type=str, callback=lambda ctx, param, arg: _verify_guid_type(arg),
39+
"device-guid",
40+
type=str,
41+
callback=lambda ctx, param, arg: _verify_guid_type(arg),
3942
)
4043

4144
new_device_name_option = click.option(
@@ -159,8 +162,16 @@ def _update_cold_storage_purge_date(sdk, guid, purge_date):
159162
def _change_device_name(sdk, guid, name):
160163
try:
161164
device_settings = sdk.devices.get_settings(guid)
165+
if isinstance(device_settings, IncydrDeviceSettings):
166+
raise Code42CLIError(
167+
"Failed to rename device. Incydr devices cannot be renamed."
168+
)
162169
device_settings.name = name
163170
sdk.devices.update_settings(device_settings)
171+
except KeyError:
172+
raise Code42CLIError(
173+
"Failed to rename device. This device is missing expected settings fields."
174+
)
164175
except exceptions.Py42ForbiddenError:
165176
raise Code42CLIError(
166177
f"You don't have the necessary permissions to rename the device with GUID '{guid}'."
@@ -500,7 +511,12 @@ def _break_backup_usage_into_total_storage(backup_usage):
500511
@format_option
501512
@sdk_options()
502513
def list_backup_sets(
503-
state, active, inactive, org_uid, include_usernames, format,
514+
state,
515+
active,
516+
inactive,
517+
org_uid,
518+
include_usernames,
519+
format,
504520
):
505521
"""Get information about many devices and their backup sets."""
506522
if inactive:

src/code42cli/cmds/high_risk_employee.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,9 @@ def handle_row(username, tag):
176176
_add_risk_tags(sdk, username, tag)
177177

178178
run_bulk_process(
179-
handle_row, csv_rows, progress_label="Adding risk tags to users:",
179+
handle_row,
180+
csv_rows,
181+
progress_label="Adding risk tags to users:",
180182
)
181183

182184

@@ -194,7 +196,9 @@ def handle_row(username, tag):
194196
_remove_risk_tags(sdk, username, tag)
195197

196198
run_bulk_process(
197-
handle_row, csv_rows, progress_label="Removing risk tags from users:",
199+
handle_row,
200+
csv_rows,
201+
progress_label="Removing risk tags from users:",
198202
)
199203

200204

0 commit comments

Comments
 (0)