Reference documentation and code samples for the Policy Simulator V1 API class Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreview.
OrgPolicyViolationsPreview is a resource providing a preview of the
violations that will exist if an OrgPolicy change is made.
The list of violations are modeled as child resources and retrieved via a
[ListOrgPolicyViolations][] API call. There are potentially more
[OrgPolicyViolations][] than could fit in an embedded field. Thus, the use of
a child resource instead of a field.
(::Array<::String>) — Output only. The names of the constraints against which all
OrgPolicyViolations were evaluated.
If OrgPolicyOverlay only contains PolicyOverlay then it contains
the name of the configured custom constraint, applicable to the specified
policies. Otherwise it contains the name of the constraint specified in
CustomConstraintOverlay.
(::Integer) — Output only. The number of [OrgPolicyViolations][] in this
OrgPolicyViolationsPreview. This count may differ from
resource_summary.noncompliant_count because each
OrgPolicyViolation is
specific to a resource and constraint. If there are multiple
constraints being evaluated (i.e. multiple policies in the overlay), a
single resource may violate multiple constraints.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-03 UTC."],[],[],null,["# Policy Simulator V1 API - Class Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreview (v1.4.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.4.0 (latest)](/ruby/docs/reference/google-cloud-policy_simulator-v1/latest/Google-Cloud-PolicySimulator-V1-OrgPolicyViolationsPreview)\n- [1.3.0](/ruby/docs/reference/google-cloud-policy_simulator-v1/1.3.0/Google-Cloud-PolicySimulator-V1-OrgPolicyViolationsPreview)\n- [1.2.1](/ruby/docs/reference/google-cloud-policy_simulator-v1/1.2.1/Google-Cloud-PolicySimulator-V1-OrgPolicyViolationsPreview)\n- [1.1.0](/ruby/docs/reference/google-cloud-policy_simulator-v1/1.1.0/Google-Cloud-PolicySimulator-V1-OrgPolicyViolationsPreview)\n- [1.0.1](/ruby/docs/reference/google-cloud-policy_simulator-v1/1.0.1/Google-Cloud-PolicySimulator-V1-OrgPolicyViolationsPreview)\n- [0.4.0](/ruby/docs/reference/google-cloud-policy_simulator-v1/0.4.0/Google-Cloud-PolicySimulator-V1-OrgPolicyViolationsPreview)\n- [0.3.2](/ruby/docs/reference/google-cloud-policy_simulator-v1/0.3.2/Google-Cloud-PolicySimulator-V1-OrgPolicyViolationsPreview)\n- [0.2.0](/ruby/docs/reference/google-cloud-policy_simulator-v1/0.2.0/Google-Cloud-PolicySimulator-V1-OrgPolicyViolationsPreview)\n- [0.1.1](/ruby/docs/reference/google-cloud-policy_simulator-v1/0.1.1/Google-Cloud-PolicySimulator-V1-OrgPolicyViolationsPreview) \nReference documentation and code samples for the Policy Simulator V1 API class Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreview.\n\nOrgPolicyViolationsPreview is a resource providing a preview of the\nviolations that will exist if an OrgPolicy change is made.\n\n\n\u003cbr /\u003e\n\nThe list of violations are modeled as child resources and retrieved via a\n\\[ListOrgPolicyViolations\\]\\[\\] API call. There are potentially more\n\\[OrgPolicyViolations\\]\\[\\] than could fit in an embedded field. Thus, the use of\na child resource instead of a field. \n\nInherits\n--------\n\n- Object \n\nExtended By\n-----------\n\n- Google::Protobuf::MessageExts::ClassMethods \n\nIncludes\n--------\n\n- Google::Protobuf::MessageExts\n\nMethods\n-------\n\n### #create_time\n\n def create_time() -\u003e ::Google::Protobuf::Timestamp\n\n**Returns**\n\n- ([::Google::Protobuf::Timestamp](./Google-Protobuf-Timestamp)) --- Output only. Time when this `OrgPolicyViolationsPreview` was created.\n\n### #custom_constraints\n\n def custom_constraints() -\u003e ::Array\u003c::String\u003e\n\n**Returns**\n\n- (::Array\\\u003c::String\\\u003e) --- Output only. The names of the constraints against which all `OrgPolicyViolations` were evaluated.\n\n\n If `OrgPolicyOverlay` only contains `PolicyOverlay` then it contains\n the name of the configured custom constraint, applicable to the specified\n policies. Otherwise it contains the name of the constraint specified in\n `CustomConstraintOverlay`.\n\n Format:\n `organizations/{organization_id}/customConstraints/{custom_constraint_id}`\n\n Example: `organizations/123/customConstraints/custom.createOnlyE2TypeVms`\n\n### #name\n\n def name() -\u003e ::String\n\n**Returns**\n\n- (::String) --- Output only. The resource name of the `OrgPolicyViolationsPreview`. It has the following format:\n\n\n `organizations/{organization}/locations/{location}/orgPolicyViolationsPreviews/{orgPolicyViolationsPreview}`\n\n Example:\n `organizations/my-example-org/locations/global/orgPolicyViolationsPreviews/506a5f7f`\n\n### #overlay\n\n def overlay() -\u003e ::Google::Cloud::PolicySimulator::V1::OrgPolicyOverlay\n\n**Returns**\n\n- ([::Google::Cloud::PolicySimulator::V1::OrgPolicyOverlay](./Google-Cloud-PolicySimulator-V1-OrgPolicyOverlay)) --- Required. The proposed changes we are previewing violations for.\n\n### #overlay=\n\n def overlay=(value) -\u003e ::Google::Cloud::PolicySimulator::V1::OrgPolicyOverlay\n\n**Parameter**\n\n- **value** ([::Google::Cloud::PolicySimulator::V1::OrgPolicyOverlay](./Google-Cloud-PolicySimulator-V1-OrgPolicyOverlay)) --- Required. The proposed changes we are previewing violations for. \n**Returns**\n\n- ([::Google::Cloud::PolicySimulator::V1::OrgPolicyOverlay](./Google-Cloud-PolicySimulator-V1-OrgPolicyOverlay)) --- Required. The proposed changes we are previewing violations for.\n\n### #resource_counts\n\n def resource_counts() -\u003e ::Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreview::ResourceCounts\n\n**Returns**\n\n- ([::Google::Cloud::PolicySimulator::V1::OrgPolicyViolationsPreview::ResourceCounts](./Google-Cloud-PolicySimulator-V1-OrgPolicyViolationsPreview-ResourceCounts)) --- Output only. A summary of the state of all resources scanned for compliance with the changed OrgPolicy.\n\n### #state\n\n def state() -\u003e ::Google::Cloud::PolicySimulator::V1::PreviewState\n\n**Returns**\n\n- ([::Google::Cloud::PolicySimulator::V1::PreviewState](./Google-Cloud-PolicySimulator-V1-PreviewState)) --- Output only. The state of the `OrgPolicyViolationsPreview`.\n\n### #violations_count\n\n def violations_count() -\u003e ::Integer\n\n**Returns**\n\n- (::Integer) --- Output only. The number of \\[OrgPolicyViolations\\]\\[\\] in this `OrgPolicyViolationsPreview`. This count may differ from `resource_summary.noncompliant_count` because each [OrgPolicyViolation](/ruby/docs/reference/google-cloud-policy_simulator-v1/latest/Google-Cloud-PolicySimulator-V1-OrgPolicyViolation \"Google::Cloud::PolicySimulator::V1::OrgPolicyViolation (class)\") is specific to a resource **and** constraint. If there are multiple constraints being evaluated (i.e. multiple policies in the overlay), a single resource may violate multiple constraints."]]