Skip to content

Commit 170e8f2

Browse files
authored
chore: remove body selector from http rule (#13255)
BEGIN_COMMIT_OVERRIDE chore: remove body selector from http rule fix: disable universe-domain validation END_COMMIT_OVERRIDE
1 parent c0351dd commit 170e8f2

11 files changed

Lines changed: 11 additions & 252 deletions

File tree

packages/google-cloud-parallelstore/google/cloud/parallelstore/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "0.2.5" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-cloud-parallelstore/google/cloud/parallelstore_v1/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "0.2.5" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-cloud-parallelstore/google/cloud/parallelstore_v1/services/parallelstore/client.py

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -549,36 +549,6 @@ def _get_universe_domain(
549549
raise ValueError("Universe Domain cannot be an empty string.")
550550
return universe_domain
551551

552-
@staticmethod
553-
def _compare_universes(
554-
client_universe: str, credentials: ga_credentials.Credentials
555-
) -> bool:
556-
"""Returns True iff the universe domains used by the client and credentials match.
557-
558-
Args:
559-
client_universe (str): The universe domain configured via the client options.
560-
credentials (ga_credentials.Credentials): The credentials being used in the client.
561-
562-
Returns:
563-
bool: True iff client_universe matches the universe in credentials.
564-
565-
Raises:
566-
ValueError: when client_universe does not match the universe in credentials.
567-
"""
568-
569-
default_universe = ParallelstoreClient._DEFAULT_UNIVERSE
570-
credentials_universe = getattr(credentials, "universe_domain", default_universe)
571-
572-
if client_universe != credentials_universe:
573-
raise ValueError(
574-
"The configured universe domain "
575-
f"({client_universe}) does not match the universe domain "
576-
f"found in the credentials ({credentials_universe}). "
577-
"If you haven't configured the universe domain explicitly, "
578-
f"`{default_universe}` is the default."
579-
)
580-
return True
581-
582552
def _validate_universe_domain(self):
583553
"""Validates client's and credentials' universe domains are consistent.
584554
@@ -588,13 +558,9 @@ def _validate_universe_domain(self):
588558
Raises:
589559
ValueError: If the configured universe domain is not valid.
590560
"""
591-
self._is_universe_domain_valid = (
592-
self._is_universe_domain_valid
593-
or ParallelstoreClient._compare_universes(
594-
self.universe_domain, self.transport._credentials
595-
)
596-
)
597-
return self._is_universe_domain_valid
561+
562+
# NOTE (b/349488459): universe validation is disabled until further notice.
563+
return True
598564

599565
@property
600566
def api_endpoint(self):

packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "0.2.5" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/client.py

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -549,36 +549,6 @@ def _get_universe_domain(
549549
raise ValueError("Universe Domain cannot be an empty string.")
550550
return universe_domain
551551

552-
@staticmethod
553-
def _compare_universes(
554-
client_universe: str, credentials: ga_credentials.Credentials
555-
) -> bool:
556-
"""Returns True iff the universe domains used by the client and credentials match.
557-
558-
Args:
559-
client_universe (str): The universe domain configured via the client options.
560-
credentials (ga_credentials.Credentials): The credentials being used in the client.
561-
562-
Returns:
563-
bool: True iff client_universe matches the universe in credentials.
564-
565-
Raises:
566-
ValueError: when client_universe does not match the universe in credentials.
567-
"""
568-
569-
default_universe = ParallelstoreClient._DEFAULT_UNIVERSE
570-
credentials_universe = getattr(credentials, "universe_domain", default_universe)
571-
572-
if client_universe != credentials_universe:
573-
raise ValueError(
574-
"The configured universe domain "
575-
f"({client_universe}) does not match the universe domain "
576-
f"found in the credentials ({credentials_universe}). "
577-
"If you haven't configured the universe domain explicitly, "
578-
f"`{default_universe}` is the default."
579-
)
580-
return True
581-
582552
def _validate_universe_domain(self):
583553
"""Validates client's and credentials' universe domains are consistent.
584554
@@ -588,13 +558,9 @@ def _validate_universe_domain(self):
588558
Raises:
589559
ValueError: If the configured universe domain is not valid.
590560
"""
591-
self._is_universe_domain_valid = (
592-
self._is_universe_domain_valid
593-
or ParallelstoreClient._compare_universes(
594-
self.universe_domain, self.transport._credentials
595-
)
596-
)
597-
return self._is_universe_domain_valid
561+
562+
# NOTE (b/349488459): universe validation is disabled until further notice.
563+
return True
598564

599565
@property
600566
def api_endpoint(self):

packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/transports/rest.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,6 @@ def operations_client(self) -> operations_v1.AbstractOperationsClient:
541541
{
542542
"method": "post",
543543
"uri": "/v1beta/{name=projects/*/locations/*/operations/*}:cancel",
544-
"body": "*",
545544
},
546545
],
547546
"google.longrunning.Operations.DeleteOperation": [
@@ -1510,7 +1509,6 @@ def _get_response(
15101509
timeout=timeout,
15111510
headers=headers,
15121511
params=rest_helpers.flatten_query_params(query_params, strict=True),
1513-
data=body,
15141512
)
15151513
return response
15161514

@@ -1544,10 +1542,6 @@ def __call__(
15441542
http_options, request
15451543
)
15461544

1547-
body = _BaseParallelstoreRestTransport._BaseCancelOperation._get_request_body_json(
1548-
transcoded_request
1549-
)
1550-
15511545
# Jsonify the query params
15521546
query_params = _BaseParallelstoreRestTransport._BaseCancelOperation._get_query_params_json(
15531547
transcoded_request
@@ -1561,7 +1555,6 @@ def __call__(
15611555
self._session,
15621556
timeout,
15631557
transcoded_request,
1564-
body,
15651558
)
15661559

15671560
# In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception

packages/google-cloud-parallelstore/google/cloud/parallelstore_v1beta/services/parallelstore/transports/rest_base.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,6 @@ def _get_http_options():
522522
{
523523
"method": "post",
524524
"uri": "/v1beta/{name=projects/*/locations/*/operations/*}:cancel",
525-
"body": "*",
526525
},
527526
]
528527
return http_options
@@ -533,11 +532,6 @@ def _get_transcoded_request(http_options, request):
533532
transcoded_request = path_template.transcode(http_options, **request_kwargs)
534533
return transcoded_request
535534

536-
@staticmethod
537-
def _get_request_body_json(transcoded_request):
538-
body = json.dumps(transcoded_request["body"])
539-
return body
540-
541535
@staticmethod
542536
def _get_query_params_json(transcoded_request):
543537
query_params = json.loads(json.dumps(transcoded_request["query_params"]))

packages/google-cloud-parallelstore/samples/generated_samples/snippet_metadata_google.cloud.parallelstore.v1.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
],
99
"language": "PYTHON",
1010
"name": "google-cloud-parallelstore",
11-
"version": "0.2.5"
11+
"version": "0.1.0"
1212
},
1313
"snippets": [
1414
{

packages/google-cloud-parallelstore/samples/generated_samples/snippet_metadata_google.cloud.parallelstore.v1beta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
],
99
"language": "PYTHON",
1010
"name": "google-cloud-parallelstore",
11-
"version": "0.2.5"
11+
"version": "0.1.0"
1212
},
1313
"snippets": [
1414
{

packages/google-cloud-parallelstore/tests/unit/gapic/parallelstore_v1/test_parallelstore.py

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -328,86 +328,6 @@ def test__get_universe_domain():
328328
assert str(excinfo.value) == "Universe Domain cannot be an empty string."
329329

330330

331-
@pytest.mark.parametrize(
332-
"client_class,transport_class,transport_name",
333-
[
334-
(ParallelstoreClient, transports.ParallelstoreGrpcTransport, "grpc"),
335-
(ParallelstoreClient, transports.ParallelstoreRestTransport, "rest"),
336-
],
337-
)
338-
def test__validate_universe_domain(client_class, transport_class, transport_name):
339-
client = client_class(
340-
transport=transport_class(credentials=ga_credentials.AnonymousCredentials())
341-
)
342-
assert client._validate_universe_domain() == True
343-
344-
# Test the case when universe is already validated.
345-
assert client._validate_universe_domain() == True
346-
347-
if transport_name == "grpc":
348-
# Test the case where credentials are provided by the
349-
# `local_channel_credentials`. The default universes in both match.
350-
channel = grpc.secure_channel(
351-
"http://localhost/", grpc.local_channel_credentials()
352-
)
353-
client = client_class(transport=transport_class(channel=channel))
354-
assert client._validate_universe_domain() == True
355-
356-
# Test the case where credentials do not exist: e.g. a transport is provided
357-
# with no credentials. Validation should still succeed because there is no
358-
# mismatch with non-existent credentials.
359-
channel = grpc.secure_channel(
360-
"http://localhost/", grpc.local_channel_credentials()
361-
)
362-
transport = transport_class(channel=channel)
363-
transport._credentials = None
364-
client = client_class(transport=transport)
365-
assert client._validate_universe_domain() == True
366-
367-
# TODO: This is needed to cater for older versions of google-auth
368-
# Make this test unconditional once the minimum supported version of
369-
# google-auth becomes 2.23.0 or higher.
370-
google_auth_major, google_auth_minor = [
371-
int(part) for part in google.auth.__version__.split(".")[0:2]
372-
]
373-
if google_auth_major > 2 or (google_auth_major == 2 and google_auth_minor >= 23):
374-
credentials = ga_credentials.AnonymousCredentials()
375-
credentials._universe_domain = "foo.com"
376-
# Test the case when there is a universe mismatch from the credentials.
377-
client = client_class(transport=transport_class(credentials=credentials))
378-
with pytest.raises(ValueError) as excinfo:
379-
client._validate_universe_domain()
380-
assert (
381-
str(excinfo.value)
382-
== "The configured universe domain (googleapis.com) does not match the universe domain found in the credentials (foo.com). If you haven't configured the universe domain explicitly, `googleapis.com` is the default."
383-
)
384-
385-
# Test the case when there is a universe mismatch from the client.
386-
#
387-
# TODO: Make this test unconditional once the minimum supported version of
388-
# google-api-core becomes 2.15.0 or higher.
389-
api_core_major, api_core_minor = [
390-
int(part) for part in api_core_version.__version__.split(".")[0:2]
391-
]
392-
if api_core_major > 2 or (api_core_major == 2 and api_core_minor >= 15):
393-
client = client_class(
394-
client_options={"universe_domain": "bar.com"},
395-
transport=transport_class(
396-
credentials=ga_credentials.AnonymousCredentials(),
397-
),
398-
)
399-
with pytest.raises(ValueError) as excinfo:
400-
client._validate_universe_domain()
401-
assert (
402-
str(excinfo.value)
403-
== "The configured universe domain (bar.com) does not match the universe domain found in the credentials (googleapis.com). If you haven't configured the universe domain explicitly, `googleapis.com` is the default."
404-
)
405-
406-
# Test that ValueError is raised if universe_domain is provided via client options and credentials is None
407-
with pytest.raises(ValueError):
408-
client._compare_universes("foo.bar", None)
409-
410-
411331
@pytest.mark.parametrize(
412332
"client_class,transport_name",
413333
[

0 commit comments

Comments
 (0)