Skip to content

feat: support authorized views #1034

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 60 commits into from
May 22, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
f9c7dc8
add authorized view field to TableAsync
daniel-sanche Oct 28, 2024
f143377
add AuthorizedView as Table subclass
daniel-sanche Oct 28, 2024
ce4351a
ran blacken
daniel-sanche Oct 28, 2024
6a679e0
simplified authorized view defaults
daniel-sanche Oct 28, 2024
cd9df24
use protos to pass in authroized view name
daniel-sanche Oct 29, 2024
8296471
fixed existing tests
daniel-sanche Oct 29, 2024
ec5f462
create authorized view on client instead of table
daniel-sanche Oct 31, 2024
9b6cadf
made base class for table and authorized_view
daniel-sanche Oct 31, 2024
5bbf56c
added docs file
daniel-sanche Nov 7, 2024
7c02dc0
Merge branch 'main' into authorized_views
daniel-sanche Nov 12, 2024
d739797
fixed merge error
daniel-sanche Nov 12, 2024
77de052
Merge branch 'main' into authorized_views
daniel-sanche Nov 22, 2024
7831dc8
made async agnostic
daniel-sanche Nov 22, 2024
a8b93cf
fixed indentation
daniel-sanche Nov 22, 2024
6e38d43
fixed merge loss
daniel-sanche Nov 22, 2024
908a3ab
ran black
daniel-sanche Nov 22, 2024
6f81541
removed union
daniel-sanche Nov 22, 2024
3139eb9
use _request_path for either view or table
daniel-sanche Nov 23, 2024
d199a88
run system tests against both table and view
daniel-sanche Nov 23, 2024
d362892
added docs page for authorized views
daniel-sanche Nov 28, 2024
c710d5a
fixed authorized view permissions in system test
daniel-sanche Dec 3, 2024
0bc88b9
added system test for auth denied
daniel-sanche Dec 4, 2024
e95ba0d
added TestAuthorizedView unit test class
daniel-sanche Dec 4, 2024
f46e6ef
run tests with both table and view
daniel-sanche Dec 4, 2024
dd337be
Merge branch 'main' into authorized_views
daniel-sanche Jan 10, 2025
39b7e44
added authorized view to docs
daniel-sanche Jan 10, 2025
362e070
fixed cross sync generation
daniel-sanche Jan 10, 2025
1f7a185
updated async code for sync generator
daniel-sanche Jan 10, 2025
81a3530
updated generated sync code
daniel-sanche Jan 10, 2025
e2136d1
fixed lint issues
daniel-sanche Jan 10, 2025
6cca1e9
fixed unit tests
daniel-sanche Jan 11, 2025
1779a79
added docs file for sync authorized views
daniel-sanche Jan 11, 2025
ba9dda4
fixed mypy issue
daniel-sanche Jan 11, 2025
b3ac6bb
add authorized view to __init__.py
daniel-sanche Jan 13, 2025
131c3c7
fixed typo
daniel-sanche Jan 13, 2025
7ba0f50
fixed duplicate import
daniel-sanche Jan 13, 2025
c321756
Merge branch 'main' into authorized_views
daniel-sanche Feb 25, 2025
eb46b31
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Feb 25, 2025
582f513
fixed merge issue
daniel-sanche Feb 25, 2025
8e2ca4a
fixed failing test
daniel-sanche Feb 26, 2025
835d598
Merge branch 'main' into authorized_views
daniel-sanche May 7, 2025
547eb17
changed view_id to authorized_view_id
daniel-sanche May 19, 2025
f784831
use target instead of table
daniel-sanche May 19, 2025
2a17eae
moved request_path into property method
daniel-sanche May 20, 2025
1bea19d
remove table_name from WarmedInstanceKey
daniel-sanche May 20, 2025
054a40f
made DataTarget into abstract class
daniel-sanche May 20, 2025
c8b23b7
fixed typo
daniel-sanche May 20, 2025
3220168
regenerated sync files
daniel-sanche May 20, 2025
e3c9b54
fixed str representation
daniel-sanche May 20, 2025
09936c4
ran blacken
daniel-sanche May 20, 2025
4c3b99c
regenerated sync files
daniel-sanche May 20, 2025
b317891
fixed system tests
daniel-sanche May 21, 2025
e39cb47
fixed cross_sync bug
daniel-sanche May 21, 2025
2aa1828
use table and authorized view where possible
daniel-sanche May 21, 2025
ff07455
fixed crosssync generation
daniel-sanche May 21, 2025
ac7f5a2
fixed authorized view format
daniel-sanche May 21, 2025
259d1cd
fixed mypy
daniel-sanche May 21, 2025
af7a6a8
fixed pytest skip
daniel-sanche May 21, 2025
0752788
pass empty view id in tests when not supported
daniel-sanche May 21, 2025
7d3a285
skip btsql test
daniel-sanche May 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'main' into authorized_views
  • Loading branch information
daniel-sanche committed Nov 12, 2024
commit 7c02dc03dea0b7faf2f605a6f1344e269cbe9200
6 changes: 2 additions & 4 deletions google/cloud/bigtable/data/_async/_mutate_rows.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,11 @@ def __init__(
f"all entries. Found {total_mutations}."
)
# create partial function to pass to trigger rpc call
metadata = _make_metadata(
table.table_name, table.app_profile_id, instance_name=None
)
self._table = table
self._gapic_fn = functools.partial(
gapic_client.mutate_rows,
metadata=metadata,
table_name=table.table_name,
app_profile_id=table.app_profile_id,
retry=None,
)
# create predicate for determining which errors are retryable
Expand Down
2 changes: 0 additions & 2 deletions google/cloud/bigtable/data/_async/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1307,7 +1307,6 @@ async def check_and_mutate_row(
app_profile_id=self.app_profile_id,
authorized_view_name=self._authorized_view_name,
),
metadata=metadata,
timeout=operation_timeout,
retry=None,
)
Expand Down Expand Up @@ -1360,7 +1359,6 @@ async def read_modify_write_row(
app_profile_id=self.app_profile_id,
authorized_view_name=self._authorized_view_name,
),
metadata=metadata,
timeout=operation_timeout,
retry=None,
)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/data/_async/test__mutate_rows.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def test_ctor(self):
assert client.mutate_rows.call_count == 1
# gapic_fn should call with table details
inner_kwargs = client.mutate_rows.call_args[1]
assert len(inner_kwargs) == 2
assert len(inner_kwargs) == 3
assert inner_kwargs["retry"] is None
# entries should be passed down
entries_w_pb = [_EntryWithProto(e, e._to_pb()) for e in entries]
Expand Down
27 changes: 1 addition & 26 deletions tests/unit/data/_async/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2027,9 +2027,8 @@ async def test_sample_row_keys_gapic_params(self):
await table.sample_row_keys(attempt_timeout=expected_timeout)
args, kwargs = sample_row_keys.call_args
assert len(args) == 0
assert len(kwargs) == 4
assert len(kwargs) == 3
assert kwargs["timeout"] == expected_timeout
assert kwargs["metadata"] is not None
assert kwargs["retry"] is None
request = kwargs["request"]
assert request.app_profile_id == expected_profile
Expand Down Expand Up @@ -2228,30 +2227,6 @@ async def test_mutate_row_non_retryable_errors(self, non_retryable_exception):
"row_key", mutation, operation_timeout=0.2
)

@pytest.mark.parametrize("include_app_profile", [True, False])
@pytest.mark.asyncio
async def test_mutate_row_metadata(self, include_app_profile):
"""request should attach metadata headers"""
profile = "profile" if include_app_profile else None
async with _make_client() as client:
async with client.get_table("i", "t", app_profile_id=profile) as table:
with mock.patch.object(
client._gapic_client, "mutate_row", AsyncMock()
) as read_rows:
await table.mutate_row("rk", DeleteAllFromRow())
kwargs = read_rows.call_args_list[0].kwargs
metadata = kwargs["metadata"]
goog_metadata = None
for key, value in metadata:
if key == "x-goog-request-params":
goog_metadata = value
assert goog_metadata is not None, "x-goog-request-params not found"
assert "table_name=" + table.table_name in goog_metadata
if include_app_profile:
assert "app_profile_id=profile" in goog_metadata
else:
assert "app_profile_id=" not in goog_metadata

@pytest.mark.parametrize("mutations", [[], None])
@pytest.mark.asyncio
async def test_mutate_row_no_mutations(self, mutations):
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.