Reference documentation and code samples for the Google Ads Ad Manager V1 Client class AdBreakServiceClient.
Service Description: Provides methods for handling AdBreak
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
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 |
string|array|FetchAuthTokenInterface|CredentialsWrapper
The credentials to be used by the client to authorize API calls. This option accepts either a path to a credentials file, or a decoded credentials file as a PHP array. Advanced usage: In addition, this option can also accept a pre-constructed Google\Auth\FetchAuthTokenInterface object or Google\ApiCore\CredentialsWrapper object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored. Important: If you accept a credential configuration (credential JSON/File/Stream) from an external source for authentication to Google Cloud Platform, you must validate it before providing it to any Google API or library. Providing an unvalidated credential configuration to Google APIs can compromise the security of your systems and data. For more information 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 |
↳ 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 |
↳ 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 |
createAdBreak
API to create an AdBreak
object.
Informs DAI of an upcoming ad break for a live stream event, with an
optional expected start time. DAI will begin decisioning ads for the break
shortly before the expected start time, if provided. Each live stream
event can only have one incomplete ad break at any given time. The next ad
break can be scheduled after the previous ad break has started serving,
indicated by its state being
COMPLETE
,
or it has been deleted.
This method cannot be used if the LiveStreamEvent
has
prefetching ad breaks
enabled
or the event is not active. If a LiveStreamEvent
is deactivated after
creating an ad break and before the ad break is complete, the ad break
is discarded.
An ad break's state is complete when the following occurs:
- Full service DAI: after a matching ad break shows in the
LiveStreamEvent
manifest only when the ad break has started decisioning. - Pod Serving: after the ad break is requested using the ad break ID or break sequence.
The async variant is AdBreakServiceClient::createAdBreakAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Ads\AdManager\V1\CreateAdBreakRequest
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. |
Returns | |
---|---|
Type | Description |
Google\Ads\AdManager\V1\AdBreak |
use Google\Ads\AdManager\V1\AdBreak;
use Google\Ads\AdManager\V1\Client\AdBreakServiceClient;
use Google\Ads\AdManager\V1\CreateAdBreakRequest;
use Google\ApiCore\ApiException;
use Google\Protobuf\Duration;
/**
* @param string $formattedParent The parent resource where this `AdBreak` will be created
* identified by an asset key or custom asset key.
*
* Formats:
* `networks/{network_code}/liveStreamEventsByAssetKey/{asset_key}`
* `networks/{network_code}/liveStreamEventsByCustomAssetKey/{custom_asset_key}`
* Please see {@see AdBreakServiceClient::liveStreamEventName()} for help formatting this field.
*/
function create_ad_break_sample(string $formattedParent): void
{
// Create a client.
$adBreakServiceClient = new AdBreakServiceClient();
// Prepare the request message.
$adBreakDuration = new Duration();
$adBreak = (new AdBreak())
->setDuration($adBreakDuration);
$request = (new CreateAdBreakRequest())
->setParent($formattedParent)
->setAdBreak($adBreak);
// Call the API and handle any network failures.
try {
/** @var AdBreak $response */
$response = $adBreakServiceClient->createAdBreak($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 = AdBreakServiceClient::liveStreamEventName(
'[NETWORK_CODE]',
'[LIVE_STREAM_EVENT]'
);
create_ad_break_sample($formattedParent);
}
deleteAdBreak
API to delete an AdBreak
object.
Deletes and cancels an incomplete ad break, mitigating the need to wait
for the current break to serve before recreating an ad break. You can
delete an ad break that has not started serving or seen in manifests,
indicated by its state being
SCHEDULED
or
DECISIONED
.
The async variant is AdBreakServiceClient::deleteAdBreakAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Ads\AdManager\V1\DeleteAdBreakRequest
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\AdBreakServiceClient;
use Google\Ads\AdManager\V1\DeleteAdBreakRequest;
use Google\ApiCore\ApiException;
/**
* @param string $formattedName The name of the ad break to delete.
*
* Format:
* `networks/{network_code}/liveStreamEventsByAssetKey/{asset_key}/adBreaks/{ad_break}`
* Please see {@see AdBreakServiceClient::adBreakName()} for help formatting this field.
*/
function delete_ad_break_sample(string $formattedName): void
{
// Create a client.
$adBreakServiceClient = new AdBreakServiceClient();
// Prepare the request message.
$request = (new DeleteAdBreakRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
$adBreakServiceClient->deleteAdBreak($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
{
$formattedName = AdBreakServiceClient::adBreakName('[NETWORK_CODE]', '[ASSET_KEY]', '[AD_BREAK]');
delete_ad_break_sample($formattedName);
}
getAdBreak
API to retrieve an AdBreak
object.
Query an ad break by its resource name or custom asset key. Check the
resource's breakState
field to determine its state.
The async variant is AdBreakServiceClient::getAdBreakAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Ads\AdManager\V1\GetAdBreakRequest
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. |
Returns | |
---|---|
Type | Description |
Google\Ads\AdManager\V1\AdBreak |
use Google\Ads\AdManager\V1\AdBreak;
use Google\Ads\AdManager\V1\Client\AdBreakServiceClient;
use Google\Ads\AdManager\V1\GetAdBreakRequest;
use Google\ApiCore\ApiException;
/**
* @param string $formattedName The resource name of the AdBreak using the asset key or custom
* asset key.
*
* Format:
* `networks/{network_code}/liveStreamEventsByAssetKey/{asset_key}/adBreaks/{ad_break_id}`
* `networks/{network_code}/liveStreamEventsByCustomAssetKey/{custom_asset_key}/adBreaks/{ad_break_id}`
* Please see {@see AdBreakServiceClient::adBreakName()} for help formatting this field.
*/
function get_ad_break_sample(string $formattedName): void
{
// Create a client.
$adBreakServiceClient = new AdBreakServiceClient();
// Prepare the request message.
$request = (new GetAdBreakRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var AdBreak $response */
$response = $adBreakServiceClient->getAdBreak($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 = AdBreakServiceClient::adBreakName('[NETWORK_CODE]', '[ASSET_KEY]', '[AD_BREAK]');
get_ad_break_sample($formattedName);
}
listAdBreaks
API to retrieve a list of AdBreak
objects.
By default, when no orderBy
query parameter is specified, ad breaks are
ordered reverse chronologically. However, ad breaks with a 'breakState' of
'SCHEDULED' or 'DECISIONED' are prioritized and appear first.
The async variant is AdBreakServiceClient::listAdBreaksAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Ads\AdManager\V1\ListAdBreaksRequest
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. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\PagedListResponse |
use Google\Ads\AdManager\V1\Client\AdBreakServiceClient;
use Google\Ads\AdManager\V1\ListAdBreaksRequest;
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
/**
* @param string $formattedParent The parent, which owns this collection of AdBreaks.
*
* Formats:
* `networks/{network_code}/liveStreamEventsByAssetKey/{asset_key}`
* `networks/{network_code}/liveStreamEventsByCustomAssetKey/{custom_asset_key}`
* Please see {@see AdBreakServiceClient::liveStreamEventName()} for help formatting this field.
*/
function list_ad_breaks_sample(string $formattedParent): void
{
// Create a client.
$adBreakServiceClient = new AdBreakServiceClient();
// Prepare the request message.
$request = (new ListAdBreaksRequest())
->setParent($formattedParent);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $adBreakServiceClient->listAdBreaks($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 = AdBreakServiceClient::liveStreamEventName(
'[NETWORK_CODE]',
'[LIVE_STREAM_EVENT]'
);
list_ad_breaks_sample($formattedParent);
}
updateAdBreak
API to update an AdBreak
object.
Modify an ad break when its state is
SCHEDULED
.
The async variant is AdBreakServiceClient::updateAdBreakAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Ads\AdManager\V1\UpdateAdBreakRequest
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. |
Returns | |
---|---|
Type | Description |
Google\Ads\AdManager\V1\AdBreak |
use Google\Ads\AdManager\V1\AdBreak;
use Google\Ads\AdManager\V1\Client\AdBreakServiceClient;
use Google\Ads\AdManager\V1\UpdateAdBreakRequest;
use Google\ApiCore\ApiException;
use Google\Protobuf\Duration;
use Google\Protobuf\FieldMask;
/**
* 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_ad_break_sample(): void
{
// Create a client.
$adBreakServiceClient = new AdBreakServiceClient();
// Prepare the request message.
$adBreakDuration = new Duration();
$adBreak = (new AdBreak())
->setDuration($adBreakDuration);
$updateMask = new FieldMask();
$request = (new UpdateAdBreakRequest())
->setAdBreak($adBreak)
->setUpdateMask($updateMask);
// Call the API and handle any network failures.
try {
/** @var AdBreak $response */
$response = $adBreakServiceClient->updateAdBreak($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
createAdBreakAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Ads\AdManager\V1\CreateAdBreakRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\Ads\AdManager\V1\AdBreak> |
deleteAdBreakAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Ads\AdManager\V1\DeleteAdBreakRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<void> |
getAdBreakAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Ads\AdManager\V1\GetAdBreakRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\Ads\AdManager\V1\AdBreak> |
listAdBreaksAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Ads\AdManager\V1\ListAdBreaksRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse> |
updateAdBreakAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Ads\AdManager\V1\UpdateAdBreakRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\Ads\AdManager\V1\AdBreak> |
static::adBreakName
Formats a string containing the fully-qualified path to represent a ad_break resource.
Parameters | |
---|---|
Name | Description |
networkCode |
string
|
assetKey |
string
|
adBreak |
string
|
Returns | |
---|---|
Type | Description |
string |
The formatted ad_break resource. |
static::liveStreamEventName
Formats a string containing the fully-qualified path to represent a live_stream_event resource.
Parameters | |
---|---|
Name | Description |
networkCode |
string
|
liveStreamEvent |
string
|
Returns | |
---|---|
Type | Description |
string |
The formatted live_stream_event 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
- adBreak: networks/{network_code}/liveStreamEventsByAssetKey/{asset_key}/adBreaks/{ad_break}
- liveStreamEvent: networks/{network_code}/liveStreamEvents/{live_stream_event}
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. |