Skip to content

Commit

Permalink
Add assign role to multiple users, up linter versions (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
evelynwou authored Nov 4, 2024
1 parent bd46486 commit 08d6a76
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 16 deletions.
30 changes: 15 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: requirements-txt-fixer
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: requirements-txt-fixer

- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black
- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.278
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.7.2
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
4 changes: 4 additions & 0 deletions CHANGE_LOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

### v2.2.0 - 2024-11-04 Theo Wou

- Add assign role to multiple users, up linter versions

### v2.1.4 - 2024-03-05 Theo Wou

- Support tab, new-line and backslash in escaped characters
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = 'setuptools.build_meta'
[project]
name = 'datahub_tools'
description = 'Python tools for working with DataHub'
version = '2.1.4'
version = '2.2.0'
readme = 'README.md'
requires-python = '>=3.9'
dependencies = ['acryl-datahub>=0.10.3.2', 'jmespath', 'requests']
Expand Down
11 changes: 11 additions & 0 deletions src/datahub_tools/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,17 @@ def remove_owners(owners: Iterable[str], urns: list[str]):
)


def assign_role_to_users(role_urn: str, urns: list[str]):
_role_urn = f'"{role_urn}"'
user_urns = ", ".join(f'"{user}"' for user in urns)
_input = f"{{ roleUrn: {_role_urn}, actors: [ {user_urns} ] }}"
response = _post_mutation(endpoint="batchAssignRole", _input=_input)
if not response:
raise ValueError(
f"Setting role {role_urn} to users {user_urns} failed! (but returned 200)"
)


def set_tags(tag_urns: Iterable[str], resource_urns: Iterable[str]):
_change_tags(
endpoint="batchAddTags", tag_urns=tag_urns, resource_urns=resource_urns
Expand Down

0 comments on commit 08d6a76

Please sign in to comment.