Class Constraint.Builder (2.46.0)

public static final class Constraint.Builder extends GeneratedMessageV3.Builder<Constraint.Builder> implements ConstraintOrBuilder

A constraint describes a way to restrict resource's configuration. For example, you could enforce a constraint that controls which Google 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 policy administrator to fit the needs of the organization 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.

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.

Protobuf type google.cloud.orgpolicy.v2.Constraint

Implements

ConstraintOrBuilder

Static Methods

getDescriptor()

public static final Descriptors.Descriptor getDescriptor()
Returns
Type Description
Descriptor

Methods

addRepeatedField(Descriptors.FieldDescriptor field, Object value)

public Constraint.Builder addRepeatedField(Descriptors.FieldDescriptor field, Object value)
Parameters
Name Description
field FieldDescriptor
value Object
Returns
Type Description
Constraint.Builder
Overrides

build()

public Constraint build()
Returns
Type Description
Constraint

buildPartial()

public Constraint buildPartial()
Returns
Type Description
Constraint

clear()

public Constraint.Builder clear()
Returns
Type Description
Constraint.Builder
Overrides

clearBooleanConstraint()

public Constraint.Builder clearBooleanConstraint()

Defines this constraint as being a BooleanConstraint.

.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint boolean_constraint = 6;

Returns
Type Description
Constraint.Builder

clearConstraintDefault()

public Constraint.Builder clearConstraintDefault()

The evaluation behavior of this constraint in the absence of a policy.

.google.cloud.orgpolicy.v2.Constraint.ConstraintDefault constraint_default = 4;

Returns
Type Description
Constraint.Builder

This builder for chaining.

clearConstraintType()

public Constraint.Builder clearConstraintType()
Returns
Type Description
Constraint.Builder

clearDescription()

public Constraint.Builder clearDescription()

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

Mutable.

string description = 3;

Returns
Type Description
Constraint.Builder

This builder for chaining.

clearDisplayName()

public Constraint.Builder clearDisplayName()

The human readable name.

Mutable.

string display_name = 2;

Returns
Type Description
Constraint.Builder

This builder for chaining.

clearField(Descriptors.FieldDescriptor field)

public Constraint.Builder clearField(Descriptors.FieldDescriptor field)
Parameter
Name Description
field FieldDescriptor
Returns
Type Description
Constraint.Builder
Overrides

clearListConstraint()

public Constraint.Builder clearListConstraint()

Defines this constraint as being a ListConstraint.

.google.cloud.orgpolicy.v2.Constraint.ListConstraint list_constraint = 5;

Returns
Type Description
Constraint.Builder

clearName()

public Constraint.Builder clearName()

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".

string name = 1 [(.google.api.field_behavior) = IMMUTABLE];

Returns
Type Description
Constraint.Builder

This builder for chaining.

clearOneof(Descriptors.OneofDescriptor oneof)

public Constraint.Builder clearOneof(Descriptors.OneofDescriptor oneof)
Parameter
Name Description
oneof OneofDescriptor
Returns
Type Description
Constraint.Builder
Overrides

clearSupportsDryRun()

public Constraint.Builder clearSupportsDryRun()

Shows if dry run is supported for this constraint or not.

bool supports_dry_run = 7;

Returns
Type Description
Constraint.Builder

This builder for chaining.

clone()

public Constraint.Builder clone()
Returns
Type Description
Constraint.Builder
Overrides

getBooleanConstraint()

public Constraint.BooleanConstraint getBooleanConstraint()

Defines this constraint as being a BooleanConstraint.

.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint boolean_constraint = 6;

Returns
Type Description
Constraint.BooleanConstraint

The booleanConstraint.

getBooleanConstraintBuilder()

public Constraint.BooleanConstraint.Builder getBooleanConstraintBuilder()

Defines this constraint as being a BooleanConstraint.

.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint boolean_constraint = 6;

Returns
Type Description
Constraint.BooleanConstraint.Builder

getBooleanConstraintOrBuilder()

public Constraint.BooleanConstraintOrBuilder getBooleanConstraintOrBuilder()

Defines this constraint as being a BooleanConstraint.

.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint boolean_constraint = 6;

Returns
Type Description
Constraint.BooleanConstraintOrBuilder

getConstraintDefault()

public Constraint.ConstraintDefault getConstraintDefault()

The evaluation behavior of this constraint in the absence of a policy.

.google.cloud.orgpolicy.v2.Constraint.ConstraintDefault constraint_default = 4;

Returns
Type Description
Constraint.ConstraintDefault

The constraintDefault.

getConstraintDefaultValue()

public int getConstraintDefaultValue()

The evaluation behavior of this constraint in the absence of a policy.

.google.cloud.orgpolicy.v2.Constraint.ConstraintDefault constraint_default = 4;

Returns
Type Description
int

The enum numeric value on the wire for constraintDefault.

getConstraintTypeCase()

public Constraint.ConstraintTypeCase getConstraintTypeCase()
Returns
Type Description
Constraint.ConstraintTypeCase

getDefaultInstanceForType()

public Constraint getDefaultInstanceForType()
Returns
Type Description
Constraint

getDescription()

public String getDescription()

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

Mutable.

string description = 3;

Returns
Type Description
String

The description.

getDescriptionBytes()

public ByteString getDescriptionBytes()

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

Mutable.

string description = 3;

Returns
Type Description
ByteString

The bytes for description.

getDescriptorForType()

public Descriptors.Descriptor getDescriptorForType()
Returns
Type Description
Descriptor
Overrides

getDisplayName()

public String getDisplayName()

The human readable name.

Mutable.

string display_name = 2;

Returns
Type Description
String

The displayName.

getDisplayNameBytes()

public ByteString getDisplayNameBytes()

The human readable name.

Mutable.

string display_name = 2;

Returns
Type Description
ByteString

The bytes for displayName.

getListConstraint()

public Constraint.ListConstraint getListConstraint()

Defines this constraint as being a ListConstraint.

.google.cloud.orgpolicy.v2.Constraint.ListConstraint list_constraint = 5;

Returns
Type Description
Constraint.ListConstraint

The listConstraint.

getListConstraintBuilder()

public Constraint.ListConstraint.Builder getListConstraintBuilder()

Defines this constraint as being a ListConstraint.

.google.cloud.orgpolicy.v2.Constraint.ListConstraint list_constraint = 5;

Returns
Type Description
Constraint.ListConstraint.Builder

getListConstraintOrBuilder()

public Constraint.ListConstraintOrBuilder getListConstraintOrBuilder()

Defines this constraint as being a ListConstraint.

.google.cloud.orgpolicy.v2.Constraint.ListConstraint list_constraint = 5;

Returns
Type Description
Constraint.ListConstraintOrBuilder

getName()

public String getName()

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".

string name = 1 [(.google.api.field_behavior) = IMMUTABLE];

Returns
Type Description
String

The name.

getNameBytes()

public ByteString getNameBytes()

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".

string name = 1 [(.google.api.field_behavior) = IMMUTABLE];

Returns
Type Description
ByteString

The bytes for name.

getSupportsDryRun()

public boolean getSupportsDryRun()

Shows if dry run is supported for this constraint or not.

bool supports_dry_run = 7;

Returns
Type Description
boolean

The supportsDryRun.

hasBooleanConstraint()

public boolean hasBooleanConstraint()

Defines this constraint as being a BooleanConstraint.

.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint boolean_constraint = 6;

Returns
Type Description
boolean

Whether the booleanConstraint field is set.

hasListConstraint()

public boolean hasListConstraint()

Defines this constraint as being a ListConstraint.

.google.cloud.orgpolicy.v2.Constraint.ListConstraint list_constraint = 5;

Returns
Type Description
boolean

Whether the listConstraint field is set.

internalGetFieldAccessorTable()

protected GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()
Returns
Type Description
FieldAccessorTable
Overrides

isInitialized()

public final boolean isInitialized()
Returns
Type Description
boolean
Overrides

mergeBooleanConstraint(Constraint.BooleanConstraint value)

public Constraint.Builder mergeBooleanConstraint(Constraint.BooleanConstraint value)

Defines this constraint as being a BooleanConstraint.

.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint boolean_constraint = 6;

Parameter
Name Description
value Constraint.BooleanConstraint
Returns
Type Description
Constraint.Builder

mergeFrom(Constraint other)

public Constraint.Builder mergeFrom(Constraint other)
Parameter
Name Description
other Constraint
Returns
Type Description
Constraint.Builder

mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)

public Constraint.Builder mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
input CodedInputStream
extensionRegistry ExtensionRegistryLite
Returns
Type Description
Constraint.Builder
Overrides
Exceptions
Type Description
IOException

mergeFrom(Message other)

public Constraint.Builder mergeFrom(Message other)
Parameter
Name Description
other Message
Returns
Type Description
Constraint.Builder
Overrides

mergeListConstraint(Constraint.ListConstraint value)

public Constraint.Builder mergeListConstraint(Constraint.ListConstraint value)

Defines this constraint as being a ListConstraint.

.google.cloud.orgpolicy.v2.Constraint.ListConstraint list_constraint = 5;

Parameter
Name Description
value Constraint.ListConstraint
Returns
Type Description
Constraint.Builder

mergeUnknownFields(UnknownFieldSet unknownFields)

public final Constraint.Builder mergeUnknownFields(UnknownFieldSet unknownFields)
Parameter
Name Description
unknownFields UnknownFieldSet
Returns
Type Description
Constraint.Builder
Overrides

setBooleanConstraint(Constraint.BooleanConstraint value)

public Constraint.Builder setBooleanConstraint(Constraint.BooleanConstraint value)

Defines this constraint as being a BooleanConstraint.

.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint boolean_constraint = 6;

Parameter
Name Description
value Constraint.BooleanConstraint
Returns
Type Description
Constraint.Builder

setBooleanConstraint(Constraint.BooleanConstraint.Builder builderForValue)

public Constraint.Builder setBooleanConstraint(Constraint.BooleanConstraint.Builder builderForValue)

Defines this constraint as being a BooleanConstraint.

.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint boolean_constraint = 6;

Parameter
Name Description
builderForValue Constraint.BooleanConstraint.Builder
Returns
Type Description
Constraint.Builder

setConstraintDefault(Constraint.ConstraintDefault value)

public Constraint.Builder setConstraintDefault(Constraint.ConstraintDefault value)

The evaluation behavior of this constraint in the absence of a policy.

.google.cloud.orgpolicy.v2.Constraint.ConstraintDefault constraint_default = 4;

Parameter
Name Description
value Constraint.ConstraintDefault

The constraintDefault to set.

Returns
Type Description
Constraint.Builder

This builder for chaining.

setConstraintDefaultValue(int value)

public Constraint.Builder setConstraintDefaultValue(int value)

The evaluation behavior of this constraint in the absence of a policy.

.google.cloud.orgpolicy.v2.Constraint.ConstraintDefault constraint_default = 4;

Parameter
Name Description
value int

The enum numeric value on the wire for constraintDefault to set.

Returns
Type Description
Constraint.Builder

This builder for chaining.

setDescription(String value)

public Constraint.Builder setDescription(String value)

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

Mutable.

string description = 3;

Parameter
Name Description
value String

The description to set.

Returns
Type Description
Constraint.Builder

This builder for chaining.

setDescriptionBytes(ByteString value)

public Constraint.Builder setDescriptionBytes(ByteString value)

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

Mutable.

string description = 3;

Parameter
Name Description
value ByteString

The bytes for description to set.

Returns
Type Description
Constraint.Builder

This builder for chaining.

setDisplayName(String value)

public Constraint.Builder setDisplayName(String value)

The human readable name.

Mutable.

string display_name = 2;

Parameter
Name Description
value String

The displayName to set.

Returns
Type Description
Constraint.Builder

This builder for chaining.

setDisplayNameBytes(ByteString value)

public Constraint.Builder setDisplayNameBytes(ByteString value)

The human readable name.

Mutable.

string display_name = 2;

Parameter
Name Description
value ByteString

The bytes for displayName to set.

Returns
Type Description
Constraint.Builder

This builder for chaining.

setField(Descriptors.FieldDescriptor field, Object value)

public Constraint.Builder setField(Descriptors.FieldDescriptor field, Object value)
Parameters
Name Description
field FieldDescriptor
value Object
Returns
Type Description
Constraint.Builder
Overrides

setListConstraint(Constraint.ListConstraint value)

public Constraint.Builder setListConstraint(Constraint.ListConstraint value)

Defines this constraint as being a ListConstraint.

.google.cloud.orgpolicy.v2.Constraint.ListConstraint list_constraint = 5;

Parameter
Name Description
value Constraint.ListConstraint
Returns
Type Description
Constraint.Builder

setListConstraint(Constraint.ListConstraint.Builder builderForValue)

public Constraint.Builder setListConstraint(Constraint.ListConstraint.Builder builderForValue)

Defines this constraint as being a ListConstraint.

.google.cloud.orgpolicy.v2.Constraint.ListConstraint list_constraint = 5;

Parameter
Name Description
builderForValue Constraint.ListConstraint.Builder
Returns
Type Description
Constraint.Builder

setName(String value)

public Constraint.Builder setName(String value)

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".

string name = 1 [(.google.api.field_behavior) = IMMUTABLE];

Parameter
Name Description
value String

The name to set.

Returns
Type Description
Constraint.Builder

This builder for chaining.

setNameBytes(ByteString value)

public Constraint.Builder setNameBytes(ByteString value)

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".

string name = 1 [(.google.api.field_behavior) = IMMUTABLE];

Parameter
Name Description
value ByteString

The bytes for name to set.

Returns
Type Description
Constraint.Builder

This builder for chaining.

setRepeatedField(Descriptors.FieldDescriptor field, int index, Object value)

public Constraint.Builder setRepeatedField(Descriptors.FieldDescriptor field, int index, Object value)
Parameters
Name Description
field FieldDescriptor
index int
value Object
Returns
Type Description
Constraint.Builder
Overrides

setSupportsDryRun(boolean value)

public Constraint.Builder setSupportsDryRun(boolean value)

Shows if dry run is supported for this constraint or not.

bool supports_dry_run = 7;

Parameter
Name Description
value boolean

The supportsDryRun to set.

Returns
Type Description
Constraint.Builder

This builder for chaining.

setUnknownFields(UnknownFieldSet unknownFields)

public final Constraint.Builder setUnknownFields(UnknownFieldSet unknownFields)
Parameter
Name Description
unknownFields UnknownFieldSet
Returns
Type Description
Constraint.Builder
Overrides