Skip to content

Commit be54cc2

Browse files
authored
feat: add support for bucket ip filter (#731)
* feat: add support for bucket ip filter * lint
1 parent 0b84596 commit be54cc2

File tree

14 files changed

+687
-705
lines changed

14 files changed

+687
-705
lines changed

bidi-api-updates.patch

Lines changed: 0 additions & 526 deletions
This file was deleted.

gcs/bucket.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class Bucket:
4848
"location_type",
4949
"iam_config",
5050
"rpo",
51+
"ip_filter",
5152
}
5253

5354
def __init__(self, metadata, notifications, iam_policy):
@@ -210,6 +211,49 @@ def __preprocess_rest_soft_delete_policy(cls, rp):
210211
},
211212
)
212213

214+
@classmethod
215+
def __preprocess_rest_ip_filter(cls, ipf):
216+
if ipf.get("vpcNetworkSources") is not None:
217+
sources = []
218+
for source in ipf.get("vpcNetworkSources"):
219+
sources.append(
220+
testbench.common.rest_adjust(
221+
source,
222+
{
223+
"network": lambda x: ("network", x),
224+
"allowedIpCidrRanges": lambda x: (
225+
"allowed_ip_cidr_ranges",
226+
x,
227+
),
228+
},
229+
)
230+
)
231+
ipf["vpcNetworkSources"] = sources
232+
return testbench.common.rest_adjust(
233+
ipf,
234+
{
235+
"mode": lambda x: ("mode", x),
236+
"publicNetworkSource": lambda x: (
237+
"public_network_source",
238+
testbench.common.rest_adjust(
239+
x,
240+
{
241+
"allowedIpCidrRanges": lambda x: (
242+
"allowed_ip_cidr_ranges",
243+
x,
244+
)
245+
},
246+
),
247+
),
248+
"vpcNetworkSources": lambda x: ("vpc_network_sources", x),
249+
"allowCrossOrgVpcs": lambda x: ("allow_cross_org_vpcs", x),
250+
"allowAllServiceAgentAccess": lambda x: (
251+
"allow_all_service_agent_access",
252+
x,
253+
),
254+
},
255+
)
256+
213257
@classmethod
214258
def __preprocess_rest(cls, rest):
215259
rest = testbench.common.rest_adjust(
@@ -242,6 +286,10 @@ def __preprocess_rest(cls, rest):
242286
"softDeletePolicy",
243287
Bucket.__preprocess_rest_soft_delete_policy(x),
244288
),
289+
"ipFilter": lambda x: (
290+
"ipFilter",
291+
Bucket.__preprocess_rest_ip_filter(x),
292+
),
245293
},
246294
)
247295
if rest.get("acl", None) is not None:

google/iam/v1/iam_policy_pb2.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# Generated by the protocol buffer compiler. DO NOT EDIT!
1717
# NO CHECKED-IN PROTOBUF GENCODE
1818
# source: google/iam/v1/iam_policy.proto
19-
# Protobuf Python Version: 5.27.2
19+
# Protobuf Python Version: 5.29.0
2020
"""Generated protocol buffer code."""
2121
from google.protobuf import descriptor as _descriptor
2222
from google.protobuf import descriptor_pool as _descriptor_pool
@@ -26,8 +26,8 @@
2626
_runtime_version.ValidateProtobufRuntimeVersion(
2727
_runtime_version.Domain.PUBLIC,
2828
5,
29-
27,
30-
2,
29+
29,
30+
0,
3131
'',
3232
'google/iam/v1/iam_policy.proto'
3333
)

google/iam/v1/iam_policy_pb2_grpc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from google.iam.v1 import iam_policy_pb2 as google_dot_iam_dot_v1_dot_iam__policy__pb2
2121
from google.iam.v1 import policy_pb2 as google_dot_iam_dot_v1_dot_policy__pb2
2222

23-
GRPC_GENERATED_VERSION = '1.67.0'
23+
GRPC_GENERATED_VERSION = '1.70.0'
2424
GRPC_VERSION = grpc.__version__
2525
_version_not_supported = False
2626

google/iam/v1/options_pb2.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# Generated by the protocol buffer compiler. DO NOT EDIT!
1717
# NO CHECKED-IN PROTOBUF GENCODE
1818
# source: google/iam/v1/options.proto
19-
# Protobuf Python Version: 5.27.2
19+
# Protobuf Python Version: 5.29.0
2020
"""Generated protocol buffer code."""
2121
from google.protobuf import descriptor as _descriptor
2222
from google.protobuf import descriptor_pool as _descriptor_pool
@@ -26,8 +26,8 @@
2626
_runtime_version.ValidateProtobufRuntimeVersion(
2727
_runtime_version.Domain.PUBLIC,
2828
5,
29-
27,
30-
2,
29+
29,
30+
0,
3131
'',
3232
'google/iam/v1/options.proto'
3333
)

google/iam/v1/options_pb2_grpc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import warnings
1919

2020

21-
GRPC_GENERATED_VERSION = '1.67.0'
21+
GRPC_GENERATED_VERSION = '1.70.0'
2222
GRPC_VERSION = grpc.__version__
2323
_version_not_supported = False
2424

google/iam/v1/policy_pb2.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# Generated by the protocol buffer compiler. DO NOT EDIT!
1717
# NO CHECKED-IN PROTOBUF GENCODE
1818
# source: google/iam/v1/policy.proto
19-
# Protobuf Python Version: 5.27.2
19+
# Protobuf Python Version: 5.29.0
2020
"""Generated protocol buffer code."""
2121
from google.protobuf import descriptor as _descriptor
2222
from google.protobuf import descriptor_pool as _descriptor_pool
@@ -26,8 +26,8 @@
2626
_runtime_version.ValidateProtobufRuntimeVersion(
2727
_runtime_version.Domain.PUBLIC,
2828
5,
29-
27,
30-
2,
29+
29,
30+
0,
3131
'',
3232
'google/iam/v1/policy.proto'
3333
)

google/iam/v1/policy_pb2_grpc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import warnings
1919

2020

21-
GRPC_GENERATED_VERSION = '1.67.0'
21+
GRPC_GENERATED_VERSION = '1.70.0'
2222
GRPC_VERSION = grpc.__version__
2323
_version_not_supported = False
2424

google/storage/v2/storage_pb2.py

Lines changed: 498 additions & 160 deletions
Large diffs are not rendered by default.

google/storage/v2/storage_pb2_grpc.py

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2
2323
from google.storage.v2 import storage_pb2 as google_dot_storage_dot_v2_dot_storage__pb2
2424

25-
GRPC_GENERATED_VERSION = '1.67.0'
25+
GRPC_GENERATED_VERSION = '1.70.0'
2626
GRPC_VERSION = grpc.__version__
2727
_version_not_supported = False
2828

@@ -256,7 +256,9 @@ def LockBucketRetentionPolicy(self, request, context):
256256
def GetIamPolicy(self, request, context):
257257
"""Gets the IAM policy for a specified bucket.
258258
The `resource` field in the request should be
259-
`projects/_/buckets/{bucket}`.
259+
`projects/_/buckets/{bucket}` for a bucket, or
260+
`projects/_/buckets/{bucket}/managedFolders/{managedFolder}`
261+
for a managed folder.
260262
"""
261263
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
262264
context.set_details('Method not implemented!')
@@ -265,7 +267,9 @@ def GetIamPolicy(self, request, context):
265267
def SetIamPolicy(self, request, context):
266268
"""Updates an IAM policy for the specified bucket.
267269
The `resource` field in the request should be
268-
`projects/_/buckets/{bucket}`.
270+
`projects/_/buckets/{bucket}` for a bucket, or
271+
`projects/_/buckets/{bucket}/managedFolders/{managedFolder}`
272+
for a managed folder.
269273
"""
270274
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
271275
context.set_details('Method not implemented!')
@@ -374,7 +378,26 @@ def ReadObject(self, request, context):
374378
raise NotImplementedError('Method not implemented!')
375379

376380
def BidiReadObject(self, request_iterator, context):
377-
"""Missing associated documentation comment in .proto file."""
381+
"""Reads an object's data.
382+
383+
This is a bi-directional API with the added support for reading multiple
384+
ranges within one stream both within and across multiple messages.
385+
If the server encountered an error for any of the inputs, the stream will
386+
be closed with the relevant error code.
387+
Because the API allows for multiple outstanding requests, when the stream
388+
is closed the error response will contain a BidiReadObjectRangesError proto
389+
in the error extension describing the error for each outstanding read_id.
390+
391+
**IAM Permissions**:
392+
393+
Requires `storage.objects.get`
394+
395+
[IAM permission](https://cloud.google.com/iam/docs/overview#permissions) on
396+
the bucket.
397+
398+
This API is currently in preview and is not yet available for general
399+
use.
400+
"""
378401
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
379402
context.set_details('Method not implemented!')
380403
raise NotImplementedError('Method not implemented!')

0 commit comments

Comments
 (0)