Reference documentation and code samples for the Google Ads Ad Manager V1 Client class BreakTemplateServiceClient.
Service Description: Provides methods for handling BreakTemplate 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'. |
batchCreateBreakTemplates
Batch creates BreakTemplate objects.
The async variant is BreakTemplateServiceClient::batchCreateBreakTemplatesAsync() .
| Parameters | |
|---|---|
| Name | Description |
request |
Google\Ads\AdManager\V1\BatchCreateBreakTemplatesRequest
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\BatchCreateBreakTemplatesResponse |
|
use Google\Ads\AdManager\V1\BatchCreateBreakTemplatesRequest;
use Google\Ads\AdManager\V1\BatchCreateBreakTemplatesResponse;
use Google\Ads\AdManager\V1\BreakTemplate;
use Google\Ads\AdManager\V1\Client\BreakTemplateServiceClient;
use Google\Ads\AdManager\V1\CreateBreakTemplateRequest;
use Google\ApiCore\ApiException;
/**
* @param string $formattedParent The parent resource where `BreakTemplates` will be created.
* Format: `networks/{network_code}`
* The parent field in the `CreateBreakTemplateRequest` must match this
* field. Please see
* {@see BreakTemplateServiceClient::networkName()} for help formatting this field.
* @param string $formattedRequestsParent The parent resource where this `BreakTemplate` will be created.
* Format: `networks/{network_code}`
* Please see {@see BreakTemplateServiceClient::networkName()} for help formatting this field.
*/
function batch_create_break_templates_sample(
string $formattedParent,
string $formattedRequestsParent
): void {
// Create a client.
$breakTemplateServiceClient = new BreakTemplateServiceClient();
// Prepare the request message.
$requestsBreakTemplate = new BreakTemplate();
$createBreakTemplateRequest = (new CreateBreakTemplateRequest())
->setParent($formattedRequestsParent)
->setBreakTemplate($requestsBreakTemplate);
$requests = [$createBreakTemplateRequest,];
$request = (new BatchCreateBreakTemplatesRequest())
->setParent($formattedParent)
->setRequests($requests);
// Call the API and handle any network failures.
try {
/** @var BatchCreateBreakTemplatesResponse $response */
$response = $breakTemplateServiceClient->batchCreateBreakTemplates($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 = BreakTemplateServiceClient::networkName('[NETWORK_CODE]');
$formattedRequestsParent = BreakTemplateServiceClient::networkName('[NETWORK_CODE]');
batch_create_break_templates_sample($formattedParent, $formattedRequestsParent);
}
batchUpdateBreakTemplates
Batch updates BreakTemplate objects.
The async variant is BreakTemplateServiceClient::batchUpdateBreakTemplatesAsync() .
| Parameters | |
|---|---|
| Name | Description |
request |
Google\Ads\AdManager\V1\BatchUpdateBreakTemplatesRequest
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\BatchUpdateBreakTemplatesResponse |
|
use Google\Ads\AdManager\V1\BatchUpdateBreakTemplatesRequest;
use Google\Ads\AdManager\V1\BatchUpdateBreakTemplatesResponse;
use Google\Ads\AdManager\V1\BreakTemplate;
use Google\Ads\AdManager\V1\Client\BreakTemplateServiceClient;
use Google\Ads\AdManager\V1\UpdateBreakTemplateRequest;
use Google\ApiCore\ApiException;
/**
* @param string $formattedParent The parent resource where `BreakTemplates` will be updated.
* Format: `networks/{network_code}`
* The parent field in the `UpdateBreakTemplateRequest` must match this
* field. Please see
* {@see BreakTemplateServiceClient::networkName()} for help formatting this field.
*/
function batch_update_break_templates_sample(string $formattedParent): void
{
// Create a client.
$breakTemplateServiceClient = new BreakTemplateServiceClient();
// Prepare the request message.
$requestsBreakTemplate = new BreakTemplate();
$updateBreakTemplateRequest = (new UpdateBreakTemplateRequest())
->setBreakTemplate($requestsBreakTemplate);
$requests = [$updateBreakTemplateRequest,];
$request = (new BatchUpdateBreakTemplatesRequest())
->setParent($formattedParent)
->setRequests($requests);
// Call the API and handle any network failures.
try {
/** @var BatchUpdateBreakTemplatesResponse $response */
$response = $breakTemplateServiceClient->batchUpdateBreakTemplates($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 = BreakTemplateServiceClient::networkName('[NETWORK_CODE]');
batch_update_break_templates_sample($formattedParent);
}
createBreakTemplate
Creates a BreakTemplate object.
The async variant is BreakTemplateServiceClient::createBreakTemplateAsync() .
| Parameters | |
|---|---|
| Name | Description |
request |
Google\Ads\AdManager\V1\CreateBreakTemplateRequest
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\BreakTemplate |
|
use Google\Ads\AdManager\V1\BreakTemplate;
use Google\Ads\AdManager\V1\Client\BreakTemplateServiceClient;
use Google\Ads\AdManager\V1\CreateBreakTemplateRequest;
use Google\ApiCore\ApiException;
/**
* @param string $formattedParent The parent resource where this `BreakTemplate` will be created.
* Format: `networks/{network_code}`
* Please see {@see BreakTemplateServiceClient::networkName()} for help formatting this field.
*/
function create_break_template_sample(string $formattedParent): void
{
// Create a client.
$breakTemplateServiceClient = new BreakTemplateServiceClient();
// Prepare the request message.
$breakTemplate = new BreakTemplate();
$request = (new CreateBreakTemplateRequest())
->setParent($formattedParent)
->setBreakTemplate($breakTemplate);
// Call the API and handle any network failures.
try {
/** @var BreakTemplate $response */
$response = $breakTemplateServiceClient->createBreakTemplate($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 = BreakTemplateServiceClient::networkName('[NETWORK_CODE]');
create_break_template_sample($formattedParent);
}
getBreakTemplate
Retrieves a BreakTemplate object.
The async variant is BreakTemplateServiceClient::getBreakTemplateAsync() .
| Parameters | |
|---|---|
| Name | Description |
request |
Google\Ads\AdManager\V1\GetBreakTemplateRequest
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\BreakTemplate |
|
use Google\Ads\AdManager\V1\BreakTemplate;
use Google\Ads\AdManager\V1\Client\BreakTemplateServiceClient;
use Google\Ads\AdManager\V1\GetBreakTemplateRequest;
use Google\ApiCore\ApiException;
/**
* @param string $formattedName The resource name of the `BreakTemplate`.
* Format: `networks/{network_code}/breakTemplates/{break_template_id}`
* Please see {@see BreakTemplateServiceClient::breakTemplateName()} for help formatting this field.
*/
function get_break_template_sample(string $formattedName): void
{
// Create a client.
$breakTemplateServiceClient = new BreakTemplateServiceClient();
// Prepare the request message.
$request = (new GetBreakTemplateRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var BreakTemplate $response */
$response = $breakTemplateServiceClient->getBreakTemplate($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 = BreakTemplateServiceClient::breakTemplateName(
'[NETWORK_CODE]',
'[BREAK_TEMPLATE]'
);
get_break_template_sample($formattedName);
}
listBreakTemplates
Lists BreakTemplate objects.
The async variant is BreakTemplateServiceClient::listBreakTemplatesAsync() .
| Parameters | |
|---|---|
| Name | Description |
request |
Google\Ads\AdManager\V1\ListBreakTemplatesRequest
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\BreakTemplateServiceClient;
use Google\Ads\AdManager\V1\ListBreakTemplatesRequest;
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
/**
* @param string $formattedParent The parent, which owns this collection of `BreakTemplates`.
* Format: `networks/{network_code}`
* Please see {@see BreakTemplateServiceClient::networkName()} for help formatting this field.
*/
function list_break_templates_sample(string $formattedParent): void
{
// Create a client.
$breakTemplateServiceClient = new BreakTemplateServiceClient();
// Prepare the request message.
$request = (new ListBreakTemplatesRequest())
->setParent($formattedParent);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $breakTemplateServiceClient->listBreakTemplates($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 = BreakTemplateServiceClient::networkName('[NETWORK_CODE]');
list_break_templates_sample($formattedParent);
}
updateBreakTemplate
Updates a BreakTemplate object.
The async variant is BreakTemplateServiceClient::updateBreakTemplateAsync() .
| Parameters | |
|---|---|
| Name | Description |
request |
Google\Ads\AdManager\V1\UpdateBreakTemplateRequest
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\BreakTemplate |
|
use Google\Ads\AdManager\V1\BreakTemplate;
use Google\Ads\AdManager\V1\Client\BreakTemplateServiceClient;
use Google\Ads\AdManager\V1\UpdateBreakTemplateRequest;
use Google\ApiCore\ApiException;
/**
* 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 update_break_template_sample(): void
{
// Create a client.
$breakTemplateServiceClient = new BreakTemplateServiceClient();
// Prepare the request message.
$breakTemplate = new BreakTemplate();
$request = (new UpdateBreakTemplateRequest())
->setBreakTemplate($breakTemplate);
// Call the API and handle any network failures.
try {
/** @var BreakTemplate $response */
$response = $breakTemplateServiceClient->updateBreakTemplate($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
batchCreateBreakTemplatesAsync
| Parameters | |
|---|---|
| Name | Description |
request |
Google\Ads\AdManager\V1\BatchCreateBreakTemplatesRequest
|
optionalArgs |
array
|
| Returns | |
|---|---|
| Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\Ads\AdManager\V1\BatchCreateBreakTemplatesResponse> |
|
batchUpdateBreakTemplatesAsync
| Parameters | |
|---|---|
| Name | Description |
request |
Google\Ads\AdManager\V1\BatchUpdateBreakTemplatesRequest
|
optionalArgs |
array
|
| Returns | |
|---|---|
| Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\Ads\AdManager\V1\BatchUpdateBreakTemplatesResponse> |
|
createBreakTemplateAsync
| Parameters | |
|---|---|
| Name | Description |
request |
Google\Ads\AdManager\V1\CreateBreakTemplateRequest
|
optionalArgs |
array
|
| Returns | |
|---|---|
| Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\Ads\AdManager\V1\BreakTemplate> |
|
getBreakTemplateAsync
| Parameters | |
|---|---|
| Name | Description |
request |
Google\Ads\AdManager\V1\GetBreakTemplateRequest
|
optionalArgs |
array
|
| Returns | |
|---|---|
| Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\Ads\AdManager\V1\BreakTemplate> |
|
listBreakTemplatesAsync
| Parameters | |
|---|---|
| Name | Description |
request |
Google\Ads\AdManager\V1\ListBreakTemplatesRequest
|
optionalArgs |
array
|
| Returns | |
|---|---|
| Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse> |
|
updateBreakTemplateAsync
| Parameters | |
|---|---|
| Name | Description |
request |
Google\Ads\AdManager\V1\UpdateBreakTemplateRequest
|
optionalArgs |
array
|
| Returns | |
|---|---|
| Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\Ads\AdManager\V1\BreakTemplate> |
|
static::adSpotName
Formats a string containing the fully-qualified path to represent a ad_spot resource.
| Parameters | |
|---|---|
| Name | Description |
networkCode |
string
|
adSpot |
string
|
| Returns | |
|---|---|
| Type | Description |
string |
The formatted ad_spot resource. |
static::breakTemplateName
Formats a string containing the fully-qualified path to represent a break_template resource.
| Parameters | |
|---|---|
| Name | Description |
networkCode |
string
|
breakTemplate |
string
|
| Returns | |
|---|---|
| Type | Description |
string |
The formatted break_template 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::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
- adSpot: networks/{network_code}/adSpots/{ad_spot}
- breakTemplate: networks/{network_code}/breakTemplates/{break_template}
- 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.
| 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. |