Google Ads Ad Manager V1 Client - Class LineItemCreativeAssociationServiceClient (0.17.0)

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

Service Description: Provides methods for handling LineItemCreativeAssociation 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\LineItemCreativeAssociationServiceClient; $creds = new ServiceAccountCredentials($scopes, $json); $options = new LineItemCreativeAssociationServiceClient(['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'.

batchActivateLineItemCreativeAssociations

Activate a list of LineItemCreativeAssociation objects.

The async variant is LineItemCreativeAssociationServiceClient::batchActivateLineItemCreativeAssociationsAsync() .

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

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\BatchActivateLineItemCreativeAssociationsResponse
Example
use Google\Ads\AdManager\V1\BatchActivateLineItemCreativeAssociationsRequest;
use Google\Ads\AdManager\V1\BatchActivateLineItemCreativeAssociationsResponse;
use Google\Ads\AdManager\V1\Client\LineItemCreativeAssociationServiceClient;
use Google\ApiCore\ApiException;

/**
 * @param string $formattedParent       The parent resource where `LineItemCreativeAssociations` will be
 *                                      activated. This request supports using the "-" character as a wildcard for
 *                                      resources that span across multiple LineItem parents. Format:
 *                                      `networks/{network_code}/lineItems/{line_item_id}` Format:
 *                                      `networks/{network_code}/lineItems/-`
 *                                      Please see {@see LineItemCreativeAssociationServiceClient::lineItemName()} for help formatting this field.
 * @param string $formattedNamesElement The names of the `LineItemCreativeAssociation` objects to
 *                                      activate. A maximum of 1000 objects can be activated in a batch. Format:
 *                                      `networks/{network_code}/lineItems/{line_item_id}/creatives/{creative_id}`
 *                                      Please see {@see LineItemCreativeAssociationServiceClient::lineItemCreativeAssociationName()} for help formatting this field.
 */
function batch_activate_line_item_creative_associations_sample(
    string $formattedParent,
    string $formattedNamesElement
): void {
    // Create a client.
    $lineItemCreativeAssociationServiceClient = new LineItemCreativeAssociationServiceClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var BatchActivateLineItemCreativeAssociationsResponse $response */
        $response = $lineItemCreativeAssociationServiceClient->batchActivateLineItemCreativeAssociations(
            $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 = LineItemCreativeAssociationServiceClient::lineItemName(
        '[NETWORK_CODE]',
        '[LINE_ITEM]'
    );
    $formattedNamesElement = LineItemCreativeAssociationServiceClient::lineItemCreativeAssociationName(
        '[NETWORK_CODE]',
        '[LINE_ITEM]',
        '[CREATIVE]'
    );

    batch_activate_line_item_creative_associations_sample($formattedParent, $formattedNamesElement);
}

batchCreateLineItemCreativeAssociations

Creates LineItemCreativeAssociation objects.

The async variant is LineItemCreativeAssociationServiceClient::batchCreateLineItemCreativeAssociationsAsync() .

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

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\BatchCreateLineItemCreativeAssociationsResponse
Example
use Google\Ads\AdManager\V1\BatchCreateLineItemCreativeAssociationsRequest;
use Google\Ads\AdManager\V1\BatchCreateLineItemCreativeAssociationsResponse;
use Google\Ads\AdManager\V1\Client\LineItemCreativeAssociationServiceClient;
use Google\Ads\AdManager\V1\CreateLineItemCreativeAssociationRequest;
use Google\Ads\AdManager\V1\LineItemCreativeAssociation;
use Google\ApiCore\ApiException;

/**
 * @param string $formattedParent                                      The parent resource where `LineItemCreativeAssociations` will be
 *                                                                     created. This request supports using the "-" character as a wildcard for
 *                                                                     resources that span across multiple LineItem parents. Format:
 *                                                                     `networks/{network_code}/lineItems/{line_item_id}` Format:
 *                                                                     `networks/{network_code}/lineItems/-`
 *                                                                     Please see {@see LineItemCreativeAssociationServiceClient::lineItemName()} for help formatting this field.
 * @param string $formattedRequestsParent                              The parent resource where this `LineItemCreativeAssociation` will
 *                                                                     be created. Format: `networks/{network_code}/lineItems/{line_item_id}`
 *                                                                     Please see {@see LineItemCreativeAssociationServiceClient::lineItemName()} for help formatting this field.
 * @param string $formattedRequestsLineItemCreativeAssociationLineItem Immutable. The [LineItem][google.ads.admanager.v1.LineItem] to
 *                                                                     which the LineItemCreativeAssociation belongs. Please see
 *                                                                     {@see LineItemCreativeAssociationServiceClient::lineItemName()} for help formatting this field.
 */
function batch_create_line_item_creative_associations_sample(
    string $formattedParent,
    string $formattedRequestsParent,
    string $formattedRequestsLineItemCreativeAssociationLineItem
): void {
    // Create a client.
    $lineItemCreativeAssociationServiceClient = new LineItemCreativeAssociationServiceClient();

    // Prepare the request message.
    $requestsLineItemCreativeAssociation = (new LineItemCreativeAssociation())
        ->setLineItem($formattedRequestsLineItemCreativeAssociationLineItem);
    $createLineItemCreativeAssociationRequest = (new CreateLineItemCreativeAssociationRequest())
        ->setParent($formattedRequestsParent)
        ->setLineItemCreativeAssociation($requestsLineItemCreativeAssociation);
    $requests = [$createLineItemCreativeAssociationRequest];
    $request = (new BatchCreateLineItemCreativeAssociationsRequest())
        ->setParent($formattedParent)
        ->setRequests($requests);

    // Call the API and handle any network failures.
    try {
        /** @var BatchCreateLineItemCreativeAssociationsResponse $response */
        $response = $lineItemCreativeAssociationServiceClient->batchCreateLineItemCreativeAssociations(
            $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 = LineItemCreativeAssociationServiceClient::lineItemName(
        '[NETWORK_CODE]',
        '[LINE_ITEM]'
    );
    $formattedRequestsParent = LineItemCreativeAssociationServiceClient::lineItemName(
        '[NETWORK_CODE]',
        '[LINE_ITEM]'
    );
    $formattedRequestsLineItemCreativeAssociationLineItem = LineItemCreativeAssociationServiceClient::lineItemName(
        '[NETWORK_CODE]',
        '[LINE_ITEM]'
    );

    batch_create_line_item_creative_associations_sample(
        $formattedParent,
        $formattedRequestsParent,
        $formattedRequestsLineItemCreativeAssociationLineItem
    );
}

batchDeactivateLineItemCreativeAssociations

Deactivates a list of LineItemCreativeAssociation objects.

The async variant is LineItemCreativeAssociationServiceClient::batchDeactivateLineItemCreativeAssociationsAsync() .

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

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\BatchDeactivateLineItemCreativeAssociationsResponse
Example
use Google\Ads\AdManager\V1\BatchDeactivateLineItemCreativeAssociationsRequest;
use Google\Ads\AdManager\V1\BatchDeactivateLineItemCreativeAssociationsResponse;
use Google\Ads\AdManager\V1\Client\LineItemCreativeAssociationServiceClient;
use Google\ApiCore\ApiException;

/**
 * @param string $formattedParent       The parent resource where `LineItemCreativeAssociations` will be
 *                                      deactivated.
 *                                      This request supports using the "-" character as a wildcard for resources
 *                                      that span across multiple LineItem parents.
 *                                      Format: `networks/{network_code}/lineItems/{line_item_id}`
 *                                      Format: `networks/{network_code}/lineItems/-`
 *                                      Please see {@see LineItemCreativeAssociationServiceClient::lineItemName()} for help formatting this field.
 * @param string $formattedNamesElement The names of the `LineItemCreativeAssociation` objects to
 *                                      deactivate. A maximum of 1000 objects can be deactivated in a batch.
 *                                      Format:
 *                                      `networks/{network_code}/lineItems/{line_item_id}/creatives/{creative_id}`
 *                                      Please see {@see LineItemCreativeAssociationServiceClient::lineItemCreativeAssociationName()} for help formatting this field.
 */
function batch_deactivate_line_item_creative_associations_sample(
    string $formattedParent,
    string $formattedNamesElement
): void {
    // Create a client.
    $lineItemCreativeAssociationServiceClient = new LineItemCreativeAssociationServiceClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var BatchDeactivateLineItemCreativeAssociationsResponse $response */
        $response = $lineItemCreativeAssociationServiceClient->batchDeactivateLineItemCreativeAssociations(
            $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 = LineItemCreativeAssociationServiceClient::lineItemName(
        '[NETWORK_CODE]',
        '[LINE_ITEM]'
    );
    $formattedNamesElement = LineItemCreativeAssociationServiceClient::lineItemCreativeAssociationName(
        '[NETWORK_CODE]',
        '[LINE_ITEM]',
        '[CREATIVE]'
    );

    batch_deactivate_line_item_creative_associations_sample($formattedParent, $formattedNamesElement);
}

batchDeleteLineItemCreativeAssociations

Deletes a list of LineItemCreativeAssociation objects.

The async variant is LineItemCreativeAssociationServiceClient::batchDeleteLineItemCreativeAssociationsAsync() .

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

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.

Example
use Google\Ads\AdManager\V1\BatchDeleteLineItemCreativeAssociationsRequest;
use Google\Ads\AdManager\V1\Client\LineItemCreativeAssociationServiceClient;
use Google\ApiCore\ApiException;

/**
 * @param string $formattedParent       The parent resource where `LineItemCreativeAssociations` will be
 *                                      deleted. This request supports using the "-" character as a wildcard for
 *                                      resources that span across multiple LineItem parents. Format:
 *                                      `networks/{network_code}/lineItems/{line_item_id}` Format:
 *                                      `networks/{network_code}/lineItems/-`
 *                                      Please see {@see LineItemCreativeAssociationServiceClient::lineItemName()} for help formatting this field.
 * @param string $formattedNamesElement The names of the `LineItemCreativeAssociation` objects to delete.
 *                                      A maximum of 1000 objects can be deleted in a batch.
 *                                      Format:
 *                                      `networks/{network_code}/lineItems/{line_item_id}/creatives/{creative_id}`
 *                                      Please see {@see LineItemCreativeAssociationServiceClient::lineItemCreativeAssociationName()} for help formatting this field.
 */
function batch_delete_line_item_creative_associations_sample(
    string $formattedParent,
    string $formattedNamesElement
): void {
    // Create a client.
    $lineItemCreativeAssociationServiceClient = new LineItemCreativeAssociationServiceClient();

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

    // Call the API and handle any network failures.
    try {
        $lineItemCreativeAssociationServiceClient->batchDeleteLineItemCreativeAssociations($request);
        printf('Call completed successfully.' . PHP_EOL);
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = LineItemCreativeAssociationServiceClient::lineItemName(
        '[NETWORK_CODE]',
        '[LINE_ITEM]'
    );
    $formattedNamesElement = LineItemCreativeAssociationServiceClient::lineItemCreativeAssociationName(
        '[NETWORK_CODE]',
        '[LINE_ITEM]',
        '[CREATIVE]'
    );

    batch_delete_line_item_creative_associations_sample($formattedParent, $formattedNamesElement);
}

batchUpdateLineItemCreativeAssociations

Batch updates LineItemCreativeAssociation objects.

The async variant is LineItemCreativeAssociationServiceClient::batchUpdateLineItemCreativeAssociationsAsync() .

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

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\BatchUpdateLineItemCreativeAssociationsResponse
Example
use Google\Ads\AdManager\V1\BatchUpdateLineItemCreativeAssociationsRequest;
use Google\Ads\AdManager\V1\BatchUpdateLineItemCreativeAssociationsResponse;
use Google\Ads\AdManager\V1\Client\LineItemCreativeAssociationServiceClient;
use Google\Ads\AdManager\V1\LineItemCreativeAssociation;
use Google\Ads\AdManager\V1\UpdateLineItemCreativeAssociationRequest;
use Google\ApiCore\ApiException;

/**
 * @param string $formattedParent                                      The parent resource where `LineItemCreativeAssociations` will be
 *                                                                     updated. This request supports using the "-" character as a wildcard for
 *                                                                     resources that span across multiple LineItem parents. Format:
 *                                                                     `networks/{network_code}/lineItems/{line_item_id}` Format:
 *                                                                     `networks/{network_code}/lineItems/-`
 *                                                                     Please see {@see LineItemCreativeAssociationServiceClient::lineItemName()} for help formatting this field.
 * @param string $formattedRequestsLineItemCreativeAssociationLineItem Immutable. The [LineItem][google.ads.admanager.v1.LineItem] to
 *                                                                     which the LineItemCreativeAssociation belongs. Please see
 *                                                                     {@see LineItemCreativeAssociationServiceClient::lineItemName()} for help formatting this field.
 */
function batch_update_line_item_creative_associations_sample(
    string $formattedParent,
    string $formattedRequestsLineItemCreativeAssociationLineItem
): void {
    // Create a client.
    $lineItemCreativeAssociationServiceClient = new LineItemCreativeAssociationServiceClient();

    // Prepare the request message.
    $requestsLineItemCreativeAssociation = (new LineItemCreativeAssociation())
        ->setLineItem($formattedRequestsLineItemCreativeAssociationLineItem);
    $updateLineItemCreativeAssociationRequest = (new UpdateLineItemCreativeAssociationRequest())
        ->setLineItemCreativeAssociation($requestsLineItemCreativeAssociation);
    $requests = [$updateLineItemCreativeAssociationRequest];
    $request = (new BatchUpdateLineItemCreativeAssociationsRequest())
        ->setParent($formattedParent)
        ->setRequests($requests);

    // Call the API and handle any network failures.
    try {
        /** @var BatchUpdateLineItemCreativeAssociationsResponse $response */
        $response = $lineItemCreativeAssociationServiceClient->batchUpdateLineItemCreativeAssociations(
            $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 = LineItemCreativeAssociationServiceClient::lineItemName(
        '[NETWORK_CODE]',
        '[LINE_ITEM]'
    );
    $formattedRequestsLineItemCreativeAssociationLineItem = LineItemCreativeAssociationServiceClient::lineItemName(
        '[NETWORK_CODE]',
        '[LINE_ITEM]'
    );

    batch_update_line_item_creative_associations_sample(
        $formattedParent,
        $formattedRequestsLineItemCreativeAssociationLineItem
    );
}

createLineItemCreativeAssociation

Creates a LineItemCreativeAssociation object.

The async variant is LineItemCreativeAssociationServiceClient::createLineItemCreativeAssociationAsync() .

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

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\LineItemCreativeAssociation
Example
use Google\Ads\AdManager\V1\Client\LineItemCreativeAssociationServiceClient;
use Google\Ads\AdManager\V1\CreateLineItemCreativeAssociationRequest;
use Google\Ads\AdManager\V1\LineItemCreativeAssociation;
use Google\ApiCore\ApiException;

/**
 * @param string $formattedParent                              The parent resource where this `LineItemCreativeAssociation` will
 *                                                             be created. Format: `networks/{network_code}/lineItems/{line_item_id}`
 *                                                             Please see {@see LineItemCreativeAssociationServiceClient::lineItemName()} for help formatting this field.
 * @param string $formattedLineItemCreativeAssociationLineItem Immutable. The [LineItem][google.ads.admanager.v1.LineItem] to
 *                                                             which the LineItemCreativeAssociation belongs. Please see
 *                                                             {@see LineItemCreativeAssociationServiceClient::lineItemName()} for help formatting this field.
 */
function create_line_item_creative_association_sample(
    string $formattedParent,
    string $formattedLineItemCreativeAssociationLineItem
): void {
    // Create a client.
    $lineItemCreativeAssociationServiceClient = new LineItemCreativeAssociationServiceClient();

    // Prepare the request message.
    $lineItemCreativeAssociation = (new LineItemCreativeAssociation())
        ->setLineItem($formattedLineItemCreativeAssociationLineItem);
    $request = (new CreateLineItemCreativeAssociationRequest())
        ->setParent($formattedParent)
        ->setLineItemCreativeAssociation($lineItemCreativeAssociation);

    // Call the API and handle any network failures.
    try {
        /** @var LineItemCreativeAssociation $response */
        $response = $lineItemCreativeAssociationServiceClient->createLineItemCreativeAssociation($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 = LineItemCreativeAssociationServiceClient::lineItemName(
        '[NETWORK_CODE]',
        '[LINE_ITEM]'
    );
    $formattedLineItemCreativeAssociationLineItem = LineItemCreativeAssociationServiceClient::lineItemName(
        '[NETWORK_CODE]',
        '[LINE_ITEM]'
    );

    create_line_item_creative_association_sample(
        $formattedParent,
        $formattedLineItemCreativeAssociationLineItem
    );
}

getLineItemCreativeAssociation

Retrieves a LineItemCreativeAssociation object.

The async variant is LineItemCreativeAssociationServiceClient::getLineItemCreativeAssociationAsync() .

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

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\LineItemCreativeAssociation
Example
use Google\Ads\AdManager\V1\Client\LineItemCreativeAssociationServiceClient;
use Google\Ads\AdManager\V1\GetLineItemCreativeAssociationRequest;
use Google\Ads\AdManager\V1\LineItemCreativeAssociation;
use Google\ApiCore\ApiException;

/**
 * @param string $formattedName The resource name of the LineItemCreativeAssociation.
 *                              Format:
 *                              `networks/{network_code}/lineItems/{line_item_id}/creatives/{creative_id}`
 *                              Please see {@see LineItemCreativeAssociationServiceClient::lineItemCreativeAssociationName()} for help formatting this field.
 */
function get_line_item_creative_association_sample(string $formattedName): void
{
    // Create a client.
    $lineItemCreativeAssociationServiceClient = new LineItemCreativeAssociationServiceClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var LineItemCreativeAssociation $response */
        $response = $lineItemCreativeAssociationServiceClient->getLineItemCreativeAssociation($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 = LineItemCreativeAssociationServiceClient::lineItemCreativeAssociationName(
        '[NETWORK_CODE]',
        '[LINE_ITEM]',
        '[CREATIVE]'
    );

    get_line_item_creative_association_sample($formattedName);
}

listLineItemCreativeAssociations

Lists LineItemCreativeAssociation objects.

The async variant is LineItemCreativeAssociationServiceClient::listLineItemCreativeAssociationsAsync() .

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

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\LineItemCreativeAssociationServiceClient;
use Google\Ads\AdManager\V1\ListLineItemCreativeAssociationsRequest;
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;

/**
 * @param string $formattedParent The parent, which owns this collection of
 *                                LineItemCreativeAssociations. This request supports using the "-" character
 *                                as a wildcard for resources that span across multiple LineItem parents.
 *                                Format: `networks/{network_code}/lineItems/{line_item_id}`
 *                                Format: `networks/{network_code}/lineItems/-`
 *                                Please see {@see LineItemCreativeAssociationServiceClient::lineItemName()} for help formatting this field.
 */
function list_line_item_creative_associations_sample(string $formattedParent): void
{
    // Create a client.
    $lineItemCreativeAssociationServiceClient = new LineItemCreativeAssociationServiceClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $lineItemCreativeAssociationServiceClient->listLineItemCreativeAssociations($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 = LineItemCreativeAssociationServiceClient::lineItemName(
        '[NETWORK_CODE]',
        '[LINE_ITEM]'
    );

    list_line_item_creative_associations_sample($formattedParent);
}

previewLineItemCreativeAssociation

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

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\PreviewLineItemCreativeAssociationResponse
Example
use Google\Ads\AdManager\V1\Client\LineItemCreativeAssociationServiceClient;
use Google\Ads\AdManager\V1\PreviewLineItemCreativeAssociationRequest;
use Google\Ads\AdManager\V1\PreviewLineItemCreativeAssociationResponse;
use Google\ApiCore\ApiException;

/**
 * @param string $formattedName The name of the `LineItemCreativeAssociation` object to preview.
 *                              Format:
 *                              `networks/{network_code}/lineItems/{line_item_id}/creatives/{creative_id}`
 *                              Please see {@see LineItemCreativeAssociationServiceClient::lineItemCreativeAssociationName()} for help formatting this field.
 * @param string $siteUrl       The URL of the site that the creative should be previewed in
 */
function preview_line_item_creative_association_sample(
    string $formattedName,
    string $siteUrl
): void {
    // Create a client.
    $lineItemCreativeAssociationServiceClient = new LineItemCreativeAssociationServiceClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var PreviewLineItemCreativeAssociationResponse $response */
        $response = $lineItemCreativeAssociationServiceClient->previewLineItemCreativeAssociation($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 = LineItemCreativeAssociationServiceClient::lineItemCreativeAssociationName(
        '[NETWORK_CODE]',
        '[LINE_ITEM]',
        '[CREATIVE]'
    );
    $siteUrl = '[SITE_URL]';

    preview_line_item_creative_association_sample($formattedName, $siteUrl);
}

updateLineItemCreativeAssociation

Updates a LineItemCreativeAssociation object.

The async variant is LineItemCreativeAssociationServiceClient::updateLineItemCreativeAssociationAsync() .

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

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\LineItemCreativeAssociation
Example
use Google\Ads\AdManager\V1\Client\LineItemCreativeAssociationServiceClient;
use Google\Ads\AdManager\V1\LineItemCreativeAssociation;
use Google\Ads\AdManager\V1\UpdateLineItemCreativeAssociationRequest;
use Google\ApiCore\ApiException;

/**
 * @param string $formattedLineItemCreativeAssociationLineItem Immutable. The [LineItem][google.ads.admanager.v1.LineItem] to
 *                                                             which the LineItemCreativeAssociation belongs. Please see
 *                                                             {@see LineItemCreativeAssociationServiceClient::lineItemName()} for help formatting this field.
 */
function update_line_item_creative_association_sample(
    string $formattedLineItemCreativeAssociationLineItem
): void {
    // Create a client.
    $lineItemCreativeAssociationServiceClient = new LineItemCreativeAssociationServiceClient();

    // Prepare the request message.
    $lineItemCreativeAssociation = (new LineItemCreativeAssociation())
        ->setLineItem($formattedLineItemCreativeAssociationLineItem);
    $request = (new UpdateLineItemCreativeAssociationRequest())
        ->setLineItemCreativeAssociation($lineItemCreativeAssociation);

    // Call the API and handle any network failures.
    try {
        /** @var LineItemCreativeAssociation $response */
        $response = $lineItemCreativeAssociationServiceClient->updateLineItemCreativeAssociation($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
{
    $formattedLineItemCreativeAssociationLineItem = LineItemCreativeAssociationServiceClient::lineItemName(
        '[NETWORK_CODE]',
        '[LINE_ITEM]'
    );

    update_line_item_creative_association_sample($formattedLineItemCreativeAssociationLineItem);
}

batchActivateLineItemCreativeAssociationsAsync

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

batchCreateLineItemCreativeAssociationsAsync

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

batchDeactivateLineItemCreativeAssociationsAsync

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

batchDeleteLineItemCreativeAssociationsAsync

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

batchUpdateLineItemCreativeAssociationsAsync

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

createLineItemCreativeAssociationAsync

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

getLineItemCreativeAssociationAsync

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

listLineItemCreativeAssociationsAsync

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

previewLineItemCreativeAssociationAsync

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

updateLineItemCreativeAssociationAsync

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

static::creativeName

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

Parameters
Name Description
networkCode string
creative string
Returns
Type Description
string The formatted creative resource.

static::creativeSetName

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

Parameters
Name Description
networkCode string
creativeSet string
Returns
Type Description
string The formatted creative_set resource.

static::lineItemName

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

Parameters
Name Description
networkCode string
lineItem string
Returns
Type Description
string The formatted line_item resource.

static::lineItemCreativeAssociationName

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

Parameters
Name Description
networkCode string
lineItem string
creative string
Returns
Type Description
string The formatted line_item_creative_association 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

  • creative: networks/{network_code}/creatives/{creative}
  • creativeSet: networks/{network_code}/creativeSets/{creative_set}
  • lineItem: networks/{network_code}/lineItems/{line_item}
  • lineItemCreativeAssociation: networks/{network_code}/lineItems/{line_item}/creatives/{creative}

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.