Defines the service account for Batch-created VMs. If omitted, thedefault Compute Engine service accountis used. Must match the service account specified in any used instance template configured in the Batch job. Includes the following fields: * * email: The service account's email address. If not set, the default Compute Engine service account is used. * * scopes: Additional OAuth scopes to grant the service account, beyond the default cloud-platform scope. (list of strings)
Custom labels to apply to the job and all the Compute Engine resources that both are created by this allocation policy and support labels. Use labels to group and describe the resources they are applied to. Batch automatically applies predefined labels and supports multiplelabelsfields for each job, which each let you apply custom labels to various resources. Label names that start with "goog-" or "google-" are reserved for predefined labels. For more information about labels with Batch, seeOrganize resources using labels.
The network policy. If you define an instance template in theInstancePolicyOrTemplatefield, Batch will use the network settings in the instance template instead of this field.
Optional. Tags applied to the VM instances. The tags identify valid sources or targets for network firewalls. Each tag must be 1-63 characters long, and comply withRFC1035.
getLocation
Location where compute resources should be allocated for the Job.
Defines the service account for Batch-created VMs. If omitted, thedefault
Compute Engine service
accountis used. Must match the service account specified in any used instance
template configured in the Batch job.
Includes the following fields:
email: The service account's email address. If not set, the default
Compute Engine service account is used.
scopes: Additional OAuth scopes to grant the service account, beyond the
default cloud-platform scope. (list of strings)
Defines the service account for Batch-created VMs. If omitted, thedefault
Compute Engine service
accountis used. Must match the service account specified in any used instance
template configured in the Batch job.
Includes the following fields:
email: The service account's email address. If not set, the default
Compute Engine service account is used.
scopes: Additional OAuth scopes to grant the service account, beyond the
default cloud-platform scope. (list of strings)
Custom labels to apply to the job and all the Compute Engine resources
that both are created by this allocation policy and support labels.
Use labels to group and describe the resources they are applied to. Batch
automatically applies predefined labels and supports multiplelabelsfields for each job, which each let you apply custom labels to various
resources. Label names that start with "goog-" or "google-" are
reserved for predefined labels. For more information about labels with
Batch, seeOrganize resources using
labels.
Custom labels to apply to the job and all the Compute Engine resources
that both are created by this allocation policy and support labels.
Use labels to group and describe the resources they are applied to. Batch
automatically applies predefined labels and supports multiplelabelsfields for each job, which each let you apply custom labels to various
resources. Label names that start with "goog-" or "google-" are
reserved for predefined labels. For more information about labels with
Batch, seeOrganize resources using
labels.
If you define an instance template in theInstancePolicyOrTemplatefield,
Batch will use the network settings in the instance template instead of
this field.
If you define an instance template in theInstancePolicyOrTemplatefield,
Batch will use the network settings in the instance template instead of
this field.
[[["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-04 UTC."],[],[],null,["# Google Cloud Batch V1 Client - Class AllocationPolicy (1.2.2)\n\nVersion latestkeyboard_arrow_down\n\n- [1.2.2 (latest)](/php/docs/reference/cloud-batch/latest/V1.AllocationPolicy)\n- [1.2.1](/php/docs/reference/cloud-batch/1.2.1/V1.AllocationPolicy)\n- [1.1.7](/php/docs/reference/cloud-batch/1.1.7/V1.AllocationPolicy)\n- [1.0.3](/php/docs/reference/cloud-batch/1.0.3/V1.AllocationPolicy)\n- [0.17.0](/php/docs/reference/cloud-batch/0.17.0/V1.AllocationPolicy)\n- [0.16.10](/php/docs/reference/cloud-batch/0.16.10/V1.AllocationPolicy)\n- [0.15.0](/php/docs/reference/cloud-batch/0.15.0/V1.AllocationPolicy)\n- [0.14.0](/php/docs/reference/cloud-batch/0.14.0/V1.AllocationPolicy)\n- [0.13.1](/php/docs/reference/cloud-batch/0.13.1/V1.AllocationPolicy)\n- [0.12.1](/php/docs/reference/cloud-batch/0.12.1/V1.AllocationPolicy)\n- [0.11.3](/php/docs/reference/cloud-batch/0.11.3/V1.AllocationPolicy)\n- [0.10.0](/php/docs/reference/cloud-batch/0.10.0/V1.AllocationPolicy)\n- [0.9.0](/php/docs/reference/cloud-batch/0.9.0/V1.AllocationPolicy)\n- [0.8.0](/php/docs/reference/cloud-batch/0.8.0/V1.AllocationPolicy)\n- [0.7.0](/php/docs/reference/cloud-batch/0.7.0/V1.AllocationPolicy)\n- [0.6.0](/php/docs/reference/cloud-batch/0.6.0/V1.AllocationPolicy)\n- [0.5.2](/php/docs/reference/cloud-batch/0.5.2/V1.AllocationPolicy)\n- [0.4.0](/php/docs/reference/cloud-batch/0.4.0/V1.AllocationPolicy)\n- [0.3.0](/php/docs/reference/cloud-batch/0.3.0/V1.AllocationPolicy)\n- [0.2.2](/php/docs/reference/cloud-batch/0.2.2/V1.AllocationPolicy) \nReference documentation and code samples for the Google Cloud Batch V1 Client class AllocationPolicy.\n\nA Job's resource allocation policy describes when, where, and how compute\nresources should be allocated for the Job.\n\nGenerated from protobuf message `google.cloud.batch.v1.AllocationPolicy`\n\nNamespace\n---------\n\nGoogle \\\\ Cloud \\\\ Batch \\\\ V1\n\nMethods\n-------\n\n### __construct\n\nConstructor.\n\n### getLocation\n\nLocation where compute resources should be allocated for the Job.\n\n### hasLocation\n\n### clearLocation\n\n### setLocation\n\nLocation where compute resources should be allocated for the Job.\n\n### getInstances\n\nDescribe instances that can be created by this AllocationPolicy.\n\nOnly instances\\[0\\] is supported now.\n\n### setInstances\n\nDescribe instances that can be created by this AllocationPolicy.\n\nOnly instances\\[0\\] is supported now.\n\n### getServiceAccount\n\nDefines the service account for Batch-created VMs. If omitted, the [default\nCompute Engine service\naccount](https://cloud.google.com/compute/docs/access/service-accounts#default_service_account)\nis used. Must match the service account specified in any used instance\ntemplate configured in the Batch job.\n\nIncludes the following fields:\n\n- email: The service account's email address. If not set, the default Compute Engine service account is used.\n- scopes: Additional OAuth scopes to grant the service account, beyond the default cloud-platform scope. (list of strings)\n\n### hasServiceAccount\n\n### clearServiceAccount\n\n### setServiceAccount\n\nDefines the service account for Batch-created VMs. If omitted, the [default\nCompute Engine service\naccount](https://cloud.google.com/compute/docs/access/service-accounts#default_service_account)\nis used. Must match the service account specified in any used instance\ntemplate configured in the Batch job.\n\nIncludes the following fields:\n\n- email: The service account's email address. If not set, the default Compute Engine service account is used.\n- scopes: Additional OAuth scopes to grant the service account, beyond the default cloud-platform scope. (list of strings)\n\n### getLabels\n\nCustom labels to apply to the job and all the Compute Engine resources\nthat both are created by this allocation policy and support labels.\n\nUse labels to group and describe the resources they are applied to. Batch\nautomatically applies predefined labels and supports multiple `labels`\nfields for each job, which each let you apply custom labels to various\nresources. Label names that start with \"goog-\" or \"google-\" are\nreserved for predefined labels. For more information about labels with\nBatch, see\n[Organize resources using\nlabels](https://cloud.google.com/batch/docs/organize-resources-using-labels).\n\n### setLabels\n\nCustom labels to apply to the job and all the Compute Engine resources\nthat both are created by this allocation policy and support labels.\n\nUse labels to group and describe the resources they are applied to. Batch\nautomatically applies predefined labels and supports multiple `labels`\nfields for each job, which each let you apply custom labels to various\nresources. Label names that start with \"goog-\" or \"google-\" are\nreserved for predefined labels. For more information about labels with\nBatch, see\n[Organize resources using\nlabels](https://cloud.google.com/batch/docs/organize-resources-using-labels).\n\n### getNetwork\n\nThe network policy.\n\nIf you define an instance template in the `InstancePolicyOrTemplate` field,\nBatch will use the network settings in the instance template instead of\nthis field.\n\n### hasNetwork\n\n### clearNetwork\n\n### setNetwork\n\nThe network policy.\n\nIf you define an instance template in the `InstancePolicyOrTemplate` field,\nBatch will use the network settings in the instance template instead of\nthis field.\n\n### getPlacement\n\nThe placement policy.\n\n### hasPlacement\n\n### clearPlacement\n\n### setPlacement\n\nThe placement policy.\n\n### getTags\n\nOptional. Tags applied to the VM instances.\n\nThe tags identify valid sources or targets for network firewalls.\nEach tag must be 1-63 characters long, and comply with\n[RFC1035](https://www.ietf.org/rfc/rfc1035.txt).\n\n### setTags\n\nOptional. Tags applied to the VM instances.\n\nThe tags identify valid sources or targets for network firewalls.\nEach tag must be 1-63 characters long, and comply with\n[RFC1035](https://www.ietf.org/rfc/rfc1035.txt)."]]