As of January 1, 2020 this library no longer supports Python 2 on the latest released version. Library versions released prior to that date will continue to be available. For more information please visit Python 2 support on Google Cloud.

Types for Google Cloud Orgpolicy v2 API

class google.cloud.orgpolicy_v2.types.AlternatePolicySpec(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]

Bases: proto.message.Message

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

launch

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

Type

str

spec

Specify Constraint for configurations of Cloud Platform resources.

Type

google.cloud.orgpolicy_v2.types.PolicySpec

class google.cloud.orgpolicy_v2.types.Constraint(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]

Bases: proto.message.Message

A constraint describes a way to restrict resource’s configuration. For example, you could enforce a constraint that controls which cloud services can be activated across an organization, or whether a Compute Engine instance can have serial port connections established. Constraints can be configured by the organization’s policy adminstrator to fit the needs of the organzation by setting a policy that includes constraints at different locations in the organization’s resource hierarchy. Policies are inherited down the resource hierarchy from higher levels, but can also be overridden. For details about the inheritance rules please read about [policies][google.cloud.OrgPolicy.v2.Policy].

Constraints have a default behavior determined by the constraint_default field, which is the enforcement behavior that is used in the absence of a policy being defined or inherited for the resource in question.

name

Immutable. The resource name of the Constraint. Must be in one of the following forms:

  • projects/{project_number}/constraints/{constraint_name}

  • folders/{folder_id}/constraints/{constraint_name}

  • organizations/{organization_id}/constraints/{constraint_name}

For example, “/projects/123/constraints/compute.disableSerialPortAccess”.

Type

str

display_name

The human readable name. Mutable.

Type

str

description

Detailed description of what this Constraint controls as well as how and where it is enforced.

Mutable.

Type

str

constraint_default

The evaluation behavior of this constraint in the absence of ‘Policy’.

Type

google.cloud.orgpolicy_v2.types.Constraint.ConstraintDefault

list_constraint

Defines this constraint as being a ListConstraint.

Type

google.cloud.orgpolicy_v2.types.Constraint.ListConstraint

boolean_constraint

Defines this constraint as being a BooleanConstraint.

Type

google.cloud.orgpolicy_v2.types.Constraint.BooleanConstraint

class BooleanConstraint(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]

Bases: proto.message.Message

A Constraint that is either enforced or not.

For example a constraint constraints/compute.disableSerialPortAccess. If it is enforced on a VM instance, serial port connections will not be opened to that instance.

class ConstraintDefault(value)[source]

Bases: proto.enums.Enum

Specifies the default behavior in the absence of any Policy for the Constraint. This must not be CONSTRAINT_DEFAULT_UNSPECIFIED.

Immutable after creation.

ALLOW = 1
CONSTRAINT_DEFAULT_UNSPECIFIED = 0
DENY = 2
class ListConstraint(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]

Bases: proto.message.Message

A Constraint that allows or disallows a list of string values, which are configured by an Organization’s policy administrator with a Policy.

supports_in

Indicates whether values grouped into categories can be used in Policy.allowed_values and Policy.denied_values. For example, "in:Python" would match any value in the ‘Python’ group.

Type

bool

supports_under

Indicates whether subtrees of Cloud Resource Manager resource hierarchy can be used in Policy.allowed_values and Policy.denied_values. For example, "under:folders/123" would match any resource under the ‘folders/123’ folder.

Type

bool

class google.cloud.orgpolicy_v2.types.CreatePolicyRequest(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]

Bases: proto.message.Message

The request sent to the [CreatePolicyRequest] [google.cloud.orgpolicy.v2.OrgPolicy.CreatePolicy] method.

parent

Required. The Cloud resource that will parent the new Policy. Must be in one of the following forms:

  • projects/{project_number}

  • projects/{project_id}

  • folders/{folder_id}

  • organizations/{organization_id}

Type

str

policy

Required. Policy to create.

Type

google.cloud.orgpolicy_v2.types.Policy

class google.cloud.orgpolicy_v2.types.DeletePolicyRequest(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]

Bases: proto.message.Message

The request sent to the [DeletePolicy] [google.cloud.orgpolicy.v2.OrgPolicy.DeletePolicy] method.

name

Required. Name of the policy to delete. See Policy for naming rules.

Type

str

class google.cloud.orgpolicy_v2.types.GetEffectivePolicyRequest(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]

Bases: proto.message.Message

The request sent to the [GetEffectivePolicy] [google.cloud.orgpolicy.v2.OrgPolicy.GetEffectivePolicy] method.

name

Required. The effective policy to compute. See Policy for naming rules.

Type

str

class google.cloud.orgpolicy_v2.types.GetPolicyRequest(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]

Bases: proto.message.Message

The request sent to the [GetPolicy] [google.cloud.orgpolicy.v2.OrgPolicy.GetPolicy] method.

name

Required. Resource name of the policy. See Policy for naming requirements.

Type

str

class google.cloud.orgpolicy_v2.types.ListConstraintsRequest(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]

Bases: proto.message.Message

The request sent to the [ListConstraints] [google.cloud.orgpolicy.v2.OrgPolicy.ListConstraints] method.

parent

Required. The Cloud resource that parents the constraint. Must be in one of the following forms:

  • projects/{project_number}

  • projects/{project_id}

  • folders/{folder_id}

  • organizations/{organization_id}

Type

str

page_size

Size of the pages to be returned. This is currently unsupported and will be ignored. The server may at any point start using this field to limit page size.

Type

int

page_token

Page token used to retrieve the next page. This is currently unsupported and will be ignored. The server may at any point start using this field.

Type

str

class google.cloud.orgpolicy_v2.types.ListConstraintsResponse(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]

Bases: proto.message.Message

The response returned from the [ListConstraints] [google.cloud.orgpolicy.v2.OrgPolicy.ListConstraints] method.

constraints

The collection of constraints that are available on the targeted resource.

Type

Sequence[google.cloud.orgpolicy_v2.types.Constraint]

next_page_token

Page token used to retrieve the next page. This is currently not used.

Type

str

property raw_page
class google.cloud.orgpolicy_v2.types.ListPoliciesRequest(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]

Bases: proto.message.Message

The request sent to the [ListPolicies] [google.cloud.orgpolicy.v2.OrgPolicy.ListPolicies] method.

parent

Required. The target Cloud resource that parents the set of constraints and policies that will be returned from this call. Must be in one of the following forms:

  • projects/{project_number}

  • projects/{project_id}

  • folders/{folder_id}

  • organizations/{organization_id}

Type

str

page_size

Size of the pages to be returned. This is currently unsupported and will be ignored. The server may at any point start using this field to limit page size.

Type

int

page_token

Page token used to retrieve the next page. This is currently unsupported and will be ignored. The server may at any point start using this field.

Type

str

class google.cloud.orgpolicy_v2.types.ListPoliciesResponse(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]

Bases: proto.message.Message

The response returned from the [ListPolicies] [google.cloud.orgpolicy.v2.OrgPolicy.ListPolicies] method. It will be empty if no Policies are set on the resource.

policies

All Policies that exist on the resource. It will be empty if no Policies are set.

Type

Sequence[google.cloud.orgpolicy_v2.types.Policy]

next_page_token

Page token used to retrieve the next page. This is currently not used, but the server may at any point start supplying a valid token.

Type

str

property raw_page
class google.cloud.orgpolicy_v2.types.Policy(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]

Bases: proto.message.Message

Defines a Cloud Organization Policy which is used to specify Constraints for configurations of Cloud Platform resources.

name

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/{project_number}/policies/{constraint_name}

  • folders/{folder_id}/policies/{constraint_name}

  • organizations/{organization_id}/policies/{constraint_name}

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

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

Type

str

spec

Basic information about the Organization Policy.

Type

google.cloud.orgpolicy_v2.types.PolicySpec

alternate

An alternate policy configuration that will be used instead of the baseline policy configurations as determined by the launch. Currently the only way the launch can trigger the alternate configuration is via dry- run/darklaunch.

Type

google.cloud.orgpolicy_v2.types.AlternatePolicySpec

class google.cloud.orgpolicy_v2.types.PolicySpec(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]

Bases: proto.message.Message

Defines a Cloud Organization PolicySpec which is used to specify Constraints for configurations of Cloud Platform resources.

etag

An opaque tag indicating the current version of the Policy, 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 Policy to use when executing a read-modify-write loop.

When the Policy is returned from a GetEffectivePolicy request, the etag will be unset.

Type

str

update_time

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.

Type

google.protobuf.timestamp_pb2.Timestamp

rules

Up to 10 PolicyRules are allowed.

In Policies for boolean constraints, the following requirements apply:

  • There must be one and only one PolicyRule where condition is unset.

  • BooleanPolicyRules with conditions must set enforced to the opposite of the PolicyRule without a condition.

  • During policy evaluation, PolicyRules with conditions that are true for a target resource take precedence.

Type

Sequence[google.cloud.orgpolicy_v2.types.PolicySpec.PolicyRule]

inherit_from_parent

Determines the inheritance behavior for this Policy.

If inherit_from_parent is true, PolicyRules 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.

Type

bool

reset

Ignores policies set above this resource and restores the constraint_default 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 inherit_from_parent must be set to false.

Type

bool

class PolicyRule(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]

Bases: proto.message.Message

A rule used to express this policy. .. attribute:: values

List of values to be used for this PolicyRule. This field can be set only in Policies for list constraints.

type

google.cloud.orgpolicy_v2.types.PolicySpec.PolicyRule.StringValues

allow_all

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

Type

bool

deny_all

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

Type

bool

enforce

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.

Type

bool

condition

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.matchLabels(key_name, value_name)”, where key_name and value_name are the resource names for Label Keys and Values. These names are available from the Label Manager Service. An example expression is: “resource.matchLabels(‘labelKeys/123, ‘labelValues/456’)”.

Type

google.type.expr_pb2.Expr

class StringValues(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]

Bases: proto.message.Message

A message that holds specific allowed and denied values. This message can define specific values and subtrees of Cloud 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/”, e.g. “projects/tokyo-rain-123” - “folders/”, e.g. “folders/1234” - “organizations/”, e.g. “organizations/1234” The supports_under field of the associated Constraint defines whether ancestry prefixes can be used.

allowed_values

List of values allowed at this resource.

Type

Sequence[str]

denied_values

List of values denied at this resource.

Type

Sequence[str]

class google.cloud.orgpolicy_v2.types.UpdatePolicyRequest(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]

Bases: proto.message.Message

The request sent to the [UpdatePolicyRequest] [google.cloud.orgpolicy.v2.OrgPolicy.UpdatePolicy] method.

policy

Required. Policy to update.

Type

google.cloud.orgpolicy_v2.types.Policy