0.17.0 (latest) 0.16.0 0.15.1 0.14.1 0.8.0 0.7.0 0.6.2 0.5.0 0.4.1 0.3.1 0.2.0 0.1.3 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 \\ Client

## Methods

### __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](https://docs.cloud.google.com/php/docs/reference/auth/latest/FetchAuthTokenInterface.md.txt) or [Google\\ApiCore\\CredentialsWrapper](https://docs.cloud.google.com/php/docs/reference/gax/latest/CredentialsWrapper.md.txt) 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\AdBreakServiceClient; $creds = new ServiceAccountCredentials($scopes, $json); $options = new AdBreakServiceClient(['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()](https://docs.cloud.google.com/php/docs/reference/gax/latest/CredentialsWrapper.md.txt#_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|Google\ApiCore\Transport\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](https://docs.cloud.google.com/php/docs/reference/gax/latest/Transport.TransportInterface.md.txt) 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()](https://docs.cloud.google.com/php/docs/reference/gax/latest/Transport.RestTransport.md.txt#_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'. |

### createAdBreak

Creates 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`](https://docs.cloud.google.com/php/docs/reference/ad-manager/latest/V1.AdBreakStateEnum.AdBreakState.md.txt#_Google_Ads_AdManager_V1_AdBreakStateEnum_AdBreakState__COMPLETE),
or it has been deleted.

This method cannot be used if the `LiveStreamEvent` has
[prefetching ad breaks
enabled](https://developers.google.com/ad-manager/api/reference/latest/LiveStreamEventService.LiveStreamEvent#prefetchenabled)
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()](https://docs.cloud.google.com/php/docs/reference/ad-manager/latest/V1.Client.AdBreakServiceClient.md.txt#_Google_Ads_AdManager_V1_Client_AdBreakServiceClient__createAdBreakAsync__) .

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Google\Ads\AdManager\V1\CreateAdBreakRequest` 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](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.md.txt) object, or an associative array of retry settings parameters. See the documentation on [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.md.txt) for example usage. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Google\Ads\AdManager\V1\AdBreak` |   |

**Example**

```php
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

Deletes 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`](https://docs.cloud.google.com/php/docs/reference/ad-manager/latest/V1.AdBreakStateEnum.AdBreakState.md.txt#_Google_Ads_AdManager_V1_AdBreakStateEnum_AdBreakState__SCHEDULED)
or
[`DECISIONED`](https://docs.cloud.google.com/php/docs/reference/ad-manager/latest/V1.AdBreakStateEnum.AdBreakState.md.txt#_Google_Ads_AdManager_V1_AdBreakStateEnum_AdBreakState__DECISIONED).

The async variant is [AdBreakServiceClient::deleteAdBreakAsync()](https://docs.cloud.google.com/php/docs/reference/ad-manager/latest/V1.Client.AdBreakServiceClient.md.txt#_Google_Ads_AdManager_V1_Client_AdBreakServiceClient__deleteAdBreakAsync__) .

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Google\Ads\AdManager\V1\DeleteAdBreakRequest` 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](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.md.txt) object, or an associative array of retry settings parameters. See the documentation on [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.md.txt) for example usage. |

**Example**

```php
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

Retrieves 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()](https://docs.cloud.google.com/php/docs/reference/ad-manager/latest/V1.Client.AdBreakServiceClient.md.txt#_Google_Ads_AdManager_V1_Client_AdBreakServiceClient__getAdBreakAsync__) .

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Google\Ads\AdManager\V1\GetAdBreakRequest` 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](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.md.txt) object, or an associative array of retry settings parameters. See the documentation on [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.md.txt) for example usage. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Google\Ads\AdManager\V1\AdBreak` |   |

**Example**

```php
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

Lists `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()](https://docs.cloud.google.com/php/docs/reference/ad-manager/latest/V1.Client.AdBreakServiceClient.md.txt#_Google_Ads_AdManager_V1_Client_AdBreakServiceClient__listAdBreaksAsync__) .

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Google\Ads\AdManager\V1\ListAdBreaksRequest` 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](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.md.txt) object, or an associative array of retry settings parameters. See the documentation on [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.md.txt) for example usage. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Google\ApiCore\PagedListResponse` |   |

**Example**

```php
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

Updates an `AdBreak` object.

Modify an ad break when its state is
[`SCHEDULED`](https://docs.cloud.google.com/php/docs/reference/ad-manager/latest/V1.AdBreakStateEnum.AdBreakState.md.txt#_Google_Ads_AdManager_V1_AdBreakStateEnum_AdBreakState__SCHEDULED).

The async variant is [AdBreakServiceClient::updateAdBreakAsync()](https://docs.cloud.google.com/php/docs/reference/ad-manager/latest/V1.Client.AdBreakServiceClient.md.txt#_Google_Ads_AdManager_V1_Client_AdBreakServiceClient__updateAdBreakAsync__) .

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `Google\Ads\AdManager\V1\UpdateAdBreakRequest` 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](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.md.txt) object, or an associative array of retry settings parameters. See the documentation on [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.md.txt) for example usage. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Google\Ads\AdManager\V1\AdBreak` |   |

**Example**

```php
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;

/**
 * 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);
    $request = (new UpdateAdBreakRequest())
        ->setAdBreak($adBreak);

    // 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. |