Google Ads Ad Manager V1 Client - Class LiveStreamServiceClient (0.8.0)

Reference documentation and code samples for the Google Ads Ad Manager V1 Client class LiveStreamServiceClient.

Service Description: Provides methods for handling LiveStream 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 or Google\ApiCore\CredentialsWrapper object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored. Important: If you are providing a path to a credentials file, or a decoded credentials file as a PHP array, this usage is now DEPRECATED. Providing an unvalidated credential configuration to Google APIs can compromise the security of your systems and data. It is recommended to create the credentials explicitly use Google\Auth\Credentials\ServiceAccountCredentials; use Google\Ads\AdManager\V1\LiveStreamServiceClient; $creds = new ServiceAccountCredentials($scopes, $json); $options = new LiveStreamServiceClient(['credentials' => $creds]); https://cloud.google.com/docs/authentication/external/externally-sourced-credentials

↳ credentialsConfig array

Options used to configure credentials, including auth token caching, for the client. For a full list of supporting configuration options, see Google\ApiCore\CredentialsWrapper::build() .

↳ disableRetries bool

Determines whether or not retries defined by the client configuration should be disabled. Defaults to false.

↳ clientConfig string|array

Client method configuration, including retry settings. This option can be either a path to a JSON file, or a PHP array containing the decoded JSON data. By default this settings points to the default client config file, which is provided in the resources folder.

↳ transport string|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 object. Note that when this object is provided, any settings in $transportConfig, and any $apiEndpoint setting, will be ignored.

↳ transportConfig array

Configuration options that will be used to construct the transport. Options for each supported transport type should be passed in a key for that transport. For example: $transportConfig = [ 'rest' => [...], ]; See the Google\ApiCore\Transport\RestTransport::build() method for the supported options.

↳ clientCertSource callable

A callable which returns the client cert as a string. This can be used to provide a certificate and private key to the transport layer for mTLS.

↳ logger false|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'.

batchActivateLiveStreams

Batch activates LiveStream objects.

The async variant is LiveStreamServiceClient::batchActivateLiveStreamsAsync() .

Parameters
Name Description
request Google\Ads\AdManager\V1\BatchActivateLiveStreamsRequest

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\BatchActivateLiveStreamsResponse
Example
use Google\Ads\AdManager\V1\BatchActivateLiveStreamsRequest;
use Google\Ads\AdManager\V1\BatchActivateLiveStreamsResponse;
use Google\Ads\AdManager\V1\Client\LiveStreamServiceClient;
use Google\ApiCore\ApiException;

/**
 * @param string $formattedParent       Format: `networks/{network_code}`
 *                                      Please see {@see LiveStreamServiceClient::networkName()} for help formatting this field.
 * @param string $formattedNamesElement The resource names of the `LiveStream`s to activate.
 *                                      Format: `networks/{network_code}/liveStreams/{live_stream_id}`
 *                                      Please see {@see LiveStreamServiceClient::liveStreamName()} for help formatting this field.
 */
function batch_activate_live_streams_sample(
    string $formattedParent,
    string $formattedNamesElement
): void {
    // Create a client.
    $liveStreamServiceClient = new LiveStreamServiceClient();

    // Prepare the request message.
    $formattedNames = [$formattedNamesElement,];
    $request = (new BatchActivateLiveStreamsRequest())
        ->setParent($formattedParent)
        ->setNames($formattedNames);

    // Call the API and handle any network failures.
    try {
        /** @var BatchActivateLiveStreamsResponse $response */
        $response = $liveStreamServiceClient->batchActivateLiveStreams($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 = LiveStreamServiceClient::networkName('[NETWORK_CODE]');
    $formattedNamesElement = LiveStreamServiceClient::liveStreamName('[NETWORK_CODE]', '[LIVE_STREAM]');

    batch_activate_live_streams_sample($formattedParent, $formattedNamesElement);
}

batchArchiveLiveStreams

Batch archives LiveStream objects.

The async variant is LiveStreamServiceClient::batchArchiveLiveStreamsAsync() .

Parameters
Name Description
request Google\Ads\AdManager\V1\BatchArchiveLiveStreamsRequest

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\BatchArchiveLiveStreamsResponse
Example
use Google\Ads\AdManager\V1\BatchArchiveLiveStreamsRequest;
use Google\Ads\AdManager\V1\BatchArchiveLiveStreamsResponse;
use Google\Ads\AdManager\V1\Client\LiveStreamServiceClient;
use Google\ApiCore\ApiException;

/**
 * @param string $formattedParent       Format: `networks/{network_code}`
 *                                      Please see {@see LiveStreamServiceClient::networkName()} for help formatting this field.
 * @param string $formattedNamesElement The resource names of the `LiveStream`s to archive.
 *                                      Format: `networks/{network_code}/liveStreams/{live_stream_id}`
 *                                      Please see {@see LiveStreamServiceClient::liveStreamName()} for help formatting this field.
 */
function batch_archive_live_streams_sample(
    string $formattedParent,
    string $formattedNamesElement
): void {
    // Create a client.
    $liveStreamServiceClient = new LiveStreamServiceClient();

    // Prepare the request message.
    $formattedNames = [$formattedNamesElement,];
    $request = (new BatchArchiveLiveStreamsRequest())
        ->setParent($formattedParent)
        ->setNames($formattedNames);

    // Call the API and handle any network failures.
    try {
        /** @var BatchArchiveLiveStreamsResponse $response */
        $response = $liveStreamServiceClient->batchArchiveLiveStreams($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 = LiveStreamServiceClient::networkName('[NETWORK_CODE]');
    $formattedNamesElement = LiveStreamServiceClient::liveStreamName('[NETWORK_CODE]', '[LIVE_STREAM]');

    batch_archive_live_streams_sample($formattedParent, $formattedNamesElement);
}

batchCreateLiveStreams

Batch creates LiveStream objects.

The async variant is LiveStreamServiceClient::batchCreateLiveStreamsAsync() .

Parameters
Name Description
request Google\Ads\AdManager\V1\BatchCreateLiveStreamsRequest

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\BatchCreateLiveStreamsResponse
Example
use Google\Ads\AdManager\V1\BatchCreateLiveStreamsRequest;
use Google\Ads\AdManager\V1\BatchCreateLiveStreamsResponse;
use Google\Ads\AdManager\V1\Client\LiveStreamServiceClient;
use Google\Ads\AdManager\V1\CreateLiveStreamRequest;
use Google\Ads\AdManager\V1\LiveStream;
use Google\ApiCore\ApiException;

/**
 * @param string $formattedParent                      The parent resource where `LiveStreams` will be created.
 *                                                     Format: `networks/{network_code}`
 *                                                     The parent field in the CreateLiveStreamRequest must match this
 *                                                     field. Please see
 *                                                     {@see LiveStreamServiceClient::networkName()} for help formatting this field.
 * @param string $formattedRequestsParent              The parent resource where this `LiveStream` will be created.
 *                                                     Format: `networks/{network_code}`
 *                                                     Please see {@see LiveStreamServiceClient::networkName()} for help formatting this field.
 * @param string $requestsLiveStreamDisplayName        The name of the LiveStream. This value has a maximum length of
 *                                                     255 characters.
 * @param string $requestsLiveStreamContentUrlsElement The list of URLs pointing to the live stream content in Content
 *                                                     Delivery Network. Can be modified when the live stream is in a
 *                                                     [PAUSED][google.ads.admanager.v1.LiveStreamEventStatusEnum.LiveStreamEventStatus.PAUSED]
 *                                                     state.
 * @param string $requestsLiveStreamAdTagsElement      The list of Ad Manager ad tag URLs generated by the Ad Manager
 *                                                     trafficking workflow that are associated with this live stream. Currently,
 *                                                     the list includes only one element: the master ad tag.
 */
function batch_create_live_streams_sample(
    string $formattedParent,
    string $formattedRequestsParent,
    string $requestsLiveStreamDisplayName,
    string $requestsLiveStreamContentUrlsElement,
    string $requestsLiveStreamAdTagsElement
): void {
    // Create a client.
    $liveStreamServiceClient = new LiveStreamServiceClient();

    // Prepare the request message.
    $requestsLiveStreamContentUrls = [$requestsLiveStreamContentUrlsElement,];
    $requestsLiveStreamAdTags = [$requestsLiveStreamAdTagsElement,];
    $requestsLiveStream = (new LiveStream())
        ->setDisplayName($requestsLiveStreamDisplayName)
        ->setContentUrls($requestsLiveStreamContentUrls)
        ->setAdTags($requestsLiveStreamAdTags);
    $createLiveStreamRequest = (new CreateLiveStreamRequest())
        ->setParent($formattedRequestsParent)
        ->setLiveStream($requestsLiveStream);
    $requests = [$createLiveStreamRequest,];
    $request = (new BatchCreateLiveStreamsRequest())
        ->setParent($formattedParent)
        ->setRequests($requests);

    // Call the API and handle any network failures.
    try {
        /** @var BatchCreateLiveStreamsResponse $response */
        $response = $liveStreamServiceClient->batchCreateLiveStreams($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 = LiveStreamServiceClient::networkName('[NETWORK_CODE]');
    $formattedRequestsParent = LiveStreamServiceClient::networkName('[NETWORK_CODE]');
    $requestsLiveStreamDisplayName = '[DISPLAY_NAME]';
    $requestsLiveStreamContentUrlsElement = '[CONTENT_URLS]';
    $requestsLiveStreamAdTagsElement = '[AD_TAGS]';

    batch_create_live_streams_sample(
        $formattedParent,
        $formattedRequestsParent,
        $requestsLiveStreamDisplayName,
        $requestsLiveStreamContentUrlsElement,
        $requestsLiveStreamAdTagsElement
    );
}

batchPauseAdsLiveStreams

Batch pauses ads on LiveStream objects.

The async variant is LiveStreamServiceClient::batchPauseAdsLiveStreamsAsync() .

Parameters
Name Description
request Google\Ads\AdManager\V1\BatchPauseAdsLiveStreamsRequest

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\BatchPauseAdsLiveStreamsResponse
Example
use Google\Ads\AdManager\V1\BatchPauseAdsLiveStreamsRequest;
use Google\Ads\AdManager\V1\BatchPauseAdsLiveStreamsResponse;
use Google\Ads\AdManager\V1\Client\LiveStreamServiceClient;
use Google\ApiCore\ApiException;

/**
 * @param string $formattedParent       Format: `networks/{network_code}`
 *                                      Please see {@see LiveStreamServiceClient::networkName()} for help formatting this field.
 * @param string $formattedNamesElement The resource names of the `LiveStream`s to pause ads on.
 *                                      Format: `networks/{network_code}/liveStreams/{live_stream_id}`
 *                                      Please see {@see LiveStreamServiceClient::liveStreamName()} for help formatting this field.
 */
function batch_pause_ads_live_streams_sample(
    string $formattedParent,
    string $formattedNamesElement
): void {
    // Create a client.
    $liveStreamServiceClient = new LiveStreamServiceClient();

    // Prepare the request message.
    $formattedNames = [$formattedNamesElement,];
    $request = (new BatchPauseAdsLiveStreamsRequest())
        ->setParent($formattedParent)
        ->setNames($formattedNames);

    // Call the API and handle any network failures.
    try {
        /** @var BatchPauseAdsLiveStreamsResponse $response */
        $response = $liveStreamServiceClient->batchPauseAdsLiveStreams($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 = LiveStreamServiceClient::networkName('[NETWORK_CODE]');
    $formattedNamesElement = LiveStreamServiceClient::liveStreamName('[NETWORK_CODE]', '[LIVE_STREAM]');

    batch_pause_ads_live_streams_sample($formattedParent, $formattedNamesElement);
}

batchPauseLiveStreams

Batch pauses LiveStream objects.

The async variant is LiveStreamServiceClient::batchPauseLiveStreamsAsync() .

Parameters
Name Description
request Google\Ads\AdManager\V1\BatchPauseLiveStreamsRequest

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\BatchPauseLiveStreamsResponse
Example
use Google\Ads\AdManager\V1\BatchPauseLiveStreamsRequest;
use Google\Ads\AdManager\V1\BatchPauseLiveStreamsResponse;
use Google\Ads\AdManager\V1\Client\LiveStreamServiceClient;
use Google\ApiCore\ApiException;

/**
 * @param string $formattedParent       Format: `networks/{network_code}`
 *                                      Please see {@see LiveStreamServiceClient::networkName()} for help formatting this field.
 * @param string $formattedNamesElement The resource names of the `LiveStream`s to pause.
 *                                      Format: `networks/{network_code}/liveStreams/{live_stream_id}`
 *                                      Please see {@see LiveStreamServiceClient::liveStreamName()} for help formatting this field.
 */
function batch_pause_live_streams_sample(
    string $formattedParent,
    string $formattedNamesElement
): void {
    // Create a client.
    $liveStreamServiceClient = new LiveStreamServiceClient();

    // Prepare the request message.
    $formattedNames = [$formattedNamesElement,];
    $request = (new BatchPauseLiveStreamsRequest())
        ->setParent($formattedParent)
        ->setNames($formattedNames);

    // Call the API and handle any network failures.
    try {
        /** @var BatchPauseLiveStreamsResponse $response */
        $response = $liveStreamServiceClient->batchPauseLiveStreams($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 = LiveStreamServiceClient::networkName('[NETWORK_CODE]');
    $formattedNamesElement = LiveStreamServiceClient::liveStreamName('[NETWORK_CODE]', '[LIVE_STREAM]');

    batch_pause_live_streams_sample($formattedParent, $formattedNamesElement);
}

batchRefreshMasterPlaylists

Batch refreshes master playlists on LiveStream objects.

The async variant is LiveStreamServiceClient::batchRefreshMasterPlaylistsAsync() .

Parameters
Name Description
request Google\Ads\AdManager\V1\BatchRefreshMasterPlaylistsRequest

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\BatchRefreshMasterPlaylistsResponse
Example
use Google\Ads\AdManager\V1\BatchRefreshMasterPlaylistsRequest;
use Google\Ads\AdManager\V1\BatchRefreshMasterPlaylistsResponse;
use Google\Ads\AdManager\V1\Client\LiveStreamServiceClient;
use Google\ApiCore\ApiException;

/**
 * @param string $formattedParent       Format: `networks/{network_code}`
 *                                      Please see {@see LiveStreamServiceClient::networkName()} for help formatting this field.
 * @param string $formattedNamesElement The resource names of the `LiveStream`s to refresh master
 *                                      playlists on. Format:
 *                                      `networks/{network_code}/liveStreams/{live_stream_id}`
 *                                      Please see {@see LiveStreamServiceClient::liveStreamName()} for help formatting this field.
 */
function batch_refresh_master_playlists_sample(
    string $formattedParent,
    string $formattedNamesElement
): void {
    // Create a client.
    $liveStreamServiceClient = new LiveStreamServiceClient();

    // Prepare the request message.
    $formattedNames = [$formattedNamesElement,];
    $request = (new BatchRefreshMasterPlaylistsRequest())
        ->setParent($formattedParent)
        ->setNames($formattedNames);

    // Call the API and handle any network failures.
    try {
        /** @var BatchRefreshMasterPlaylistsResponse $response */
        $response = $liveStreamServiceClient->batchRefreshMasterPlaylists($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 = LiveStreamServiceClient::networkName('[NETWORK_CODE]');
    $formattedNamesElement = LiveStreamServiceClient::liveStreamName('[NETWORK_CODE]', '[LIVE_STREAM]');

    batch_refresh_master_playlists_sample($formattedParent, $formattedNamesElement);
}

batchUpdateLiveStreams

Batch updates LiveStream objects.

The async variant is LiveStreamServiceClient::batchUpdateLiveStreamsAsync() .

Parameters
Name Description
request Google\Ads\AdManager\V1\BatchUpdateLiveStreamsRequest

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\BatchUpdateLiveStreamsResponse
Example
use Google\Ads\AdManager\V1\BatchUpdateLiveStreamsRequest;
use Google\Ads\AdManager\V1\BatchUpdateLiveStreamsResponse;
use Google\Ads\AdManager\V1\Client\LiveStreamServiceClient;
use Google\Ads\AdManager\V1\LiveStream;
use Google\Ads\AdManager\V1\UpdateLiveStreamRequest;
use Google\ApiCore\ApiException;

/**
 * @param string $formattedParent                      The parent resource where `LiveStreams` will be updated.
 *                                                     Format: `networks/{network_code}`
 *                                                     The parent field in the UpdateLiveStreamRequest must match this
 *                                                     field. Please see
 *                                                     {@see LiveStreamServiceClient::networkName()} for help formatting this field.
 * @param string $requestsLiveStreamDisplayName        The name of the LiveStream. This value has a maximum length of
 *                                                     255 characters.
 * @param string $requestsLiveStreamContentUrlsElement The list of URLs pointing to the live stream content in Content
 *                                                     Delivery Network. Can be modified when the live stream is in a
 *                                                     [PAUSED][google.ads.admanager.v1.LiveStreamEventStatusEnum.LiveStreamEventStatus.PAUSED]
 *                                                     state.
 * @param string $requestsLiveStreamAdTagsElement      The list of Ad Manager ad tag URLs generated by the Ad Manager
 *                                                     trafficking workflow that are associated with this live stream. Currently,
 *                                                     the list includes only one element: the master ad tag.
 */
function batch_update_live_streams_sample(
    string $formattedParent,
    string $requestsLiveStreamDisplayName,
    string $requestsLiveStreamContentUrlsElement,
    string $requestsLiveStreamAdTagsElement
): void {
    // Create a client.
    $liveStreamServiceClient = new LiveStreamServiceClient();

    // Prepare the request message.
    $requestsLiveStreamContentUrls = [$requestsLiveStreamContentUrlsElement,];
    $requestsLiveStreamAdTags = [$requestsLiveStreamAdTagsElement,];
    $requestsLiveStream = (new LiveStream())
        ->setDisplayName($requestsLiveStreamDisplayName)
        ->setContentUrls($requestsLiveStreamContentUrls)
        ->setAdTags($requestsLiveStreamAdTags);
    $updateLiveStreamRequest = (new UpdateLiveStreamRequest())
        ->setLiveStream($requestsLiveStream);
    $requests = [$updateLiveStreamRequest,];
    $request = (new BatchUpdateLiveStreamsRequest())
        ->setParent($formattedParent)
        ->setRequests($requests);

    // Call the API and handle any network failures.
    try {
        /** @var BatchUpdateLiveStreamsResponse $response */
        $response = $liveStreamServiceClient->batchUpdateLiveStreams($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 = LiveStreamServiceClient::networkName('[NETWORK_CODE]');
    $requestsLiveStreamDisplayName = '[DISPLAY_NAME]';
    $requestsLiveStreamContentUrlsElement = '[CONTENT_URLS]';
    $requestsLiveStreamAdTagsElement = '[AD_TAGS]';

    batch_update_live_streams_sample(
        $formattedParent,
        $requestsLiveStreamDisplayName,
        $requestsLiveStreamContentUrlsElement,
        $requestsLiveStreamAdTagsElement
    );
}

createLiveStream

Creates a LiveStream object.

The async variant is LiveStreamServiceClient::createLiveStreamAsync() .

Parameters
Name Description
request Google\Ads\AdManager\V1\CreateLiveStreamRequest

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\LiveStream
Example
use Google\Ads\AdManager\V1\Client\LiveStreamServiceClient;
use Google\Ads\AdManager\V1\CreateLiveStreamRequest;
use Google\Ads\AdManager\V1\LiveStream;
use Google\ApiCore\ApiException;

/**
 * @param string $formattedParent              The parent resource where this `LiveStream` will be created.
 *                                             Format: `networks/{network_code}`
 *                                             Please see {@see LiveStreamServiceClient::networkName()} for help formatting this field.
 * @param string $liveStreamDisplayName        The name of the LiveStream. This value has a maximum length of
 *                                             255 characters.
 * @param string $liveStreamContentUrlsElement The list of URLs pointing to the live stream content in Content
 *                                             Delivery Network. Can be modified when the live stream is in a
 *                                             [PAUSED][google.ads.admanager.v1.LiveStreamEventStatusEnum.LiveStreamEventStatus.PAUSED]
 *                                             state.
 * @param string $liveStreamAdTagsElement      The list of Ad Manager ad tag URLs generated by the Ad Manager
 *                                             trafficking workflow that are associated with this live stream. Currently,
 *                                             the list includes only one element: the master ad tag.
 */
function create_live_stream_sample(
    string $formattedParent,
    string $liveStreamDisplayName,
    string $liveStreamContentUrlsElement,
    string $liveStreamAdTagsElement
): void {
    // Create a client.
    $liveStreamServiceClient = new LiveStreamServiceClient();

    // Prepare the request message.
    $liveStreamContentUrls = [$liveStreamContentUrlsElement,];
    $liveStreamAdTags = [$liveStreamAdTagsElement,];
    $liveStream = (new LiveStream())
        ->setDisplayName($liveStreamDisplayName)
        ->setContentUrls($liveStreamContentUrls)
        ->setAdTags($liveStreamAdTags);
    $request = (new CreateLiveStreamRequest())
        ->setParent($formattedParent)
        ->setLiveStream($liveStream);

    // Call the API and handle any network failures.
    try {
        /** @var LiveStream $response */
        $response = $liveStreamServiceClient->createLiveStream($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 = LiveStreamServiceClient::networkName('[NETWORK_CODE]');
    $liveStreamDisplayName = '[DISPLAY_NAME]';
    $liveStreamContentUrlsElement = '[CONTENT_URLS]';
    $liveStreamAdTagsElement = '[AD_TAGS]';

    create_live_stream_sample(
        $formattedParent,
        $liveStreamDisplayName,
        $liveStreamContentUrlsElement,
        $liveStreamAdTagsElement
    );
}

getLiveStream

Retrieves a LiveStream object.

The async variant is LiveStreamServiceClient::getLiveStreamAsync() .

Parameters
Name Description
request Google\Ads\AdManager\V1\GetLiveStreamRequest

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\LiveStream
Example
use Google\Ads\AdManager\V1\Client\LiveStreamServiceClient;
use Google\Ads\AdManager\V1\GetLiveStreamRequest;
use Google\Ads\AdManager\V1\LiveStream;
use Google\ApiCore\ApiException;

/**
 * @param string $formattedName The resource name of the LiveStream.
 *                              Format: `networks/{network_code}/liveStreams/{live_stream_id}`
 *                              Please see {@see LiveStreamServiceClient::liveStreamName()} for help formatting this field.
 */
function get_live_stream_sample(string $formattedName): void
{
    // Create a client.
    $liveStreamServiceClient = new LiveStreamServiceClient();

    // Prepare the request message.
    $request = (new GetLiveStreamRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var LiveStream $response */
        $response = $liveStreamServiceClient->getLiveStream($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 = LiveStreamServiceClient::liveStreamName('[NETWORK_CODE]', '[LIVE_STREAM]');

    get_live_stream_sample($formattedName);
}

listLiveStreams

Lists LiveStream objects.

The async variant is LiveStreamServiceClient::listLiveStreamsAsync() .

Parameters
Name Description
request Google\Ads\AdManager\V1\ListLiveStreamsRequest

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
Example
use Google\Ads\AdManager\V1\Client\LiveStreamServiceClient;
use Google\Ads\AdManager\V1\ListLiveStreamsRequest;
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;

/**
 * @param string $formattedParent The parent, which owns this collection of LiveStreams.
 *                                Format: `networks/{network_code}`
 *                                Please see {@see LiveStreamServiceClient::networkName()} for help formatting this field.
 */
function list_live_streams_sample(string $formattedParent): void
{
    // Create a client.
    $liveStreamServiceClient = new LiveStreamServiceClient();

    // Prepare the request message.
    $request = (new ListLiveStreamsRequest())
        ->setParent($formattedParent);

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $liveStreamServiceClient->listLiveStreams($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 = LiveStreamServiceClient::networkName('[NETWORK_CODE]');

    list_live_streams_sample($formattedParent);
}

updateLiveStream

Updates a LiveStream object.

The async variant is LiveStreamServiceClient::updateLiveStreamAsync() .

Parameters
Name Description
request Google\Ads\AdManager\V1\UpdateLiveStreamRequest

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\LiveStream
Example
use Google\Ads\AdManager\V1\Client\LiveStreamServiceClient;
use Google\Ads\AdManager\V1\LiveStream;
use Google\Ads\AdManager\V1\UpdateLiveStreamRequest;
use Google\ApiCore\ApiException;

/**
 * @param string $liveStreamDisplayName        The name of the LiveStream. This value has a maximum length of
 *                                             255 characters.
 * @param string $liveStreamContentUrlsElement The list of URLs pointing to the live stream content in Content
 *                                             Delivery Network. Can be modified when the live stream is in a
 *                                             [PAUSED][google.ads.admanager.v1.LiveStreamEventStatusEnum.LiveStreamEventStatus.PAUSED]
 *                                             state.
 * @param string $liveStreamAdTagsElement      The list of Ad Manager ad tag URLs generated by the Ad Manager
 *                                             trafficking workflow that are associated with this live stream. Currently,
 *                                             the list includes only one element: the master ad tag.
 */
function update_live_stream_sample(
    string $liveStreamDisplayName,
    string $liveStreamContentUrlsElement,
    string $liveStreamAdTagsElement
): void {
    // Create a client.
    $liveStreamServiceClient = new LiveStreamServiceClient();

    // Prepare the request message.
    $liveStreamContentUrls = [$liveStreamContentUrlsElement,];
    $liveStreamAdTags = [$liveStreamAdTagsElement,];
    $liveStream = (new LiveStream())
        ->setDisplayName($liveStreamDisplayName)
        ->setContentUrls($liveStreamContentUrls)
        ->setAdTags($liveStreamAdTags);
    $request = (new UpdateLiveStreamRequest())
        ->setLiveStream($liveStream);

    // Call the API and handle any network failures.
    try {
        /** @var LiveStream $response */
        $response = $liveStreamServiceClient->updateLiveStream($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
{
    $liveStreamDisplayName = '[DISPLAY_NAME]';
    $liveStreamContentUrlsElement = '[CONTENT_URLS]';
    $liveStreamAdTagsElement = '[AD_TAGS]';

    update_live_stream_sample(
        $liveStreamDisplayName,
        $liveStreamContentUrlsElement,
        $liveStreamAdTagsElement
    );
}

batchActivateLiveStreamsAsync

Parameters
Name Description
request Google\Ads\AdManager\V1\BatchActivateLiveStreamsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Ads\AdManager\V1\BatchActivateLiveStreamsResponse>

batchArchiveLiveStreamsAsync

Parameters
Name Description
request Google\Ads\AdManager\V1\BatchArchiveLiveStreamsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Ads\AdManager\V1\BatchArchiveLiveStreamsResponse>

batchCreateLiveStreamsAsync

Parameters
Name Description
request Google\Ads\AdManager\V1\BatchCreateLiveStreamsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Ads\AdManager\V1\BatchCreateLiveStreamsResponse>

batchPauseAdsLiveStreamsAsync

Parameters
Name Description
request Google\Ads\AdManager\V1\BatchPauseAdsLiveStreamsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Ads\AdManager\V1\BatchPauseAdsLiveStreamsResponse>

batchPauseLiveStreamsAsync

Parameters
Name Description
request Google\Ads\AdManager\V1\BatchPauseLiveStreamsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Ads\AdManager\V1\BatchPauseLiveStreamsResponse>

batchRefreshMasterPlaylistsAsync

Parameters
Name Description
request Google\Ads\AdManager\V1\BatchRefreshMasterPlaylistsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Ads\AdManager\V1\BatchRefreshMasterPlaylistsResponse>

batchUpdateLiveStreamsAsync

Parameters
Name Description
request Google\Ads\AdManager\V1\BatchUpdateLiveStreamsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Ads\AdManager\V1\BatchUpdateLiveStreamsResponse>

createLiveStreamAsync

Parameters
Name Description
request Google\Ads\AdManager\V1\CreateLiveStreamRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Ads\AdManager\V1\LiveStream>

getLiveStreamAsync

Parameters
Name Description
request Google\Ads\AdManager\V1\GetLiveStreamRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Ads\AdManager\V1\LiveStream>

listLiveStreamsAsync

Parameters
Name Description
request Google\Ads\AdManager\V1\ListLiveStreamsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse>

updateLiveStreamAsync

Parameters
Name Description
request Google\Ads\AdManager\V1\UpdateLiveStreamRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Ads\AdManager\V1\LiveStream>

static::cdnConfigName

Formats a string containing the fully-qualified path to represent a cdn_config resource.

Parameters
Name Description
networkCode string
cdnConfig string
Returns
Type Description
string The formatted cdn_config resource.

static::liveStreamName

Formats a string containing the fully-qualified path to represent a live_stream resource.

Parameters
Name Description
networkCode string
liveStream string
Returns
Type Description
string The formatted live_stream 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

  • cdnConfig: networks/{network_code}/cdnConfigs/{cdn_config}
  • liveStream: networks/{network_code}/liveStreams/{live_stream}
  • 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.