Class CorsPolicy.Builder (1.56.0)

public static final class CorsPolicy.Builder extends GeneratedMessageV3.Builder<CorsPolicy.Builder> implements CorsPolicyOrBuilder

The specification for allowing client-side cross-origin requests. For more information about the W3C recommendation for cross-origin resource sharing (CORS), see Fetch API Living Standard.

Protobuf type google.cloud.compute.v1.CorsPolicy

Implements

CorsPolicyOrBuilder

Static Methods

getDescriptor()

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

Methods

addAllAllowHeaders(Iterable<String> values)

public CorsPolicy.Builder addAllAllowHeaders(Iterable<String> values)

Specifies the content for the Access-Control-Allow-Headers header.

repeated string allow_headers = 45179024;

Parameter
Name Description
values Iterable<String>

The allowHeaders to add.

Returns
Type Description
CorsPolicy.Builder

This builder for chaining.

addAllAllowMethods(Iterable<String> values)

public CorsPolicy.Builder addAllAllowMethods(Iterable<String> values)

Specifies the content for the Access-Control-Allow-Methods header.

repeated string allow_methods = 205405372;

Parameter
Name Description
values Iterable<String>

The allowMethods to add.

Returns
Type Description
CorsPolicy.Builder

This builder for chaining.

addAllAllowOriginRegexes(Iterable<String> values)

public CorsPolicy.Builder addAllAllowOriginRegexes(Iterable<String> values)

Specifies a regular expression that matches allowed origins. For more information, see regular expression syntax . An origin is allowed if it matches either an item in allowOrigins or an item in allowOriginRegexes. Regular expressions can only be used when the loadBalancingScheme is set to INTERNAL_SELF_MANAGED.

repeated string allow_origin_regexes = 215385810;

Parameter
Name Description
values Iterable<String>

The allowOriginRegexes to add.

Returns
Type Description
CorsPolicy.Builder

This builder for chaining.

addAllAllowOrigins(Iterable<String> values)

public CorsPolicy.Builder addAllAllowOrigins(Iterable<String> values)

Specifies the list of origins that is allowed to do CORS requests. An origin is allowed if it matches either an item in allowOrigins or an item in allowOriginRegexes.

repeated string allow_origins = 194914071;

Parameter
Name Description
values Iterable<String>

The allowOrigins to add.

Returns
Type Description
CorsPolicy.Builder

This builder for chaining.

addAllExposeHeaders(Iterable<String> values)

public CorsPolicy.Builder addAllExposeHeaders(Iterable<String> values)

Specifies the content for the Access-Control-Expose-Headers header.

repeated string expose_headers = 247604747;

Parameter
Name Description
values Iterable<String>

The exposeHeaders to add.

Returns
Type Description
CorsPolicy.Builder

This builder for chaining.

addAllowHeaders(String value)

public CorsPolicy.Builder addAllowHeaders(String value)

Specifies the content for the Access-Control-Allow-Headers header.

repeated string allow_headers = 45179024;

Parameter
Name Description
value String

The allowHeaders to add.

Returns
Type Description
CorsPolicy.Builder

This builder for chaining.

addAllowHeadersBytes(ByteString value)

public CorsPolicy.Builder addAllowHeadersBytes(ByteString value)

Specifies the content for the Access-Control-Allow-Headers header.

repeated string allow_headers = 45179024;

Parameter
Name Description
value ByteString

The bytes of the allowHeaders to add.

Returns
Type Description
CorsPolicy.Builder

This builder for chaining.

addAllowMethods(String value)

public CorsPolicy.Builder addAllowMethods(String value)

Specifies the content for the Access-Control-Allow-Methods header.

repeated string allow_methods = 205405372;

Parameter
Name Description
value String

The allowMethods to add.

Returns
Type Description
CorsPolicy.Builder

This builder for chaining.

addAllowMethodsBytes(ByteString value)

public CorsPolicy.Builder addAllowMethodsBytes(ByteString value)

Specifies the content for the Access-Control-Allow-Methods header.

repeated string allow_methods = 205405372;

Parameter
Name Description
value ByteString

The bytes of the allowMethods to add.

Returns
Type Description
CorsPolicy.Builder

This builder for chaining.

addAllowOriginRegexes(String value)

public CorsPolicy.Builder addAllowOriginRegexes(String value)

Specifies a regular expression that matches allowed origins. For more information, see regular expression syntax . An origin is allowed if it matches either an item in allowOrigins or an item in allowOriginRegexes. Regular expressions can only be used when the loadBalancingScheme is set to INTERNAL_SELF_MANAGED.

repeated string allow_origin_regexes = 215385810;

Parameter
Name Description
value String

The allowOriginRegexes to add.

Returns
Type Description
CorsPolicy.Builder

This builder for chaining.

addAllowOriginRegexesBytes(ByteString value)

public CorsPolicy.Builder addAllowOriginRegexesBytes(ByteString value)

Specifies a regular expression that matches allowed origins. For more information, see regular expression syntax . An origin is allowed if it matches either an item in allowOrigins or an item in allowOriginRegexes. Regular expressions can only be used when the loadBalancingScheme is set to INTERNAL_SELF_MANAGED.

repeated string allow_origin_regexes = 215385810;

Parameter
Name Description
value ByteString

The bytes of the allowOriginRegexes to add.

Returns
Type Description
CorsPolicy.Builder

This builder for chaining.

addAllowOrigins(String value)

public CorsPolicy.Builder addAllowOrigins(String value)

Specifies the list of origins that is allowed to do CORS requests. An origin is allowed if it matches either an item in allowOrigins or an item in allowOriginRegexes.

repeated string allow_origins = 194914071;

Parameter
Name Description
value String

The allowOrigins to add.

Returns
Type Description
CorsPolicy.Builder

This builder for chaining.

addAllowOriginsBytes(ByteString value)

public CorsPolicy.Builder addAllowOriginsBytes(ByteString value)

Specifies the list of origins that is allowed to do CORS requests. An origin is allowed if it matches either an item in allowOrigins or an item in allowOriginRegexes.

repeated string allow_origins = 194914071;

Parameter
Name Description
value ByteString

The bytes of the allowOrigins to add.

Returns
Type Description
CorsPolicy.Builder

This builder for chaining.

addExposeHeaders(String value)

public CorsPolicy.Builder addExposeHeaders(String value)

Specifies the content for the Access-Control-Expose-Headers header.

repeated string expose_headers = 247604747;

Parameter
Name Description
value String

The exposeHeaders to add.

Returns
Type Description
CorsPolicy.Builder

This builder for chaining.

addExposeHeadersBytes(ByteString value)

public CorsPolicy.Builder addExposeHeadersBytes(ByteString value)

Specifies the content for the Access-Control-Expose-Headers header.

repeated string expose_headers = 247604747;

Parameter
Name Description
value ByteString

The bytes of the exposeHeaders to add.

Returns
Type Description
CorsPolicy.Builder

This builder for chaining.

addRepeatedField(Descriptors.FieldDescriptor field, Object value)

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

build()

public CorsPolicy build()
Returns
Type Description
CorsPolicy

buildPartial()

public CorsPolicy buildPartial()
Returns
Type Description
CorsPolicy

clear()

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

clearAllowCredentials()

public CorsPolicy.Builder clearAllowCredentials()

In response to a preflight request, setting this to true indicates that the actual request can include user credentials. This field translates to the Access-Control-Allow-Credentials header. Default is false.

optional bool allow_credentials = 481263366;

Returns
Type Description
CorsPolicy.Builder

This builder for chaining.

clearAllowHeaders()

public CorsPolicy.Builder clearAllowHeaders()

Specifies the content for the Access-Control-Allow-Headers header.

repeated string allow_headers = 45179024;

Returns
Type Description
CorsPolicy.Builder

This builder for chaining.

clearAllowMethods()

public CorsPolicy.Builder clearAllowMethods()

Specifies the content for the Access-Control-Allow-Methods header.

repeated string allow_methods = 205405372;

Returns
Type Description
CorsPolicy.Builder

This builder for chaining.

clearAllowOriginRegexes()

public CorsPolicy.Builder clearAllowOriginRegexes()

Specifies a regular expression that matches allowed origins. For more information, see regular expression syntax . An origin is allowed if it matches either an item in allowOrigins or an item in allowOriginRegexes. Regular expressions can only be used when the loadBalancingScheme is set to INTERNAL_SELF_MANAGED.

repeated string allow_origin_regexes = 215385810;

Returns
Type Description
CorsPolicy.Builder

This builder for chaining.

clearAllowOrigins()

public CorsPolicy.Builder clearAllowOrigins()

Specifies the list of origins that is allowed to do CORS requests. An origin is allowed if it matches either an item in allowOrigins or an item in allowOriginRegexes.

repeated string allow_origins = 194914071;

Returns
Type Description
CorsPolicy.Builder

This builder for chaining.

clearDisabled()

public CorsPolicy.Builder clearDisabled()

If true, disables the CORS policy. The default value is false, which indicates that the CORS policy is in effect.

optional bool disabled = 270940796;

Returns
Type Description
CorsPolicy.Builder

This builder for chaining.

clearExposeHeaders()

public CorsPolicy.Builder clearExposeHeaders()

Specifies the content for the Access-Control-Expose-Headers header.

repeated string expose_headers = 247604747;

Returns
Type Description
CorsPolicy.Builder

This builder for chaining.

clearField(Descriptors.FieldDescriptor field)

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

clearMaxAge()

public CorsPolicy.Builder clearMaxAge()

Specifies how long results of a preflight request can be cached in seconds. This field translates to the Access-Control-Max-Age header.

optional int32 max_age = 307559332;

Returns
Type Description
CorsPolicy.Builder

This builder for chaining.

clearOneof(Descriptors.OneofDescriptor oneof)

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

clone()

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

getAllowCredentials()

public boolean getAllowCredentials()

In response to a preflight request, setting this to true indicates that the actual request can include user credentials. This field translates to the Access-Control-Allow-Credentials header. Default is false.

optional bool allow_credentials = 481263366;

Returns
Type Description
boolean

The allowCredentials.

getAllowHeaders(int index)

public String getAllowHeaders(int index)

Specifies the content for the Access-Control-Allow-Headers header.

repeated string allow_headers = 45179024;

Parameter
Name Description
index int

The index of the element to return.

Returns
Type Description
String

The allowHeaders at the given index.

getAllowHeadersBytes(int index)

public ByteString getAllowHeadersBytes(int index)

Specifies the content for the Access-Control-Allow-Headers header.

repeated string allow_headers = 45179024;

Parameter
Name Description
index int

The index of the value to return.

Returns
Type Description
ByteString

The bytes of the allowHeaders at the given index.

getAllowHeadersCount()

public int getAllowHeadersCount()

Specifies the content for the Access-Control-Allow-Headers header.

repeated string allow_headers = 45179024;

Returns
Type Description
int

The count of allowHeaders.

getAllowHeadersList()

public ProtocolStringList getAllowHeadersList()

Specifies the content for the Access-Control-Allow-Headers header.

repeated string allow_headers = 45179024;

Returns
Type Description
ProtocolStringList

A list containing the allowHeaders.

getAllowMethods(int index)

public String getAllowMethods(int index)

Specifies the content for the Access-Control-Allow-Methods header.

repeated string allow_methods = 205405372;

Parameter
Name Description
index int

The index of the element to return.

Returns
Type Description
String

The allowMethods at the given index.

getAllowMethodsBytes(int index)

public ByteString getAllowMethodsBytes(int index)

Specifies the content for the Access-Control-Allow-Methods header.

repeated string allow_methods = 205405372;

Parameter
Name Description
index int

The index of the value to return.

Returns
Type Description
ByteString

The bytes of the allowMethods at the given index.

getAllowMethodsCount()

public int getAllowMethodsCount()

Specifies the content for the Access-Control-Allow-Methods header.

repeated string allow_methods = 205405372;

Returns
Type Description
int

The count of allowMethods.

getAllowMethodsList()

public ProtocolStringList getAllowMethodsList()

Specifies the content for the Access-Control-Allow-Methods header.

repeated string allow_methods = 205405372;

Returns
Type Description
ProtocolStringList

A list containing the allowMethods.

getAllowOriginRegexes(int index)

public String getAllowOriginRegexes(int index)

Specifies a regular expression that matches allowed origins. For more information, see regular expression syntax . An origin is allowed if it matches either an item in allowOrigins or an item in allowOriginRegexes. Regular expressions can only be used when the loadBalancingScheme is set to INTERNAL_SELF_MANAGED.

repeated string allow_origin_regexes = 215385810;

Parameter
Name Description
index int

The index of the element to return.

Returns
Type Description
String

The allowOriginRegexes at the given index.

getAllowOriginRegexesBytes(int index)

public ByteString getAllowOriginRegexesBytes(int index)

Specifies a regular expression that matches allowed origins. For more information, see regular expression syntax . An origin is allowed if it matches either an item in allowOrigins or an item in allowOriginRegexes. Regular expressions can only be used when the loadBalancingScheme is set to INTERNAL_SELF_MANAGED.

repeated string allow_origin_regexes = 215385810;

Parameter
Name Description
index int

The index of the value to return.

Returns
Type Description
ByteString

The bytes of the allowOriginRegexes at the given index.

getAllowOriginRegexesCount()

public int getAllowOriginRegexesCount()

Specifies a regular expression that matches allowed origins. For more information, see regular expression syntax . An origin is allowed if it matches either an item in allowOrigins or an item in allowOriginRegexes. Regular expressions can only be used when the loadBalancingScheme is set to INTERNAL_SELF_MANAGED.

repeated string allow_origin_regexes = 215385810;

Returns
Type Description
int

The count of allowOriginRegexes.

getAllowOriginRegexesList()

public ProtocolStringList getAllowOriginRegexesList()

Specifies a regular expression that matches allowed origins. For more information, see regular expression syntax . An origin is allowed if it matches either an item in allowOrigins or an item in allowOriginRegexes. Regular expressions can only be used when the loadBalancingScheme is set to INTERNAL_SELF_MANAGED.

repeated string allow_origin_regexes = 215385810;

Returns
Type Description
ProtocolStringList

A list containing the allowOriginRegexes.

getAllowOrigins(int index)

public String getAllowOrigins(int index)

Specifies the list of origins that is allowed to do CORS requests. An origin is allowed if it matches either an item in allowOrigins or an item in allowOriginRegexes.

repeated string allow_origins = 194914071;

Parameter
Name Description
index int

The index of the element to return.

Returns
Type Description
String

The allowOrigins at the given index.

getAllowOriginsBytes(int index)

public ByteString getAllowOriginsBytes(int index)

Specifies the list of origins that is allowed to do CORS requests. An origin is allowed if it matches either an item in allowOrigins or an item in allowOriginRegexes.

repeated string allow_origins = 194914071;

Parameter
Name Description
index int

The index of the value to return.

Returns
Type Description
ByteString

The bytes of the allowOrigins at the given index.

getAllowOriginsCount()

public int getAllowOriginsCount()

Specifies the list of origins that is allowed to do CORS requests. An origin is allowed if it matches either an item in allowOrigins or an item in allowOriginRegexes.

repeated string allow_origins = 194914071;

Returns
Type Description
int

The count of allowOrigins.

getAllowOriginsList()

public ProtocolStringList getAllowOriginsList()

Specifies the list of origins that is allowed to do CORS requests. An origin is allowed if it matches either an item in allowOrigins or an item in allowOriginRegexes.

repeated string allow_origins = 194914071;

Returns
Type Description
ProtocolStringList

A list containing the allowOrigins.

getDefaultInstanceForType()

public CorsPolicy getDefaultInstanceForType()
Returns
Type Description
CorsPolicy

getDescriptorForType()

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

getDisabled()

public boolean getDisabled()

If true, disables the CORS policy. The default value is false, which indicates that the CORS policy is in effect.

optional bool disabled = 270940796;

Returns
Type Description
boolean

The disabled.

getExposeHeaders(int index)

public String getExposeHeaders(int index)

Specifies the content for the Access-Control-Expose-Headers header.

repeated string expose_headers = 247604747;

Parameter
Name Description
index int

The index of the element to return.

Returns
Type Description
String

The exposeHeaders at the given index.

getExposeHeadersBytes(int index)

public ByteString getExposeHeadersBytes(int index)

Specifies the content for the Access-Control-Expose-Headers header.

repeated string expose_headers = 247604747;

Parameter
Name Description
index int

The index of the value to return.

Returns
Type Description
ByteString

The bytes of the exposeHeaders at the given index.

getExposeHeadersCount()

public int getExposeHeadersCount()

Specifies the content for the Access-Control-Expose-Headers header.

repeated string expose_headers = 247604747;

Returns
Type Description
int

The count of exposeHeaders.

getExposeHeadersList()

public ProtocolStringList getExposeHeadersList()

Specifies the content for the Access-Control-Expose-Headers header.

repeated string expose_headers = 247604747;

Returns
Type Description
ProtocolStringList

A list containing the exposeHeaders.

getMaxAge()

public int getMaxAge()

Specifies how long results of a preflight request can be cached in seconds. This field translates to the Access-Control-Max-Age header.

optional int32 max_age = 307559332;

Returns
Type Description
int

The maxAge.

hasAllowCredentials()

public boolean hasAllowCredentials()

In response to a preflight request, setting this to true indicates that the actual request can include user credentials. This field translates to the Access-Control-Allow-Credentials header. Default is false.

optional bool allow_credentials = 481263366;

Returns
Type Description
boolean

Whether the allowCredentials field is set.

hasDisabled()

public boolean hasDisabled()

If true, disables the CORS policy. The default value is false, which indicates that the CORS policy is in effect.

optional bool disabled = 270940796;

Returns
Type Description
boolean

Whether the disabled field is set.

hasMaxAge()

public boolean hasMaxAge()

Specifies how long results of a preflight request can be cached in seconds. This field translates to the Access-Control-Max-Age header.

optional int32 max_age = 307559332;

Returns
Type Description
boolean

Whether the maxAge field is set.

internalGetFieldAccessorTable()

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

isInitialized()

public final boolean isInitialized()
Returns
Type Description
boolean
Overrides

mergeFrom(CorsPolicy other)

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

mergeFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)

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

mergeFrom(Message other)

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

mergeUnknownFields(UnknownFieldSet unknownFields)

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

setAllowCredentials(boolean value)

public CorsPolicy.Builder setAllowCredentials(boolean value)

In response to a preflight request, setting this to true indicates that the actual request can include user credentials. This field translates to the Access-Control-Allow-Credentials header. Default is false.

optional bool allow_credentials = 481263366;

Parameter
Name Description
value boolean

The allowCredentials to set.

Returns
Type Description
CorsPolicy.Builder

This builder for chaining.

setAllowHeaders(int index, String value)

public CorsPolicy.Builder setAllowHeaders(int index, String value)

Specifies the content for the Access-Control-Allow-Headers header.

repeated string allow_headers = 45179024;

Parameters
Name Description
index int

The index to set the value at.

value String

The allowHeaders to set.

Returns
Type Description
CorsPolicy.Builder

This builder for chaining.

setAllowMethods(int index, String value)

public CorsPolicy.Builder setAllowMethods(int index, String value)

Specifies the content for the Access-Control-Allow-Methods header.

repeated string allow_methods = 205405372;

Parameters
Name Description
index int

The index to set the value at.

value String

The allowMethods to set.

Returns
Type Description
CorsPolicy.Builder

This builder for chaining.

setAllowOriginRegexes(int index, String value)

public CorsPolicy.Builder setAllowOriginRegexes(int index, String value)

Specifies a regular expression that matches allowed origins. For more information, see regular expression syntax . An origin is allowed if it matches either an item in allowOrigins or an item in allowOriginRegexes. Regular expressions can only be used when the loadBalancingScheme is set to INTERNAL_SELF_MANAGED.

repeated string allow_origin_regexes = 215385810;

Parameters
Name Description
index int

The index to set the value at.

value String

The allowOriginRegexes to set.

Returns
Type Description
CorsPolicy.Builder

This builder for chaining.

setAllowOrigins(int index, String value)

public CorsPolicy.Builder setAllowOrigins(int index, String value)

Specifies the list of origins that is allowed to do CORS requests. An origin is allowed if it matches either an item in allowOrigins or an item in allowOriginRegexes.

repeated string allow_origins = 194914071;

Parameters
Name Description
index int

The index to set the value at.

value String

The allowOrigins to set.

Returns
Type Description
CorsPolicy.Builder

This builder for chaining.

setDisabled(boolean value)

public CorsPolicy.Builder setDisabled(boolean value)

If true, disables the CORS policy. The default value is false, which indicates that the CORS policy is in effect.

optional bool disabled = 270940796;

Parameter
Name Description
value boolean

The disabled to set.

Returns
Type Description
CorsPolicy.Builder

This builder for chaining.

setExposeHeaders(int index, String value)

public CorsPolicy.Builder setExposeHeaders(int index, String value)

Specifies the content for the Access-Control-Expose-Headers header.

repeated string expose_headers = 247604747;

Parameters
Name Description
index int

The index to set the value at.

value String

The exposeHeaders to set.

Returns
Type Description
CorsPolicy.Builder

This builder for chaining.

setField(Descriptors.FieldDescriptor field, Object value)

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

setMaxAge(int value)

public CorsPolicy.Builder setMaxAge(int value)

Specifies how long results of a preflight request can be cached in seconds. This field translates to the Access-Control-Max-Age header.

optional int32 max_age = 307559332;

Parameter
Name Description
value int

The maxAge to set.

Returns
Type Description
CorsPolicy.Builder

This builder for chaining.

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

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

setUnknownFields(UnknownFieldSet unknownFields)

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