Reference documentation and code samples for the Google Ads Ad Manager V1 Client class CustomFieldServiceClient.
Service Description: Provides methods for handling CustomField
objects.
This class provides the ability to make remote calls to the backing service through method calls that map to API methods.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parseName method to extract the individual identifiers contained within formatted names that are returned by the API.
Namespace
Google \ Ads \ AdManager \ V1 \ ClientMethods
__construct
Constructor.
options
array| Google\ApiCore\Options\ClientOptions
Optional. Options for configuring the service API wrapper.
↳ apiEndpoint
string
The address of the API remote host. May optionally include the port, formatted as "
↳ credentials
FetchAuthTokenInterface|CredentialsWrapper
This option should only be used with a pre-constructed Google\Auth\FetchAuthTokenInterface
or Google\ApiCore\CredentialsWrapper
object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored. Important: If you are providing a path to a credentials file, or a decoded credentials file as a PHP array, this usage is now DEPRECATED. Providing an unvalidated credential configuration to Google APIs can compromise the security of your systems and data. It is recommended to create the credentials explicitly use Google\Auth\Credentials\ServiceAccountCredentials; use Google\Ads\AdManager\V1\CustomFieldServiceClient; $creds = new ServiceAccountCredentials($scopes, $json); $options = new CustomFieldServiceClient(['credentials' => $creds]);
https://cloud.google.com/docs/authentication/external/externally-sourced-credentials
↳ credentialsConfig
array
Options used to configure credentials, including auth token caching, for the client. For a full list of supporting configuration options, see Google\ApiCore\CredentialsWrapper::build() .
↳ disableRetries
bool
Determines whether or not retries defined by the client configuration should be disabled. Defaults to false
.
↳ clientConfig
string|array
Client method configuration, including retry settings. This option can be either a path to a JSON file, or a PHP array containing the decoded JSON data. By default this settings points to the default client config file, which is provided in the resources folder.
↳ transport
string|TransportInterface
The transport used for executing network requests. At the moment, supports only rest
. Advanced usage
: Additionally, it is possible to pass in an already instantiated Google\ApiCore\Transport\TransportInterface
object. Note that when this object is provided, any settings in $transportConfig, and any $apiEndpoint setting, will be ignored.
↳ transportConfig
array
Configuration options that will be used to construct the transport. Options for each supported transport type should be passed in a key for that transport. For example: $transportConfig = [ 'rest' => [...], ]; See the Google\ApiCore\Transport\RestTransport::build() method for the supported options.
↳ clientCertSource
callable
A callable which returns the client cert as a string. This can be used to provide a certificate and private key to the transport layer for mTLS.
↳ logger
false|LoggerInterface
A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the 'GOOGLE_SDK_PHP_LOGGING' environment flag
↳ universeDomain
string
The service domain for the client. Defaults to 'googleapis.com'.
batchActivateCustomFields
Activates a list of CustomField
objects.
The async variant is CustomFieldServiceClient::batchActivateCustomFieldsAsync() .
request
Google\Ads\AdManager\V1\BatchActivateCustomFieldsRequest
A request to house fields associated with the call.
callOptions
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\Ads\AdManager\V1\BatchActivateCustomFieldsRequest;
use Google\Ads\AdManager\V1\BatchActivateCustomFieldsResponse;
use Google\Ads\AdManager\V1\Client\CustomFieldServiceClient;
use Google\ApiCore\ApiException;
/**
* @param string $formattedParent Format: `networks/{network_code}`
* Please see {@see CustomFieldServiceClient::networkName()} for help formatting this field.
* @param string $formattedNamesElement The resource names of the `CustomField` objects to activate.
* Format: `networks/{network_code}/customFields/{custom_field_id}`
* Please see {@see CustomFieldServiceClient::customFieldName()} for help formatting this field.
*/
function batch_activate_custom_fields_sample(
string $formattedParent,
string $formattedNamesElement
): void {
// Create a client.
$customFieldServiceClient = new CustomFieldServiceClient();
// Prepare the request message.
$formattedNames = [$formattedNamesElement,];
$request = (new BatchActivateCustomFieldsRequest())
->setParent($formattedParent)
->setNames($formattedNames);
// Call the API and handle any network failures.
try {
/** @var BatchActivateCustomFieldsResponse $response */
$response = $customFieldServiceClient->batchActivateCustomFields($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedParent = CustomFieldServiceClient::networkName('[NETWORK_CODE]');
$formattedNamesElement = CustomFieldServiceClient::customFieldName(
'[NETWORK_CODE]',
'[CUSTOM_FIELD]'
);
batch_activate_custom_fields_sample($formattedParent, $formattedNamesElement);
}
batchCreateCustomFields
API to batch create CustomField
objects.
The async variant is CustomFieldServiceClient::batchCreateCustomFieldsAsync() .
request
Google\Ads\AdManager\V1\BatchCreateCustomFieldsRequest
A request to house fields associated with the call.
callOptions
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\Ads\AdManager\V1\BatchCreateCustomFieldsRequest;
use Google\Ads\AdManager\V1\BatchCreateCustomFieldsResponse;
use Google\Ads\AdManager\V1\Client\CustomFieldServiceClient;
use Google\Ads\AdManager\V1\CreateCustomFieldRequest;
use Google\Ads\AdManager\V1\CustomField;
use Google\Ads\AdManager\V1\CustomFieldDataTypeEnum\CustomFieldDataType;
use Google\Ads\AdManager\V1\CustomFieldEntityTypeEnum\CustomFieldEntityType;
use Google\Ads\AdManager\V1\CustomFieldVisibilityEnum\CustomFieldVisibility;
use Google\ApiCore\ApiException;
/**
* @param string $formattedParent The parent resource where `CustomFields` will be created.
* Format: `networks/{network_code}`
* The parent field in the CreateCustomFieldRequest must match this
* field. Please see
* {@see CustomFieldServiceClient::networkName()} for help formatting this field.
* @param string $formattedRequestsParent The parent resource where this `CustomField` will be created.
* Format: `networks/{network_code}`
* Please see {@see CustomFieldServiceClient::networkName()} for help formatting this field.
* @param string $requestsCustomFieldDisplayName Name of the CustomField. The max length is 127 characters.
* @param int $requestsCustomFieldEntityType The type of entity the `CustomField` can be applied to.
* @param int $requestsCustomFieldDataType The data type of the `CustomField`.
* @param int $requestsCustomFieldVisibility The visibility of the `CustomField`.
*/
function batch_create_custom_fields_sample(
string $formattedParent,
string $formattedRequestsParent,
string $requestsCustomFieldDisplayName,
int $requestsCustomFieldEntityType,
int $requestsCustomFieldDataType,
int $requestsCustomFieldVisibility
): void {
// Create a client.
$customFieldServiceClient = new CustomFieldServiceClient();
// Prepare the request message.
$requestsCustomField = (new CustomField())
->setDisplayName($requestsCustomFieldDisplayName)
->setEntityType($requestsCustomFieldEntityType)
->setDataType($requestsCustomFieldDataType)
->setVisibility($requestsCustomFieldVisibility);
$createCustomFieldRequest = (new CreateCustomFieldRequest())
->setParent($formattedRequestsParent)
->setCustomField($requestsCustomField);
$requests = [$createCustomFieldRequest,];
$request = (new BatchCreateCustomFieldsRequest())
->setParent($formattedParent)
->setRequests($requests);
// Call the API and handle any network failures.
try {
/** @var BatchCreateCustomFieldsResponse $response */
$response = $customFieldServiceClient->batchCreateCustomFields($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedParent = CustomFieldServiceClient::networkName('[NETWORK_CODE]');
$formattedRequestsParent = CustomFieldServiceClient::networkName('[NETWORK_CODE]');
$requestsCustomFieldDisplayName = '[DISPLAY_NAME]';
$requestsCustomFieldEntityType = CustomFieldEntityType::CUSTOM_FIELD_ENTITY_TYPE_UNSPECIFIED;
$requestsCustomFieldDataType = CustomFieldDataType::CUSTOM_FIELD_DATA_TYPE_UNSPECIFIED;
$requestsCustomFieldVisibility = CustomFieldVisibility::CUSTOM_FIELD_VISIBILITY_UNSPECIFIED;
batch_create_custom_fields_sample(
$formattedParent,
$formattedRequestsParent,
$requestsCustomFieldDisplayName,
$requestsCustomFieldEntityType,
$requestsCustomFieldDataType,
$requestsCustomFieldVisibility
);
}
batchDeactivateCustomFields
Deactivates a list of CustomField
objects.
The async variant is CustomFieldServiceClient::batchDeactivateCustomFieldsAsync() .
request
Google\Ads\AdManager\V1\BatchDeactivateCustomFieldsRequest
A request to house fields associated with the call.
callOptions
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\Ads\AdManager\V1\BatchDeactivateCustomFieldsRequest;
use Google\Ads\AdManager\V1\BatchDeactivateCustomFieldsResponse;
use Google\Ads\AdManager\V1\Client\CustomFieldServiceClient;
use Google\ApiCore\ApiException;
/**
* @param string $formattedParent Format: `networks/{network_code}`
* Please see {@see CustomFieldServiceClient::networkName()} for help formatting this field.
* @param string $formattedNamesElement The resource names of the `CustomField` objects to deactivate.
* Format: `networks/{network_code}/customFields/{custom_field_id}`
* Please see {@see CustomFieldServiceClient::customFieldName()} for help formatting this field.
*/
function batch_deactivate_custom_fields_sample(
string $formattedParent,
string $formattedNamesElement
): void {
// Create a client.
$customFieldServiceClient = new CustomFieldServiceClient();
// Prepare the request message.
$formattedNames = [$formattedNamesElement,];
$request = (new BatchDeactivateCustomFieldsRequest())
->setParent($formattedParent)
->setNames($formattedNames);
// Call the API and handle any network failures.
try {
/** @var BatchDeactivateCustomFieldsResponse $response */
$response = $customFieldServiceClient->batchDeactivateCustomFields($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedParent = CustomFieldServiceClient::networkName('[NETWORK_CODE]');
$formattedNamesElement = CustomFieldServiceClient::customFieldName(
'[NETWORK_CODE]',
'[CUSTOM_FIELD]'
);
batch_deactivate_custom_fields_sample($formattedParent, $formattedNamesElement);
}
batchUpdateCustomFields
API to batch update CustomField
objects.
The async variant is CustomFieldServiceClient::batchUpdateCustomFieldsAsync() .
request
Google\Ads\AdManager\V1\BatchUpdateCustomFieldsRequest
A request to house fields associated with the call.
callOptions
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\Ads\AdManager\V1\BatchUpdateCustomFieldsRequest;
use Google\Ads\AdManager\V1\BatchUpdateCustomFieldsResponse;
use Google\Ads\AdManager\V1\Client\CustomFieldServiceClient;
use Google\Ads\AdManager\V1\CustomField;
use Google\Ads\AdManager\V1\CustomFieldDataTypeEnum\CustomFieldDataType;
use Google\Ads\AdManager\V1\CustomFieldEntityTypeEnum\CustomFieldEntityType;
use Google\Ads\AdManager\V1\CustomFieldVisibilityEnum\CustomFieldVisibility;
use Google\Ads\AdManager\V1\UpdateCustomFieldRequest;
use Google\ApiCore\ApiException;
use Google\Protobuf\FieldMask;
/**
* @param string $formattedParent The parent resource where `CustomFields` will be updated.
* Format: `networks/{network_code}`
* The parent field in the UpdateCustomFieldRequest must match this
* field. Please see
* {@see CustomFieldServiceClient::networkName()} for help formatting this field.
* @param string $requestsCustomFieldDisplayName Name of the CustomField. The max length is 127 characters.
* @param int $requestsCustomFieldEntityType The type of entity the `CustomField` can be applied to.
* @param int $requestsCustomFieldDataType The data type of the `CustomField`.
* @param int $requestsCustomFieldVisibility The visibility of the `CustomField`.
*/
function batch_update_custom_fields_sample(
string $formattedParent,
string $requestsCustomFieldDisplayName,
int $requestsCustomFieldEntityType,
int $requestsCustomFieldDataType,
int $requestsCustomFieldVisibility
): void {
// Create a client.
$customFieldServiceClient = new CustomFieldServiceClient();
// Prepare the request message.
$requestsCustomField = (new CustomField())
->setDisplayName($requestsCustomFieldDisplayName)
->setEntityType($requestsCustomFieldEntityType)
->setDataType($requestsCustomFieldDataType)
->setVisibility($requestsCustomFieldVisibility);
$requestsUpdateMask = new FieldMask();
$updateCustomFieldRequest = (new UpdateCustomFieldRequest())
->setCustomField($requestsCustomField)
->setUpdateMask($requestsUpdateMask);
$requests = [$updateCustomFieldRequest,];
$request = (new BatchUpdateCustomFieldsRequest())
->setParent($formattedParent)
->setRequests($requests);
// Call the API and handle any network failures.
try {
/** @var BatchUpdateCustomFieldsResponse $response */
$response = $customFieldServiceClient->batchUpdateCustomFields($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedParent = CustomFieldServiceClient::networkName('[NETWORK_CODE]');
$requestsCustomFieldDisplayName = '[DISPLAY_NAME]';
$requestsCustomFieldEntityType = CustomFieldEntityType::CUSTOM_FIELD_ENTITY_TYPE_UNSPECIFIED;
$requestsCustomFieldDataType = CustomFieldDataType::CUSTOM_FIELD_DATA_TYPE_UNSPECIFIED;
$requestsCustomFieldVisibility = CustomFieldVisibility::CUSTOM_FIELD_VISIBILITY_UNSPECIFIED;
batch_update_custom_fields_sample(
$formattedParent,
$requestsCustomFieldDisplayName,
$requestsCustomFieldEntityType,
$requestsCustomFieldDataType,
$requestsCustomFieldVisibility
);
}
createCustomField
API to create a CustomField
object.
The async variant is CustomFieldServiceClient::createCustomFieldAsync() .
request
Google\Ads\AdManager\V1\CreateCustomFieldRequest
A request to house fields associated with the call.
callOptions
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\Ads\AdManager\V1\Client\CustomFieldServiceClient;
use Google\Ads\AdManager\V1\CreateCustomFieldRequest;
use Google\Ads\AdManager\V1\CustomField;
use Google\Ads\AdManager\V1\CustomFieldDataTypeEnum\CustomFieldDataType;
use Google\Ads\AdManager\V1\CustomFieldEntityTypeEnum\CustomFieldEntityType;
use Google\Ads\AdManager\V1\CustomFieldVisibilityEnum\CustomFieldVisibility;
use Google\ApiCore\ApiException;
/**
* @param string $formattedParent The parent resource where this `CustomField` will be created.
* Format: `networks/{network_code}`
* Please see {@see CustomFieldServiceClient::networkName()} for help formatting this field.
* @param string $customFieldDisplayName Name of the CustomField. The max length is 127 characters.
* @param int $customFieldEntityType The type of entity the `CustomField` can be applied to.
* @param int $customFieldDataType The data type of the `CustomField`.
* @param int $customFieldVisibility The visibility of the `CustomField`.
*/
function create_custom_field_sample(
string $formattedParent,
string $customFieldDisplayName,
int $customFieldEntityType,
int $customFieldDataType,
int $customFieldVisibility
): void {
// Create a client.
$customFieldServiceClient = new CustomFieldServiceClient();
// Prepare the request message.
$customField = (new CustomField())
->setDisplayName($customFieldDisplayName)
->setEntityType($customFieldEntityType)
->setDataType($customFieldDataType)
->setVisibility($customFieldVisibility);
$request = (new CreateCustomFieldRequest())
->setParent($formattedParent)
->setCustomField($customField);
// Call the API and handle any network failures.
try {
/** @var CustomField $response */
$response = $customFieldServiceClient->createCustomField($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedParent = CustomFieldServiceClient::networkName('[NETWORK_CODE]');
$customFieldDisplayName = '[DISPLAY_NAME]';
$customFieldEntityType = CustomFieldEntityType::CUSTOM_FIELD_ENTITY_TYPE_UNSPECIFIED;
$customFieldDataType = CustomFieldDataType::CUSTOM_FIELD_DATA_TYPE_UNSPECIFIED;
$customFieldVisibility = CustomFieldVisibility::CUSTOM_FIELD_VISIBILITY_UNSPECIFIED;
create_custom_field_sample(
$formattedParent,
$customFieldDisplayName,
$customFieldEntityType,
$customFieldDataType,
$customFieldVisibility
);
}
getCustomField
API to retrieve a CustomField
object.
The async variant is CustomFieldServiceClient::getCustomFieldAsync() .
request
callOptions
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\Ads\AdManager\V1\Client\CustomFieldServiceClient;
use Google\Ads\AdManager\V1\CustomField;
use Google\Ads\AdManager\V1\GetCustomFieldRequest;
use Google\ApiCore\ApiException;
/**
* @param string $formattedName The resource name of the CustomField.
* Format: `networks/{network_code}/customFields/{custom_field_id}`
* Please see {@see CustomFieldServiceClient::customFieldName()} for help formatting this field.
*/
function get_custom_field_sample(string $formattedName): void
{
// Create a client.
$customFieldServiceClient = new CustomFieldServiceClient();
// Prepare the request message.
$request = (new GetCustomFieldRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var CustomField $response */
$response = $customFieldServiceClient->getCustomField($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = CustomFieldServiceClient::customFieldName('[NETWORK_CODE]', '[CUSTOM_FIELD]');
get_custom_field_sample($formattedName);
}
listCustomFields
API to retrieve a list of CustomField
objects.
The async variant is CustomFieldServiceClient::listCustomFieldsAsync() .
request
callOptions
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\Ads\AdManager\V1\Client\CustomFieldServiceClient;
use Google\Ads\AdManager\V1\ListCustomFieldsRequest;
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
/**
* @param string $formattedParent The parent, which owns this collection of CustomFields.
* Format: `networks/{network_code}`
* Please see {@see CustomFieldServiceClient::networkName()} for help formatting this field.
*/
function list_custom_fields_sample(string $formattedParent): void
{
// Create a client.
$customFieldServiceClient = new CustomFieldServiceClient();
// Prepare the request message.
$request = (new ListCustomFieldsRequest())
->setParent($formattedParent);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $customFieldServiceClient->listCustomFields($request);
foreach ($response as $element) {
printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedParent = CustomFieldServiceClient::networkName('[NETWORK_CODE]');
list_custom_fields_sample($formattedParent);
}
updateCustomField
API to update a CustomField
object.
The async variant is CustomFieldServiceClient::updateCustomFieldAsync() .
request
Google\Ads\AdManager\V1\UpdateCustomFieldRequest
A request to house fields associated with the call.
callOptions
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\Ads\AdManager\V1\Client\CustomFieldServiceClient;
use Google\Ads\AdManager\V1\CustomField;
use Google\Ads\AdManager\V1\CustomFieldDataTypeEnum\CustomFieldDataType;
use Google\Ads\AdManager\V1\CustomFieldEntityTypeEnum\CustomFieldEntityType;
use Google\Ads\AdManager\V1\CustomFieldVisibilityEnum\CustomFieldVisibility;
use Google\Ads\AdManager\V1\UpdateCustomFieldRequest;
use Google\ApiCore\ApiException;
use Google\Protobuf\FieldMask;
/**
* @param string $customFieldDisplayName Name of the CustomField. The max length is 127 characters.
* @param int $customFieldEntityType The type of entity the `CustomField` can be applied to.
* @param int $customFieldDataType The data type of the `CustomField`.
* @param int $customFieldVisibility The visibility of the `CustomField`.
*/
function update_custom_field_sample(
string $customFieldDisplayName,
int $customFieldEntityType,
int $customFieldDataType,
int $customFieldVisibility
): void {
// Create a client.
$customFieldServiceClient = new CustomFieldServiceClient();
// Prepare the request message.
$customField = (new CustomField())
->setDisplayName($customFieldDisplayName)
->setEntityType($customFieldEntityType)
->setDataType($customFieldDataType)
->setVisibility($customFieldVisibility);
$updateMask = new FieldMask();
$request = (new UpdateCustomFieldRequest())
->setCustomField($customField)
->setUpdateMask($updateMask);
// Call the API and handle any network failures.
try {
/** @var CustomField $response */
$response = $customFieldServiceClient->updateCustomField($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$customFieldDisplayName = '[DISPLAY_NAME]';
$customFieldEntityType = CustomFieldEntityType::CUSTOM_FIELD_ENTITY_TYPE_UNSPECIFIED;
$customFieldDataType = CustomFieldDataType::CUSTOM_FIELD_DATA_TYPE_UNSPECIFIED;
$customFieldVisibility = CustomFieldVisibility::CUSTOM_FIELD_VISIBILITY_UNSPECIFIED;
update_custom_field_sample(
$customFieldDisplayName,
$customFieldEntityType,
$customFieldDataType,
$customFieldVisibility
);
}
batchActivateCustomFieldsAsync
optionalArgs
array
batchCreateCustomFieldsAsync
optionalArgs
array
batchDeactivateCustomFieldsAsync
optionalArgs
array
batchUpdateCustomFieldsAsync
optionalArgs
array
createCustomFieldAsync
optionalArgs
array
getCustomFieldAsync
optionalArgs
array
listCustomFieldsAsync
optionalArgs
array
updateCustomFieldAsync
optionalArgs
array
static::customFieldName
Formats a string containing the fully-qualified path to represent a custom_field resource.
networkCode
string
customField
string
string
static::networkName
Formats a string containing the fully-qualified path to represent a network resource.
networkCode
string
string
static::parseName
Parses a formatted name string and returns an associative array of the components in the name.
The following name formats are supported: Template: Pattern
- customField: networks/{network_code}/customFields/{custom_field}
- network: networks/{network_code}
The optional $template argument can be supplied to specify a particular pattern, and must match one of the templates listed above. If no $template argument is provided, or if the $template argument does not match one of the templates listed, then parseName will check each of the supported templates, and return the first match.
formattedName
string
The formatted name string
template
?string
Optional name of template to match
array

