Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

feat: support for OrgPolicy dry runs #197

Merged
merged 2 commits into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 21 additions & 0 deletions google/cloud/orgpolicy_v2/types/orgpolicy.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import proto # type: ignore

from google.cloud.orgpolicy_v2.types import constraint
from google.protobuf import field_mask_pb2 # type: ignore
from google.protobuf import timestamp_pb2 # type: ignore
from google.type import expr_pb2 # type: ignore

Expand Down Expand Up @@ -66,6 +67,11 @@ class Policy(proto.Message):
Policy.
alternate (google.cloud.orgpolicy_v2.types.AlternatePolicySpec):
Deprecated.
dry_run_spec (google.cloud.orgpolicy_v2.types.PolicySpec):
dry-run policy.
Audit-only policy, can be used to monitor how
the policy would have impacted the existing and
future resources if it's enforced.
"""

name: str = proto.Field(
Expand All @@ -82,6 +88,11 @@ class Policy(proto.Message):
number=3,
message="AlternatePolicySpec",
)
dry_run_spec: "PolicySpec" = proto.Field(
proto.MESSAGE,
number=4,
message="PolicySpec",
)


class AlternatePolicySpec(proto.Message):
Expand Down Expand Up @@ -500,13 +511,23 @@ class UpdatePolicyRequest(proto.Message):
Attributes:
policy (google.cloud.orgpolicy_v2.types.Policy):
Required. ``Policy`` to update.
update_mask (google.protobuf.field_mask_pb2.FieldMask):
Field mask used to specify the fields to be overwritten in
the policy by the set. The fields specified in the
update_mask are relative to the policy, not the full
request.
"""

policy: "Policy" = proto.Field(
proto.MESSAGE,
number=1,
message="Policy",
)
update_mask: field_mask_pb2.FieldMask = proto.Field(
proto.MESSAGE,
number=3,
message=field_mask_pb2.FieldMask,
)


class DeletePolicyRequest(proto.Message):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"language": "PYTHON",
"name": "google-cloud-org-policy",
"version": "1.6.0"
"version": "0.1.0"
},
"snippets": [
{
Expand Down
2 changes: 1 addition & 1 deletion scripts/fixup_orgpolicy_v2_keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class orgpolicyCallTransformer(cst.CSTTransformer):
'get_policy': ('name', ),
'list_constraints': ('parent', 'page_size', 'page_token', ),
'list_policies': ('parent', 'page_size', 'page_token', ),
'update_policy': ('policy', ),
'update_policy': ('policy', 'update_mask', ),
}

def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode:
Expand Down
1 change: 1 addition & 0 deletions tests/unit/gapic/orgpolicy_v2/test_org_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
from google.cloud.orgpolicy_v2.types import constraint
from google.cloud.orgpolicy_v2.types import orgpolicy
from google.oauth2 import service_account
from google.protobuf import field_mask_pb2 # type: ignore
from google.protobuf import timestamp_pb2 # type: ignore
from google.type import expr_pb2 # type: ignore
import google.auth
Expand Down