REST Resource: organizations.locations.orgPolicyViolationsPreviews

Resource: 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.

JSON representation
{
  "name": string,
  "state": enum (PreviewState),
  "overlay": {
    object (OrgPolicyOverlay)
  },
  "violationsCount": integer,
  "resourceCounts": {
    object (ResourceCounts)
  },
  "customConstraints": [
    string
  ],
  "createTime": string
}
Fields
name

string

Output only. The resource name of the OrgPolicyViolationsPreview. It has the following format:

organizations/{organization}/locations/{location}/orgPolicyViolationsPreviews/{orgPolicyViolationsPreview}

Example: organizations/my-example-org/locations/global/orgPolicyViolationsPreviews/506a5f7f

state

enum (PreviewState)

Output only. The state of the OrgPolicyViolationsPreview.

overlay

object (OrgPolicyOverlay)

Required. The proposed changes we are previewing violations for.

violationsCount

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.

resourceCounts

object (ResourceCounts)

Output only. A summary of the state of all resources scanned for compliance with the changed OrgPolicy.

customConstraints[]

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.

Format: organizations/{organizationId}/customConstraints/{custom_constraint_id}

Example: organizations/123/customConstraints/custom.createOnlyE2TypeVms

createTime

string (Timestamp format)

Output only. Time when this OrgPolicyViolationsPreview was created.

A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".

PreviewState

The current state of an OrgPolicyViolationsPreview.

Enums
PREVIEW_STATE_UNSPECIFIED The state is unspecified.
PREVIEW_PENDING The OrgPolicyViolationsPreview has not been created yet.
PREVIEW_RUNNING The OrgPolicyViolationsPreview is currently being created.
PREVIEW_SUCCEEDED The OrgPolicyViolationsPreview creation finished successfully.
PREVIEW_FAILED The OrgPolicyViolationsPreview creation failed with an error.

OrgPolicyOverlay

The proposed changes to OrgPolicy.

JSON representation
{
  "policies": [
    {
      object (PolicyOverlay)
    }
  ],
  "customConstraints": [
    {
      object (CustomConstraintOverlay)
    }
  ]
}
Fields
policies[]

object (PolicyOverlay)

Optional. The OrgPolicy changes to preview violations for.

Any existing OrgPolicies with the same name will be overridden in the simulation. That is, violations will be determined as if all policies in the overlay were created or updated.

customConstraints[]

object (CustomConstraintOverlay)

Optional. The OrgPolicy CustomConstraint changes to preview violations for.

Any existing CustomConstraints with the same name will be overridden in the simulation. That is, violations will be determined as if all custom constraints in the overlay were instantiated.

Only a single customConstraint is supported in the overlay at a time. For evaluating multiple constraints, multiple orgPolicyViolationsPreviews.generate requests are made, where each request evaluates a single constraint.

PolicyOverlay

A change to an OrgPolicy.

JSON representation
{
  "policyParent": string,
  "policy": {
    object (Policy)
  }
}
Fields
policyParent

string

Optional. The parent of the policy we are attaching to. Example: "projects/123456"

policy

object (Policy)

Optional. The new or updated OrgPolicy.

Policy

Defines an organization policy which is used to specify constraints for configurations of Google Cloud resources.

JSON representation
{
  "name": string,
  "spec": {
    object (PolicySpec)
  },
  "alternate": {
    object (AlternatePolicySpec)
  },
  "dryRunSpec": {
    object (PolicySpec)
  },
  "etag": string
}
Fields
name

string

Immutable. The resource name of the policy. Must be one of the following forms, where constraint_name is the name of the constraint which this policy configures:

  • projects/{projectNumber}/policies/{constraint_name}
  • folders/{folderId}/policies/{constraint_name}
  • organizations/{organizationId}/policies/{constraint_name}

For example, projects/123/policies/compute.disableSerialPortAccess.

Note: projects/{projectId}/policies/{constraint_name} is also an acceptable name for API requests, but responses will return the name using the equivalent project number.

spec

object (PolicySpec)

Basic information about the Organization Policy.

alternate
(deprecated)

object (AlternatePolicySpec)

Deprecated.

dryRunSpec

object (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.

etag

string

Optional. An opaque tag indicating the current state of the policy, used for concurrency control. This 'etag' is computed by the server based on the value of other fields, and may be sent on update and delete requests to ensure the client has an up-to-date value before proceeding.

PolicySpec

Defines a Google Cloud policy specification which is used to specify constraints for configurations of Google Cloud resources.

JSON representation
{
  "etag": string,
  "updateTime": string,
  "rules": [
    {
      object (PolicyRule)
    }
  ],
  "inheritFromParent": boolean,
  "reset": boolean
}
Fields
etag

string

An opaque tag indicating the current version of the policySpec, used for concurrency control.

This field is ignored if used in a CreatePolicy request.

When the policy is returned from either a GetPolicy or a ListPolicies request, this etag indicates the version of the current policySpec to use when executing a read-modify-write loop.

When the policy is returned from a policies.getEffectivePolicy request, the etag will be unset.

updateTime

string (Timestamp format)

Output only. The time stamp this was previously updated. This represents the last time a call to CreatePolicy or UpdatePolicy was made for that policy.

A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".

rules[]

object (PolicyRule)

In policies for boolean constraints, the following requirements apply:

  • There must be one and only one policy rule where condition is unset.
  • Boolean policy rules with conditions must set enforced to the opposite of the policy rule without a condition.
  • During policy evaluation, policy rules with conditions that are true for a target resource take precedence.
inheritFromParent

boolean

Determines the inheritance behavior for this policy.

If inheritFromParent is true, policy rules set higher up in the hierarchy (up to the closest root) are inherited and present in the effective policy. If it is false, then no rules are inherited, and this policy becomes the new root for evaluation. This field can be set only for policies which configure list constraints.

reset

boolean

Ignores policies set above this resource and restores the constraintDefault enforcement behavior of the specific constraint at this resource. This field can be set in policies for either list or boolean constraints. If set, rules must be empty and inheritFromParent must be set to false.

PolicyRule

A rule used to express this policy.

JSON representation
{
  "condition": {
    object (Expr)
  },

  // Union field kind can be only one of the following:
  "values": {
    object (StringValues)
  },
  "allowAll": boolean,
  "denyAll": boolean,
  "enforce": boolean
  // End of list of possible types for union field kind.
}
Fields
condition

object (Expr)

A condition which determines whether this rule is used in the evaluation of the policy. When set, the expression field in the `Expr' must include from 1 to 10 subexpressions, joined by the "||" or "&&" operators. Each subexpression must be of the form "resource.matchTag('/tag_key_short_name, 'tag_value_short_name')". or "resource.matchTagId('tagKeys/key_id', 'tagValues/value_id')". where key_name and value_name are the resource names for Label Keys and Values. These names are available from the Tag Manager Service. An example expression is: "resource.matchTag('123456789/environment, 'prod')". or "resource.matchTagId('tagKeys/123', 'tagValues/456')".

Union field kind.

kind can be only one of the following:

values

object (StringValues)

List of values to be used for this policy rule. This field can be set only in policies for list constraints.

allowAll

boolean

Setting this to true means that all values are allowed. This field can be set only in policies for list constraints.

denyAll

boolean

Setting this to true means that all values are denied. This field can be set only in policies for list constraints.

enforce

boolean

If true, then the policy is enforced. If false, then any configuration is acceptable. This field can be set only in policies for boolean constraints.

StringValues

A message that holds specific allowed and denied values. This message can define specific values and subtrees of the Resource Manager resource hierarchy (Organizations, Folders, Projects) that are allowed or denied. This is achieved by using the under: and optional is: prefixes. The under: prefix is used to denote resource subtree values. The is: prefix is used to denote specific values, and is required only if the value contains a ":". Values prefixed with "is:" are treated the same as values with no prefix. Ancestry subtrees must be in one of the following formats:

  • projects/<project-id> (for example, projects/tokyo-rain-123)
  • folders/<folder-id> (for example, folders/1234)
  • organizations/<organization-id> (for example, organizations/1234)

The supportsUnder field of the associated Constraint defines whether ancestry prefixes can be used.

JSON representation
{
  "allowedValues": [
    string
  ],
  "deniedValues": [
    string
  ]
}
Fields
allowedValues[]

string

List of values allowed at this resource.

deniedValues[]

string

List of values denied at this resource.

AlternatePolicySpec

Similar to PolicySpec but with an extra 'launch' field for launch reference. The PolicySpec here is specific for dry-run/darklaunch.

JSON representation
{
  "launch": string,
  "spec": {
    object (PolicySpec)
  }
}
Fields
launch

string

Reference to the launch that will be used while audit logging and to control the launch. Should be set only in the alternate policy.

spec

object (PolicySpec)

Specify constraint for configurations of Google Cloud resources.

CustomConstraintOverlay

A change to an OrgPolicy custom constraint.

JSON representation
{
  "customConstraintParent": string,
  "customConstraint": {
    object (CustomConstraint)
  }
}
Fields
customConstraintParent

string

Optional. Resource the constraint is attached to. Example: "organization/987654"

customConstraint

object (CustomConstraint)

Optional. The new or updated custom constraint.

ResourceCounts

A summary of the state of all resources scanned for compliance with the changed OrgPolicy.

JSON representation
{
  "scanned": integer,
  "noncompliant": integer,
  "compliant": integer,
  "unenforced": integer,
  "errors": integer
}
Fields
scanned

integer

Output only. Number of resources checked for compliance.

Must equal: unenforced + noncompliant + compliant + error

noncompliant

integer

Output only. Number of scanned resources with at least one violation.

compliant

integer

Output only. Number of scanned resources with zero violations.

unenforced

integer

Output only. Number of resources where the constraint was not enforced, i.e. the Policy set enforced: false for that resource.

errors

integer

Output only. Number of resources that returned an error when scanned.

Methods

create

CreateOrgPolicyViolationsPreview creates an OrgPolicyViolationsPreview for the proposed changes in the provided [OrgPolicyViolationsPreview.OrgPolicyOverlay][].

generate

GenerateOrgPolicyViolationsPreview generates an OrgPolicyViolationsPreview for the proposed changes in the provided [OrgPolicyViolationsPreview.OrgPolicyOverlay][].

get

GetOrgPolicyViolationsPreview gets the specified OrgPolicyViolationsPreview.

list

ListOrgPolicyViolationsPreviews lists each OrgPolicyViolationsPreview in an organization.