Google Ads Data Manager V1 Client - Class IngestionServiceClient (0.1.0)

Reference documentation and code samples for the Google Ads Data Manager V1 Client class IngestionServiceClient.

Service Description: Service for sending audience data to supported destinations.

This class provides the ability to make remote calls to the backing service through method calls that map to API methods.

Namespace

Google \ Ads \ DataManager \ 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 FetchAuthTokenInterface|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\DataManager\V1\IngestionServiceClient; $creds = new ServiceAccountCredentials($scopes, $json); $options = new IngestionServiceClient(['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|TransportInterface

The transport used for executing network requests. May be either the string rest or grpc. Defaults to grpc if gRPC support is detected on the system. 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 = [ 'grpc' => [...], 'rest' => [...], ]; See the Google\ApiCore\Transport\GrpcTransport::build() and Google\ApiCore\Transport\RestTransport::build() methods for the supported options.

↳ clientCertSource callable

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

↳ logger false|LoggerInterface

A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the 'GOOGLE_SDK_PHP_LOGGING' environment flag

↳ universeDomain string

The service domain for the client. Defaults to 'googleapis.com'.

ingestAudienceMembers

Uploads a list of AudienceMember resources to the provided Destination.

The async variant is IngestionServiceClient::ingestAudienceMembersAsync() .

Parameters
Name Description
request Google\Ads\DataManager\V1\IngestAudienceMembersRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Ads\DataManager\V1\IngestAudienceMembersResponse
Example
use Google\Ads\DataManager\V1\AudienceMember;
use Google\Ads\DataManager\V1\Client\IngestionServiceClient;
use Google\Ads\DataManager\V1\Destination;
use Google\Ads\DataManager\V1\IngestAudienceMembersRequest;
use Google\Ads\DataManager\V1\IngestAudienceMembersResponse;
use Google\Ads\DataManager\V1\ProductAccount;
use Google\ApiCore\ApiException;

/**
 * @param string $destinationsOperatingAccountAccountId The ID of the account. For example, your Google Ads account ID.
 * @param string $destinationsProductDestinationId      The object within the product account to ingest into. For
 *                                                      example, a Google Ads audience ID, a Display & Video 360 audience ID or a
 *                                                      Google Ads conversion action ID.
 */
function ingest_audience_members_sample(
    string $destinationsOperatingAccountAccountId,
    string $destinationsProductDestinationId
): void {
    // Create a client.
    $ingestionServiceClient = new IngestionServiceClient();

    // Prepare the request message.
    $destinationsOperatingAccount = (new ProductAccount())
        ->setAccountId($destinationsOperatingAccountAccountId);
    $destination = (new Destination())
        ->setOperatingAccount($destinationsOperatingAccount)
        ->setProductDestinationId($destinationsProductDestinationId);
    $destinations = [$destination,];
    $audienceMembers = [new AudienceMember()];
    $request = (new IngestAudienceMembersRequest())
        ->setDestinations($destinations)
        ->setAudienceMembers($audienceMembers);

    // Call the API and handle any network failures.
    try {
        /** @var IngestAudienceMembersResponse $response */
        $response = $ingestionServiceClient->ingestAudienceMembers($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
{
    $destinationsOperatingAccountAccountId = '[ACCOUNT_ID]';
    $destinationsProductDestinationId = '[PRODUCT_DESTINATION_ID]';

    ingest_audience_members_sample(
        $destinationsOperatingAccountAccountId,
        $destinationsProductDestinationId
    );
}

ingestEvents

Uploads a list of Event resources from the provided Destination.

The async variant is IngestionServiceClient::ingestEventsAsync() .

Parameters
Name Description
request Google\Ads\DataManager\V1\IngestEventsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Ads\DataManager\V1\IngestEventsResponse
Example
use Google\Ads\DataManager\V1\Client\IngestionServiceClient;
use Google\Ads\DataManager\V1\Destination;
use Google\Ads\DataManager\V1\Event;
use Google\Ads\DataManager\V1\IngestEventsRequest;
use Google\Ads\DataManager\V1\IngestEventsResponse;
use Google\Ads\DataManager\V1\ProductAccount;
use Google\ApiCore\ApiException;
use Google\Protobuf\Timestamp;

/**
 * @param string $destinationsOperatingAccountAccountId The ID of the account. For example, your Google Ads account ID.
 * @param string $destinationsProductDestinationId      The object within the product account to ingest into. For
 *                                                      example, a Google Ads audience ID, a Display & Video 360 audience ID or a
 *                                                      Google Ads conversion action ID.
 */
function ingest_events_sample(
    string $destinationsOperatingAccountAccountId,
    string $destinationsProductDestinationId
): void {
    // Create a client.
    $ingestionServiceClient = new IngestionServiceClient();

    // Prepare the request message.
    $destinationsOperatingAccount = (new ProductAccount())
        ->setAccountId($destinationsOperatingAccountAccountId);
    $destination = (new Destination())
        ->setOperatingAccount($destinationsOperatingAccount)
        ->setProductDestinationId($destinationsProductDestinationId);
    $destinations = [$destination,];
    $eventsEventTimestamp = new Timestamp();
    $event = (new Event())
        ->setEventTimestamp($eventsEventTimestamp);
    $events = [$event,];
    $request = (new IngestEventsRequest())
        ->setDestinations($destinations)
        ->setEvents($events);

    // Call the API and handle any network failures.
    try {
        /** @var IngestEventsResponse $response */
        $response = $ingestionServiceClient->ingestEvents($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
{
    $destinationsOperatingAccountAccountId = '[ACCOUNT_ID]';
    $destinationsProductDestinationId = '[PRODUCT_DESTINATION_ID]';

    ingest_events_sample($destinationsOperatingAccountAccountId, $destinationsProductDestinationId);
}

removeAudienceMembers

Removes a list of AudienceMember resources from the provided Destination.

The async variant is IngestionServiceClient::removeAudienceMembersAsync() .

Parameters
Name Description
request Google\Ads\DataManager\V1\RemoveAudienceMembersRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Ads\DataManager\V1\RemoveAudienceMembersResponse
Example
use Google\Ads\DataManager\V1\AudienceMember;
use Google\Ads\DataManager\V1\Client\IngestionServiceClient;
use Google\Ads\DataManager\V1\Destination;
use Google\Ads\DataManager\V1\ProductAccount;
use Google\Ads\DataManager\V1\RemoveAudienceMembersRequest;
use Google\Ads\DataManager\V1\RemoveAudienceMembersResponse;
use Google\ApiCore\ApiException;

/**
 * @param string $destinationsOperatingAccountAccountId The ID of the account. For example, your Google Ads account ID.
 * @param string $destinationsProductDestinationId      The object within the product account to ingest into. For
 *                                                      example, a Google Ads audience ID, a Display & Video 360 audience ID or a
 *                                                      Google Ads conversion action ID.
 */
function remove_audience_members_sample(
    string $destinationsOperatingAccountAccountId,
    string $destinationsProductDestinationId
): void {
    // Create a client.
    $ingestionServiceClient = new IngestionServiceClient();

    // Prepare the request message.
    $destinationsOperatingAccount = (new ProductAccount())
        ->setAccountId($destinationsOperatingAccountAccountId);
    $destination = (new Destination())
        ->setOperatingAccount($destinationsOperatingAccount)
        ->setProductDestinationId($destinationsProductDestinationId);
    $destinations = [$destination,];
    $audienceMembers = [new AudienceMember()];
    $request = (new RemoveAudienceMembersRequest())
        ->setDestinations($destinations)
        ->setAudienceMembers($audienceMembers);

    // Call the API and handle any network failures.
    try {
        /** @var RemoveAudienceMembersResponse $response */
        $response = $ingestionServiceClient->removeAudienceMembers($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
{
    $destinationsOperatingAccountAccountId = '[ACCOUNT_ID]';
    $destinationsProductDestinationId = '[PRODUCT_DESTINATION_ID]';

    remove_audience_members_sample(
        $destinationsOperatingAccountAccountId,
        $destinationsProductDestinationId
    );
}

retrieveRequestStatus

Gets the status of a request given request id.

The async variant is IngestionServiceClient::retrieveRequestStatusAsync() .

Parameters
Name Description
request Google\Ads\DataManager\V1\RetrieveRequestStatusRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Ads\DataManager\V1\RetrieveRequestStatusResponse
Example
use Google\Ads\DataManager\V1\Client\IngestionServiceClient;
use Google\Ads\DataManager\V1\RetrieveRequestStatusRequest;
use Google\Ads\DataManager\V1\RetrieveRequestStatusResponse;
use Google\ApiCore\ApiException;

/**
 * @param string $requestId Required. The request ID of the Data Manager API request.
 */
function retrieve_request_status_sample(string $requestId): void
{
    // Create a client.
    $ingestionServiceClient = new IngestionServiceClient();

    // Prepare the request message.
    $request = (new RetrieveRequestStatusRequest())
        ->setRequestId($requestId);

    // Call the API and handle any network failures.
    try {
        /** @var RetrieveRequestStatusResponse $response */
        $response = $ingestionServiceClient->retrieveRequestStatus($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
{
    $requestId = '[REQUEST_ID]';

    retrieve_request_status_sample($requestId);
}

ingestAudienceMembersAsync

Parameters
Name Description
request Google\Ads\DataManager\V1\IngestAudienceMembersRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Ads\DataManager\V1\IngestAudienceMembersResponse>

ingestEventsAsync

Parameters
Name Description
request Google\Ads\DataManager\V1\IngestEventsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Ads\DataManager\V1\IngestEventsResponse>

removeAudienceMembersAsync

Parameters
Name Description
request Google\Ads\DataManager\V1\RemoveAudienceMembersRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Ads\DataManager\V1\RemoveAudienceMembersResponse>

retrieveRequestStatusAsync

Parameters
Name Description
request Google\Ads\DataManager\V1\RetrieveRequestStatusRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Ads\DataManager\V1\RetrieveRequestStatusResponse>