Reference documentation and code samples for the Google Ads Ad Manager V1 Client class AdRuleServiceClient.
Service Description: Provides methods for handling AdRule 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.
| Parameters | |
|---|---|
| Name | Description |
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 |
Google\Auth\FetchAuthTokenInterface|Google\ApiCore\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 |
↳ 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 |
↳ 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|Google\ApiCore\Transport\TransportInterface
The transport used for executing network requests. At the moment, supports only |
↳ 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|Psr\Log\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'. |
batchActivateAdRules
Activates a list of AdRule objects.
The async variant is AdRuleServiceClient::batchActivateAdRulesAsync() .
| Parameters | |
|---|---|
| Name | Description |
request |
Google\Ads\AdManager\V1\BatchActivateAdRulesRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
Google\ApiCore\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. |
| Returns | |
|---|---|
| Type | Description |
Google\Ads\AdManager\V1\BatchActivateAdRulesResponse |
|
use Google\Ads\AdManager\V1\BatchActivateAdRulesRequest;
use Google\Ads\AdManager\V1\BatchActivateAdRulesResponse;
use Google\Ads\AdManager\V1\Client\AdRuleServiceClient;
use Google\ApiCore\ApiException;
/**
* @param string $formattedParent Format: `networks/{network_code}`
* Please see {@see AdRuleServiceClient::networkName()} for help formatting this field.
* @param string $formattedNamesElement Resource names for the AdRule.
* Format:
* `networks/{network_code}/adRules/{ad_rule}`
* Please see {@see AdRuleServiceClient::adRuleName()} for help formatting this field.
*/
function batch_activate_ad_rules_sample(
string $formattedParent,
string $formattedNamesElement
): void {
// Create a client.
$adRuleServiceClient = new AdRuleServiceClient();
// Prepare the request message.
$formattedNames = [$formattedNamesElement,];
$request = (new BatchActivateAdRulesRequest())
->setParent($formattedParent)
->setNames($formattedNames);
// Call the API and handle any network failures.
try {
/** @var BatchActivateAdRulesResponse $response */
$response = $adRuleServiceClient->batchActivateAdRules($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 = AdRuleServiceClient::networkName('[NETWORK_CODE]');
$formattedNamesElement = AdRuleServiceClient::adRuleName('[NETWORK_CODE]', '[AD_RULE]');
batch_activate_ad_rules_sample($formattedParent, $formattedNamesElement);
}
batchCreateAdRules
Batch creates AdRule objects.
The async variant is AdRuleServiceClient::batchCreateAdRulesAsync() .
| Parameters | |
|---|---|
| Name | Description |
request |
Google\Ads\AdManager\V1\BatchCreateAdRulesRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
Google\ApiCore\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. |
| Returns | |
|---|---|
| Type | Description |
Google\Ads\AdManager\V1\BatchCreateAdRulesResponse |
|
use Google\Ads\AdManager\V1\AdRule;
use Google\Ads\AdManager\V1\AdRuleSlot;
use Google\Ads\AdManager\V1\BatchCreateAdRulesRequest;
use Google\Ads\AdManager\V1\BatchCreateAdRulesResponse;
use Google\Ads\AdManager\V1\Client\AdRuleServiceClient;
use Google\Ads\AdManager\V1\CreateAdRuleRequest;
use Google\Ads\AdManager\V1\Targeting;
use Google\ApiCore\ApiException;
use Google\Protobuf\Timestamp;
/**
* @param string $formattedParent The parent resource where `AdRules` will be created.
* Format: `networks/{network_code}`
* The parent field in the CreateAdRuleRequest must match this
* field. Please see
* {@see AdRuleServiceClient::networkName()} for help formatting this field.
* @param string $formattedRequestsParent The parent resource where this `AdRule` will be created.
* Format: `networks/{network_code}`
* Please see {@see AdRuleServiceClient::networkName()} for help formatting this field.
* @param string $requestsAdRuleDisplayName The unique name of the AdRule. This attribute is required to
* create an ad rule and has a maximum length of 255 characters.
*/
function batch_create_ad_rules_sample(
string $formattedParent,
string $formattedRequestsParent,
string $requestsAdRuleDisplayName
): void {
// Create a client.
$adRuleServiceClient = new AdRuleServiceClient();
// Prepare the request message.
$requestsAdRuleStartTime = new Timestamp();
$requestsAdRulePreroll = new AdRuleSlot();
$requestsAdRuleMidrolls = [new AdRuleSlot()];
$requestsAdRulePostroll = new AdRuleSlot();
$requestsAdRuleTargeting = new Targeting();
$requestsAdRule = (new AdRule())
->setDisplayName($requestsAdRuleDisplayName)
->setStartTime($requestsAdRuleStartTime)
->setPreroll($requestsAdRulePreroll)
->setMidrolls($requestsAdRuleMidrolls)
->setPostroll($requestsAdRulePostroll)
->setTargeting($requestsAdRuleTargeting);
$createAdRuleRequest = (new CreateAdRuleRequest())
->setParent($formattedRequestsParent)
->setAdRule($requestsAdRule);
$requests = [$createAdRuleRequest,];
$request = (new BatchCreateAdRulesRequest())
->setParent($formattedParent)
->setRequests($requests);
// Call the API and handle any network failures.
try {
/** @var BatchCreateAdRulesResponse $response */
$response = $adRuleServiceClient->batchCreateAdRules($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 = AdRuleServiceClient::networkName('[NETWORK_CODE]');
$formattedRequestsParent = AdRuleServiceClient::networkName('[NETWORK_CODE]');
$requestsAdRuleDisplayName = '[DISPLAY_NAME]';
batch_create_ad_rules_sample(
$formattedParent,
$formattedRequestsParent,
$requestsAdRuleDisplayName
);
}
batchDeactivateAdRules
Deactivates a list of AdRule objects.
The async variant is AdRuleServiceClient::batchDeactivateAdRulesAsync() .
| Parameters | |
|---|---|
| Name | Description |
request |
Google\Ads\AdManager\V1\BatchDeactivateAdRulesRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
Google\ApiCore\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. |
| Returns | |
|---|---|
| Type | Description |
Google\Ads\AdManager\V1\BatchDeactivateAdRulesResponse |
|
use Google\Ads\AdManager\V1\BatchDeactivateAdRulesRequest;
use Google\Ads\AdManager\V1\BatchDeactivateAdRulesResponse;
use Google\Ads\AdManager\V1\Client\AdRuleServiceClient;
use Google\ApiCore\ApiException;
/**
* @param string $formattedParent Format: `networks/{network_code}`
* Please see {@see AdRuleServiceClient::networkName()} for help formatting this field.
* @param string $formattedNamesElement Resource names for the AdRule.
* Format:
* `networks/{network_code}/adRules/{ad_rule}`
* Please see {@see AdRuleServiceClient::adRuleName()} for help formatting this field.
*/
function batch_deactivate_ad_rules_sample(
string $formattedParent,
string $formattedNamesElement
): void {
// Create a client.
$adRuleServiceClient = new AdRuleServiceClient();
// Prepare the request message.
$formattedNames = [$formattedNamesElement,];
$request = (new BatchDeactivateAdRulesRequest())
->setParent($formattedParent)
->setNames($formattedNames);
// Call the API and handle any network failures.
try {
/** @var BatchDeactivateAdRulesResponse $response */
$response = $adRuleServiceClient->batchDeactivateAdRules($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 = AdRuleServiceClient::networkName('[NETWORK_CODE]');
$formattedNamesElement = AdRuleServiceClient::adRuleName('[NETWORK_CODE]', '[AD_RULE]');
batch_deactivate_ad_rules_sample($formattedParent, $formattedNamesElement);
}
batchDeleteAdRules
Deletes a list of AdRule objects.
The async variant is AdRuleServiceClient::batchDeleteAdRulesAsync() .
| Parameters | |
|---|---|
| Name | Description |
request |
Google\Ads\AdManager\V1\BatchDeleteAdRulesRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
Google\ApiCore\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\BatchDeleteAdRulesRequest;
use Google\Ads\AdManager\V1\Client\AdRuleServiceClient;
use Google\ApiCore\ApiException;
/**
* @param string $formattedParent Format: `networks/{network_code}`
* Please see {@see AdRuleServiceClient::networkName()} for help formatting this field.
* @param string $formattedNamesElement Resource names for the AdRule.
* Format:
* `networks/{network_code}/adRules/{ad_rule}`
* Please see {@see AdRuleServiceClient::adRuleName()} for help formatting this field.
*/
function batch_delete_ad_rules_sample(
string $formattedParent,
string $formattedNamesElement
): void {
// Create a client.
$adRuleServiceClient = new AdRuleServiceClient();
// Prepare the request message.
$formattedNames = [$formattedNamesElement,];
$request = (new BatchDeleteAdRulesRequest())
->setParent($formattedParent)
->setNames($formattedNames);
// Call the API and handle any network failures.
try {
$adRuleServiceClient->batchDeleteAdRules($request);
printf('Call completed successfully.' . PHP_EOL);
} 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 = AdRuleServiceClient::networkName('[NETWORK_CODE]');
$formattedNamesElement = AdRuleServiceClient::adRuleName('[NETWORK_CODE]', '[AD_RULE]');
batch_delete_ad_rules_sample($formattedParent, $formattedNamesElement);
}
batchUpdateAdRules
Batch updates AdRule objects.
The async variant is AdRuleServiceClient::batchUpdateAdRulesAsync() .
| Parameters | |
|---|---|
| Name | Description |
request |
Google\Ads\AdManager\V1\BatchUpdateAdRulesRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
Google\ApiCore\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. |
| Returns | |
|---|---|
| Type | Description |
Google\Ads\AdManager\V1\BatchUpdateAdRulesResponse |
|
use Google\Ads\AdManager\V1\AdRule;
use Google\Ads\AdManager\V1\AdRuleSlot;
use Google\Ads\AdManager\V1\BatchUpdateAdRulesRequest;
use Google\Ads\AdManager\V1\BatchUpdateAdRulesResponse;
use Google\Ads\AdManager\V1\Client\AdRuleServiceClient;
use Google\Ads\AdManager\V1\Targeting;
use Google\Ads\AdManager\V1\UpdateAdRuleRequest;
use Google\ApiCore\ApiException;
use Google\Protobuf\Timestamp;
/**
* @param string $formattedParent The parent resource where `AdRules` will be updated.
* Format: `networks/{network_code}`
* The parent field in the UpdateAdRuleRequest must match this
* field. Please see
* {@see AdRuleServiceClient::networkName()} for help formatting this field.
* @param string $requestsAdRuleDisplayName The unique name of the AdRule. This attribute is required to
* create an ad rule and has a maximum length of 255 characters.
*/
function batch_update_ad_rules_sample(
string $formattedParent,
string $requestsAdRuleDisplayName
): void {
// Create a client.
$adRuleServiceClient = new AdRuleServiceClient();
// Prepare the request message.
$requestsAdRuleStartTime = new Timestamp();
$requestsAdRulePreroll = new AdRuleSlot();
$requestsAdRuleMidrolls = [new AdRuleSlot()];
$requestsAdRulePostroll = new AdRuleSlot();
$requestsAdRuleTargeting = new Targeting();
$requestsAdRule = (new AdRule())
->setDisplayName($requestsAdRuleDisplayName)
->setStartTime($requestsAdRuleStartTime)
->setPreroll($requestsAdRulePreroll)
->setMidrolls($requestsAdRuleMidrolls)
->setPostroll($requestsAdRulePostroll)
->setTargeting($requestsAdRuleTargeting);
$updateAdRuleRequest = (new UpdateAdRuleRequest())
->setAdRule($requestsAdRule);
$requests = [$updateAdRuleRequest,];
$request = (new BatchUpdateAdRulesRequest())
->setParent($formattedParent)
->setRequests($requests);
// Call the API and handle any network failures.
try {
/** @var BatchUpdateAdRulesResponse $response */
$response = $adRuleServiceClient->batchUpdateAdRules($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 = AdRuleServiceClient::networkName('[NETWORK_CODE]');
$requestsAdRuleDisplayName = '[DISPLAY_NAME]';
batch_update_ad_rules_sample($formattedParent, $requestsAdRuleDisplayName);
}
createAdRule
Creates a AdRule object.
The async variant is AdRuleServiceClient::createAdRuleAsync() .
| Parameters | |
|---|---|
| Name | Description |
request |
Google\Ads\AdManager\V1\CreateAdRuleRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
Google\ApiCore\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. |
| Returns | |
|---|---|
| Type | Description |
Google\Ads\AdManager\V1\AdRule |
|
use Google\Ads\AdManager\V1\AdRule;
use Google\Ads\AdManager\V1\AdRuleSlot;
use Google\Ads\AdManager\V1\Client\AdRuleServiceClient;
use Google\Ads\AdManager\V1\CreateAdRuleRequest;
use Google\Ads\AdManager\V1\Targeting;
use Google\ApiCore\ApiException;
use Google\Protobuf\Timestamp;
/**
* @param string $formattedParent The parent resource where this `AdRule` will be created.
* Format: `networks/{network_code}`
* Please see {@see AdRuleServiceClient::networkName()} for help formatting this field.
* @param string $adRuleDisplayName The unique name of the AdRule. This attribute is required to
* create an ad rule and has a maximum length of 255 characters.
*/
function create_ad_rule_sample(string $formattedParent, string $adRuleDisplayName): void
{
// Create a client.
$adRuleServiceClient = new AdRuleServiceClient();
// Prepare the request message.
$adRuleStartTime = new Timestamp();
$adRulePreroll = new AdRuleSlot();
$adRuleMidrolls = [new AdRuleSlot()];
$adRulePostroll = new AdRuleSlot();
$adRuleTargeting = new Targeting();
$adRule = (new AdRule())
->setDisplayName($adRuleDisplayName)
->setStartTime($adRuleStartTime)
->setPreroll($adRulePreroll)
->setMidrolls($adRuleMidrolls)
->setPostroll($adRulePostroll)
->setTargeting($adRuleTargeting);
$request = (new CreateAdRuleRequest())
->setParent($formattedParent)
->setAdRule($adRule);
// Call the API and handle any network failures.
try {
/** @var AdRule $response */
$response = $adRuleServiceClient->createAdRule($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 = AdRuleServiceClient::networkName('[NETWORK_CODE]');
$adRuleDisplayName = '[DISPLAY_NAME]';
create_ad_rule_sample($formattedParent, $adRuleDisplayName);
}
getAdRule
Retrieves an AdRule object.
The async variant is AdRuleServiceClient::getAdRuleAsync() .
| Parameters | |
|---|---|
| Name | Description |
request |
Google\Ads\AdManager\V1\GetAdRuleRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
Google\ApiCore\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. |
| Returns | |
|---|---|
| Type | Description |
Google\Ads\AdManager\V1\AdRule |
|
use Google\Ads\AdManager\V1\AdRule;
use Google\Ads\AdManager\V1\Client\AdRuleServiceClient;
use Google\Ads\AdManager\V1\GetAdRuleRequest;
use Google\ApiCore\ApiException;
/**
* @param string $formattedName The resource name of the AdRule.
* Format: `networks/{network_code}/adRules/{ad_rule_id}`
* Please see {@see AdRuleServiceClient::adRuleName()} for help formatting this field.
*/
function get_ad_rule_sample(string $formattedName): void
{
// Create a client.
$adRuleServiceClient = new AdRuleServiceClient();
// Prepare the request message.
$request = (new GetAdRuleRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var AdRule $response */
$response = $adRuleServiceClient->getAdRule($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 = AdRuleServiceClient::adRuleName('[NETWORK_CODE]', '[AD_RULE]');
get_ad_rule_sample($formattedName);
}
listAdRules
Lists AdRule objects.
The async variant is AdRuleServiceClient::listAdRulesAsync() .
| Parameters | |
|---|---|
| Name | Description |
request |
Google\Ads\AdManager\V1\ListAdRulesRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
Google\ApiCore\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. |
| Returns | |
|---|---|
| Type | Description |
Google\ApiCore\PagedListResponse |
|
use Google\Ads\AdManager\V1\Client\AdRuleServiceClient;
use Google\Ads\AdManager\V1\ListAdRulesRequest;
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
/**
* @param string $formattedParent The parent, which owns this collection of AdRules.
* Format: `networks/{network_code}`
* Please see {@see AdRuleServiceClient::networkName()} for help formatting this field.
*/
function list_ad_rules_sample(string $formattedParent): void
{
// Create a client.
$adRuleServiceClient = new AdRuleServiceClient();
// Prepare the request message.
$request = (new ListAdRulesRequest())
->setParent($formattedParent);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $adRuleServiceClient->listAdRules($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 = AdRuleServiceClient::networkName('[NETWORK_CODE]');
list_ad_rules_sample($formattedParent);
}
updateAdRule
Updates a AdRule object.
The async variant is AdRuleServiceClient::updateAdRuleAsync() .
| Parameters | |
|---|---|
| Name | Description |
request |
Google\Ads\AdManager\V1\UpdateAdRuleRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
Google\ApiCore\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. |
| Returns | |
|---|---|
| Type | Description |
Google\Ads\AdManager\V1\AdRule |
|
use Google\Ads\AdManager\V1\AdRule;
use Google\Ads\AdManager\V1\AdRuleSlot;
use Google\Ads\AdManager\V1\Client\AdRuleServiceClient;
use Google\Ads\AdManager\V1\Targeting;
use Google\Ads\AdManager\V1\UpdateAdRuleRequest;
use Google\ApiCore\ApiException;
use Google\Protobuf\Timestamp;
/**
* @param string $adRuleDisplayName The unique name of the AdRule. This attribute is required to
* create an ad rule and has a maximum length of 255 characters.
*/
function update_ad_rule_sample(string $adRuleDisplayName): void
{
// Create a client.
$adRuleServiceClient = new AdRuleServiceClient();
// Prepare the request message.
$adRuleStartTime = new Timestamp();
$adRulePreroll = new AdRuleSlot();
$adRuleMidrolls = [new AdRuleSlot()];
$adRulePostroll = new AdRuleSlot();
$adRuleTargeting = new Targeting();
$adRule = (new AdRule())
->setDisplayName($adRuleDisplayName)
->setStartTime($adRuleStartTime)
->setPreroll($adRulePreroll)
->setMidrolls($adRuleMidrolls)
->setPostroll($adRulePostroll)
->setTargeting($adRuleTargeting);
$request = (new UpdateAdRuleRequest())
->setAdRule($adRule);
// Call the API and handle any network failures.
try {
/** @var AdRule $response */
$response = $adRuleServiceClient->updateAdRule($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
{
$adRuleDisplayName = '[DISPLAY_NAME]';
update_ad_rule_sample($adRuleDisplayName);
}
batchActivateAdRulesAsync
| Parameters | |
|---|---|
| Name | Description |
request |
Google\Ads\AdManager\V1\BatchActivateAdRulesRequest
|
optionalArgs |
array
|
| Returns | |
|---|---|
| Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\Ads\AdManager\V1\BatchActivateAdRulesResponse> |
|
batchCreateAdRulesAsync
| Parameters | |
|---|---|
| Name | Description |
request |
Google\Ads\AdManager\V1\BatchCreateAdRulesRequest
|
optionalArgs |
array
|
| Returns | |
|---|---|
| Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\Ads\AdManager\V1\BatchCreateAdRulesResponse> |
|
batchDeactivateAdRulesAsync
| Parameters | |
|---|---|
| Name | Description |
request |
Google\Ads\AdManager\V1\BatchDeactivateAdRulesRequest
|
optionalArgs |
array
|
| Returns | |
|---|---|
| Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\Ads\AdManager\V1\BatchDeactivateAdRulesResponse> |
|
batchDeleteAdRulesAsync
| Parameters | |
|---|---|
| Name | Description |
request |
Google\Ads\AdManager\V1\BatchDeleteAdRulesRequest
|
optionalArgs |
array
|
| Returns | |
|---|---|
| Type | Description |
GuzzleHttp\Promise\PromiseInterface<void> |
|
batchUpdateAdRulesAsync
| Parameters | |
|---|---|
| Name | Description |
request |
Google\Ads\AdManager\V1\BatchUpdateAdRulesRequest
|
optionalArgs |
array
|
| Returns | |
|---|---|
| Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\Ads\AdManager\V1\BatchUpdateAdRulesResponse> |
|
createAdRuleAsync
| Parameters | |
|---|---|
| Name | Description |
request |
Google\Ads\AdManager\V1\CreateAdRuleRequest
|
optionalArgs |
array
|
| Returns | |
|---|---|
| Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\Ads\AdManager\V1\AdRule> |
|
getAdRuleAsync
| Parameters | |
|---|---|
| Name | Description |
request |
Google\Ads\AdManager\V1\GetAdRuleRequest
|
optionalArgs |
array
|
| Returns | |
|---|---|
| Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\Ads\AdManager\V1\AdRule> |
|
listAdRulesAsync
| Parameters | |
|---|---|
| Name | Description |
request |
Google\Ads\AdManager\V1\ListAdRulesRequest
|
optionalArgs |
array
|
| Returns | |
|---|---|
| Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse> |
|
updateAdRuleAsync
| Parameters | |
|---|---|
| Name | Description |
request |
Google\Ads\AdManager\V1\UpdateAdRuleRequest
|
optionalArgs |
array
|
| Returns | |
|---|---|
| Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\Ads\AdManager\V1\AdRule> |
|
static::adRuleName
Formats a string containing the fully-qualified path to represent a ad_rule resource.
| Parameters | |
|---|---|
| Name | Description |
networkCode |
string
|
adRule |
string
|
| Returns | |
|---|---|
| Type | Description |
string |
The formatted ad_rule resource. |
static::adUnitName
Formats a string containing the fully-qualified path to represent a ad_unit resource.
| Parameters | |
|---|---|
| Name | Description |
networkCode |
string
|
adUnit |
string
|
| Returns | |
|---|---|
| Type | Description |
string |
The formatted ad_unit resource. |
static::applicationName
Formats a string containing the fully-qualified path to represent a application resource.
| Parameters | |
|---|---|
| Name | Description |
networkCode |
string
|
application |
string
|
| Returns | |
|---|---|
| Type | Description |
string |
The formatted application resource. |
static::audienceSegmentName
Formats a string containing the fully-qualified path to represent a audience_segment resource.
| Parameters | |
|---|---|
| Name | Description |
networkCode |
string
|
audienceSegment |
string
|
| Returns | |
|---|---|
| Type | Description |
string |
The formatted audience_segment resource. |
static::bandwidthGroupName
Formats a string containing the fully-qualified path to represent a bandwidth_group resource.
| Parameters | |
|---|---|
| Name | Description |
networkCode |
string
|
bandwidthGroup |
string
|
| Returns | |
|---|---|
| Type | Description |
string |
The formatted bandwidth_group resource. |
static::browserName
Formats a string containing the fully-qualified path to represent a browser resource.
| Parameters | |
|---|---|
| Name | Description |
networkCode |
string
|
browser |
string
|
| Returns | |
|---|---|
| Type | Description |
string |
The formatted browser resource. |
static::browserLanguageName
Formats a string containing the fully-qualified path to represent a browser_language resource.
| Parameters | |
|---|---|
| Name | Description |
networkCode |
string
|
browserLanguage |
string
|
| Returns | |
|---|---|
| Type | Description |
string |
The formatted browser_language resource. |
static::cmsMetadataValueName
Formats a string containing the fully-qualified path to represent a cms_metadata_value resource.
| Parameters | |
|---|---|
| Name | Description |
networkCode |
string
|
cmsMetadataValue |
string
|
| Returns | |
|---|---|
| Type | Description |
string |
The formatted cms_metadata_value resource. |
static::contentName
Formats a string containing the fully-qualified path to represent a content resource.
| Parameters | |
|---|---|
| Name | Description |
networkCode |
string
|
content |
string
|
| Returns | |
|---|---|
| Type | Description |
string |
The formatted content resource. |
static::contentBundleName
Formats a string containing the fully-qualified path to represent a content_bundle resource.
| Parameters | |
|---|---|
| Name | Description |
networkCode |
string
|
contentBundle |
string
|
| Returns | |
|---|---|
| Type | Description |
string |
The formatted content_bundle resource. |
static::customTargetingKeyName
Formats a string containing the fully-qualified path to represent a custom_targeting_key resource.
| Parameters | |
|---|---|
| Name | Description |
networkCode |
string
|
customTargetingKey |
string
|
| Returns | |
|---|---|
| Type | Description |
string |
The formatted custom_targeting_key resource. |
static::customTargetingValueName
Formats a string containing the fully-qualified path to represent a custom_targeting_value resource.
| Parameters | |
|---|---|
| Name | Description |
networkCode |
string
|
customTargetingValue |
string
|
| Returns | |
|---|---|
| Type | Description |
string |
The formatted custom_targeting_value resource. |
static::deviceCapabilityName
Formats a string containing the fully-qualified path to represent a device_capability resource.
| Parameters | |
|---|---|
| Name | Description |
networkCode |
string
|
deviceCapability |
string
|
| Returns | |
|---|---|
| Type | Description |
string |
The formatted device_capability resource. |
static::deviceCategoryName
Formats a string containing the fully-qualified path to represent a device_category resource.
| Parameters | |
|---|---|
| Name | Description |
networkCode |
string
|
deviceCategory |
string
|
| Returns | |
|---|---|
| Type | Description |
string |
The formatted device_category resource. |
static::deviceManufacturerName
Formats a string containing the fully-qualified path to represent a device_manufacturer resource.
| Parameters | |
|---|---|
| Name | Description |
networkCode |
string
|
deviceManufacturer |
string
|
| Returns | |
|---|---|
| Type | Description |
string |
The formatted device_manufacturer resource. |
static::geoTargetName
Formats a string containing the fully-qualified path to represent a geo_target resource.
| Parameters | |
|---|---|
| Name | Description |
networkCode |
string
|
geoTarget |
string
|
| Returns | |
|---|---|
| Type | Description |
string |
The formatted geo_target resource. |
static::mobileCarrierName
Formats a string containing the fully-qualified path to represent a mobile_carrier resource.
| Parameters | |
|---|---|
| Name | Description |
networkCode |
string
|
mobileCarrier |
string
|
| Returns | |
|---|---|
| Type | Description |
string |
The formatted mobile_carrier resource. |
static::mobileDeviceName
Formats a string containing the fully-qualified path to represent a mobile_device resource.
| Parameters | |
|---|---|
| Name | Description |
networkCode |
string
|
mobileDevice |
string
|
| Returns | |
|---|---|
| Type | Description |
string |
The formatted mobile_device resource. |
static::mobileDeviceSubmodelName
Formats a string containing the fully-qualified path to represent a mobile_device_submodel resource.
| Parameters | |
|---|---|
| Name | Description |
networkCode |
string
|
mobileDeviceSubmodel |
string
|
| Returns | |
|---|---|
| Type | Description |
string |
The formatted mobile_device_submodel resource. |
static::networkName
Formats a string containing the fully-qualified path to represent a network resource.
| Parameter | |
|---|---|
| Name | Description |
networkCode |
string
|
| Returns | |
|---|---|
| Type | Description |
string |
The formatted network resource. |
static::operatingSystemName
Formats a string containing the fully-qualified path to represent a operating_system resource.
| Parameters | |
|---|---|
| Name | Description |
networkCode |
string
|
operatingSystem |
string
|
| Returns | |
|---|---|
| Type | Description |
string |
The formatted operating_system resource. |
static::operatingSystemVersionName
Formats a string containing the fully-qualified path to represent a operating_system_version resource.
| Parameters | |
|---|---|
| Name | Description |
networkCode |
string
|
operatingSystemVersion |
string
|
| Returns | |
|---|---|
| Type | Description |
string |
The formatted operating_system_version resource. |
static::placementName
Formats a string containing the fully-qualified path to represent a placement resource.
| Parameters | |
|---|---|
| Name | Description |
networkCode |
string
|
placement |
string
|
| Returns | |
|---|---|
| Type | Description |
string |
The formatted placement resource. |
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
- adRule: networks/{network_code}/adRules/{ad_rule}
- adUnit: networks/{network_code}/adUnits/{ad_unit}
- application: networks/{network_code}/applications/{application}
- audienceSegment: networks/{network_code}/audienceSegments/{audience_segment}
- bandwidthGroup: networks/{network_code}/bandwidthGroups/{bandwidth_group}
- browser: networks/{network_code}/browsers/{browser}
- browserLanguage: networks/{network_code}/browserLanguages/{browser_language}
- cmsMetadataValue: networks/{network_code}/cmsMetadataValues/{cms_metadata_value}
- content: networks/{network_code}/content/{content}
- contentBundle: networks/{network_code}/contentBundles/{content_bundle}
- customTargetingKey: networks/{network_code}/customTargetingKeys/{custom_targeting_key}
- customTargetingValue: networks/{network_code}/customTargetingValues/{custom_targeting_value}
- deviceCapability: networks/{network_code}/deviceCapabilities/{device_capability}
- deviceCategory: networks/{network_code}/deviceCategories/{device_category}
- deviceManufacturer: networks/{network_code}/deviceManufacturers/{device_manufacturer}
- geoTarget: networks/{network_code}/geoTargets/{geo_target}
- mobileCarrier: networks/{network_code}/mobileCarriers/{mobile_carrier}
- mobileDevice: networks/{network_code}/mobileDevices/{mobile_device}
- mobileDeviceSubmodel: networks/{network_code}/mobileDeviceSubmodels/{mobile_device_submodel}
- network: networks/{network_code}
- operatingSystem: networks/{network_code}/operatingSystems/{operating_system}
- operatingSystemVersion: networks/{network_code}/operatingSystemVersions/{operating_system_version}
- placement: networks/{network_code}/placements/{placement}
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.
| Parameters | |
|---|---|
| Name | Description |
formattedName |
string
The formatted name string |
template |
?string
Optional name of template to match |
| Returns | |
|---|---|
| Type | Description |
array |
An associative array from name component IDs to component values. |