Skip to content
This repository has been archived by the owner on Dec 31, 2023. It is now read-only.

Commit

Permalink
fix: revert proto3_optional, required removal on parent_id (#714) (#265)
Browse files Browse the repository at this point in the history
- [ ] Regenerate this pull request now.

Source-Link: googleapis/googleapis@6b3fdce

Source-Link: googleapis/googleapis-gen@832dbe9
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiODMyZGJlOTk4ODc4ZDg2MTlkNmI0MGZlNTdjNmQyY2M2ZTdkYzkwYyJ9
  • Loading branch information
gcf-owl-bot[bot] committed Apr 20, 2022
1 parent 526fb10 commit ae1aeac
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 8 deletions.
Expand Up @@ -1805,7 +1805,9 @@ class _Move(FirewallPoliciesRestStub):
def __hash__(self):
return hash("Move")

__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {}
__REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {
"parentId": "",
}

@classmethod
def _get_unset_required_fields(cls, message_dict):
Expand Down
3 changes: 0 additions & 3 deletions google/cloud/compute_v1/types/compute.py
Expand Up @@ -50310,8 +50310,6 @@ class MoveFirewallPolicyRequest(proto.Message):
Name of the firewall policy to update.
parent_id (str):
The new parent of the firewall policy.

This field is a member of `oneof`_ ``_parent_id``.
request_id (str):
An optional request ID to identify requests.
Specify a unique request ID so that if you must
Expand Down Expand Up @@ -50339,7 +50337,6 @@ class MoveFirewallPolicyRequest(proto.Message):
parent_id = proto.Field(
proto.STRING,
number=459714768,
optional=True,
)
request_id = proto.Field(
proto.STRING,
Expand Down
42 changes: 38 additions & 4 deletions tests/unit/gapic/compute_v1/test_firewall_policies.py
Expand Up @@ -5461,6 +5461,7 @@ def test_move_rest_required_fields(request_type=compute.MoveFirewallPolicyReques

request_init = {}
request_init["firewall_policy"] = ""
request_init["parent_id"] = ""
request = request_type(request_init)
jsonified_request = json.loads(
request_type.to_json(
Expand All @@ -5469,15 +5470,19 @@ def test_move_rest_required_fields(request_type=compute.MoveFirewallPolicyReques
)

# verify fields with default values are dropped
assert "parentId" not in jsonified_request

unset_fields = transport_class(
credentials=ga_credentials.AnonymousCredentials()
).move._get_unset_required_fields(jsonified_request)
jsonified_request.update(unset_fields)

# verify required fields with default values are now present
assert "parentId" in jsonified_request
assert jsonified_request["parentId"] == request_init["parent_id"]

jsonified_request["firewallPolicy"] = "firewall_policy_value"
jsonified_request["parentId"] = "parent_id_value"

unset_fields = transport_class(
credentials=ga_credentials.AnonymousCredentials()
Expand All @@ -5494,6 +5499,8 @@ def test_move_rest_required_fields(request_type=compute.MoveFirewallPolicyReques
# verify required fields with non-default values are left alone
assert "firewallPolicy" in jsonified_request
assert jsonified_request["firewallPolicy"] == "firewall_policy_value"
assert "parentId" in jsonified_request
assert jsonified_request["parentId"] == "parent_id_value"

client = FirewallPoliciesClient(
credentials=ga_credentials.AnonymousCredentials(),
Expand Down Expand Up @@ -5526,7 +5533,12 @@ def test_move_rest_required_fields(request_type=compute.MoveFirewallPolicyReques

response = client.move(request)

expected_params = []
expected_params = [
(
"parentId",
"",
),
]
actual_params = req.call_args.kwargs["params"]
assert expected_params == actual_params

Expand All @@ -5544,7 +5556,12 @@ def test_move_rest_unset_required_fields():
"requestId",
)
)
& set(("firewallPolicy",))
& set(
(
"firewallPolicy",
"parentId",
)
)
)


Expand Down Expand Up @@ -5753,6 +5770,7 @@ def test_move_unary_rest_required_fields(

request_init = {}
request_init["firewall_policy"] = ""
request_init["parent_id"] = ""
request = request_type(request_init)
jsonified_request = json.loads(
request_type.to_json(
Expand All @@ -5761,15 +5779,19 @@ def test_move_unary_rest_required_fields(
)

# verify fields with default values are dropped
assert "parentId" not in jsonified_request

unset_fields = transport_class(
credentials=ga_credentials.AnonymousCredentials()
).move._get_unset_required_fields(jsonified_request)
jsonified_request.update(unset_fields)

# verify required fields with default values are now present
assert "parentId" in jsonified_request
assert jsonified_request["parentId"] == request_init["parent_id"]

jsonified_request["firewallPolicy"] = "firewall_policy_value"
jsonified_request["parentId"] = "parent_id_value"

unset_fields = transport_class(
credentials=ga_credentials.AnonymousCredentials()
Expand All @@ -5786,6 +5808,8 @@ def test_move_unary_rest_required_fields(
# verify required fields with non-default values are left alone
assert "firewallPolicy" in jsonified_request
assert jsonified_request["firewallPolicy"] == "firewall_policy_value"
assert "parentId" in jsonified_request
assert jsonified_request["parentId"] == "parent_id_value"

client = FirewallPoliciesClient(
credentials=ga_credentials.AnonymousCredentials(),
Expand Down Expand Up @@ -5818,7 +5842,12 @@ def test_move_unary_rest_required_fields(

response = client.move_unary(request)

expected_params = []
expected_params = [
(
"parentId",
"",
),
]
actual_params = req.call_args.kwargs["params"]
assert expected_params == actual_params

Expand All @@ -5836,7 +5865,12 @@ def test_move_unary_rest_unset_required_fields():
"requestId",
)
)
& set(("firewallPolicy",))
& set(
(
"firewallPolicy",
"parentId",
)
)
)


Expand Down

0 comments on commit ae1aeac

Please sign in to comment.