Google Ads Ad Manager V1 Client - Class NativeStyleServiceClient (0.14.1)

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

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

batchActivateNativeStyles

Beginning of non-CRUD Activates a list of NativeStyle objects.

The async variant is NativeStyleServiceClient::batchActivateNativeStylesAsync() .

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

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\BatchActivateNativeStylesResponse
Example
use Google\Ads\AdManager\V1\BatchActivateNativeStylesRequest;
use Google\Ads\AdManager\V1\BatchActivateNativeStylesResponse;
use Google\Ads\AdManager\V1\Client\NativeStyleServiceClient;
use Google\ApiCore\ApiException;

/**
 * @param string $formattedParent       Format: `networks/{network_code}`
 *                                      Please see {@see NativeStyleServiceClient::networkName()} for help formatting this field.
 * @param string $formattedNamesElement Resource names for the `NativeStyle`s.
 *                                      Format: `networks/{network_code}/nativeStyles/{native_style_id}`
 *                                      Please see {@see NativeStyleServiceClient::nativeStyleName()} for help formatting this field.
 */
function batch_activate_native_styles_sample(
    string $formattedParent,
    string $formattedNamesElement
): void {
    // Create a client.
    $nativeStyleServiceClient = new NativeStyleServiceClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var BatchActivateNativeStylesResponse $response */
        $response = $nativeStyleServiceClient->batchActivateNativeStyles($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 = NativeStyleServiceClient::networkName('[NETWORK_CODE]');
    $formattedNamesElement = NativeStyleServiceClient::nativeStyleName(
        '[NETWORK_CODE]',
        '[NATIVE_STYLE]'
    );

    batch_activate_native_styles_sample($formattedParent, $formattedNamesElement);
}

batchArchiveNativeStyles

Archives a list of NativeStyle objects.

The async variant is NativeStyleServiceClient::batchArchiveNativeStylesAsync() .

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

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\BatchArchiveNativeStylesResponse
Example
use Google\Ads\AdManager\V1\BatchArchiveNativeStylesRequest;
use Google\Ads\AdManager\V1\BatchArchiveNativeStylesResponse;
use Google\Ads\AdManager\V1\Client\NativeStyleServiceClient;
use Google\ApiCore\ApiException;

/**
 * @param string $formattedParent       Format: `networks/{network_code}`
 *                                      Please see {@see NativeStyleServiceClient::networkName()} for help formatting this field.
 * @param string $formattedNamesElement Resource names for the `NativeStyle`s.
 *                                      Format: `networks/{network_code}/nativeStyles/{native_style_id}`
 *                                      Please see {@see NativeStyleServiceClient::nativeStyleName()} for help formatting this field.
 */
function batch_archive_native_styles_sample(
    string $formattedParent,
    string $formattedNamesElement
): void {
    // Create a client.
    $nativeStyleServiceClient = new NativeStyleServiceClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var BatchArchiveNativeStylesResponse $response */
        $response = $nativeStyleServiceClient->batchArchiveNativeStyles($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 = NativeStyleServiceClient::networkName('[NETWORK_CODE]');
    $formattedNamesElement = NativeStyleServiceClient::nativeStyleName(
        '[NETWORK_CODE]',
        '[NATIVE_STYLE]'
    );

    batch_archive_native_styles_sample($formattedParent, $formattedNamesElement);
}

batchCreateNativeStyles

Creates NativeStyle objects.

The async variant is NativeStyleServiceClient::batchCreateNativeStylesAsync() .

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

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\BatchCreateNativeStylesResponse
Example
use Google\Ads\AdManager\V1\BatchCreateNativeStylesRequest;
use Google\Ads\AdManager\V1\BatchCreateNativeStylesResponse;
use Google\Ads\AdManager\V1\Client\NativeStyleServiceClient;
use Google\Ads\AdManager\V1\CreateNativeStyleRequest;
use Google\Ads\AdManager\V1\NativeStyle;
use Google\Ads\AdManager\V1\Size;
use Google\Ads\AdManager\V1\SizeTypeEnum\SizeType;
use Google\ApiCore\ApiException;

/**
 * @param string $formattedParent                              The parent resource where `NativeStyles` will be created.
 *                                                             Format: `networks/{network_code}`
 *                                                             The parent field in the CreateNativeStyleRequest must match this
 *                                                             field. Please see
 *                                                             {@see NativeStyleServiceClient::networkName()} for help formatting this field.
 * @param string $formattedRequestsParent                      The parent resource where this `NativeStyle` will be created.
 *                                                             Format: `networks/{network_code}`
 *                                                             Please see {@see NativeStyleServiceClient::networkName()} for help formatting this field.
 * @param string $formattedRequestsNativeStyleCreativeTemplate Immutable. The creative template this native style is associated
 *                                                             with. Format:
 *                                                             "networks/{network_code}/creativeTemplates/{creative_template}"
 *                                                             Please see {@see NativeStyleServiceClient::creativeTemplateName()} for help formatting this field.
 * @param string $requestsNativeStyleDisplayName               The display name of the native style. This attribute has a
 *                                                             maximum length of 255 characters.
 * @param int    $requestsNativeStyleSizeWidth                 The width of the Creative,
 *                                                             [AdUnit][google.ads.admanager.v1.AdUnit], or LineItem.
 * @param int    $requestsNativeStyleSizeHeight                The height of the Creative,
 *                                                             [AdUnit][google.ads.admanager.v1.AdUnit], or LineItem.
 * @param int    $requestsNativeStyleSizeSizeType              The SizeType of the Creative,
 *                                                             [AdUnit][google.ads.admanager.v1.AdUnit], or LineItem.
 */
function batch_create_native_styles_sample(
    string $formattedParent,
    string $formattedRequestsParent,
    string $formattedRequestsNativeStyleCreativeTemplate,
    string $requestsNativeStyleDisplayName,
    int $requestsNativeStyleSizeWidth,
    int $requestsNativeStyleSizeHeight,
    int $requestsNativeStyleSizeSizeType
): void {
    // Create a client.
    $nativeStyleServiceClient = new NativeStyleServiceClient();

    // Prepare the request message.
    $requestsNativeStyleSize = (new Size())
        ->setWidth($requestsNativeStyleSizeWidth)
        ->setHeight($requestsNativeStyleSizeHeight)
        ->setSizeType($requestsNativeStyleSizeSizeType);
    $requestsNativeStyle = (new NativeStyle())
        ->setCreativeTemplate($formattedRequestsNativeStyleCreativeTemplate)
        ->setDisplayName($requestsNativeStyleDisplayName)
        ->setSize($requestsNativeStyleSize);
    $createNativeStyleRequest = (new CreateNativeStyleRequest())
        ->setParent($formattedRequestsParent)
        ->setNativeStyle($requestsNativeStyle);
    $requests = [$createNativeStyleRequest,];
    $request = (new BatchCreateNativeStylesRequest())
        ->setParent($formattedParent)
        ->setRequests($requests);

    // Call the API and handle any network failures.
    try {
        /** @var BatchCreateNativeStylesResponse $response */
        $response = $nativeStyleServiceClient->batchCreateNativeStyles($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 = NativeStyleServiceClient::networkName('[NETWORK_CODE]');
    $formattedRequestsParent = NativeStyleServiceClient::networkName('[NETWORK_CODE]');
    $formattedRequestsNativeStyleCreativeTemplate = NativeStyleServiceClient::creativeTemplateName(
        '[NETWORK_CODE]',
        '[CREATIVE_TEMPLATE]'
    );
    $requestsNativeStyleDisplayName = '[DISPLAY_NAME]';
    $requestsNativeStyleSizeWidth = 0;
    $requestsNativeStyleSizeHeight = 0;
    $requestsNativeStyleSizeSizeType = SizeType::SIZE_TYPE_UNSPECIFIED;

    batch_create_native_styles_sample(
        $formattedParent,
        $formattedRequestsParent,
        $formattedRequestsNativeStyleCreativeTemplate,
        $requestsNativeStyleDisplayName,
        $requestsNativeStyleSizeWidth,
        $requestsNativeStyleSizeHeight,
        $requestsNativeStyleSizeSizeType
    );
}

batchDeactivateNativeStyles

Deactivates a list of NativeStyle objects.

The async variant is NativeStyleServiceClient::batchDeactivateNativeStylesAsync() .

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

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\BatchDeactivateNativeStylesResponse
Example
use Google\Ads\AdManager\V1\BatchDeactivateNativeStylesRequest;
use Google\Ads\AdManager\V1\BatchDeactivateNativeStylesResponse;
use Google\Ads\AdManager\V1\Client\NativeStyleServiceClient;
use Google\ApiCore\ApiException;

/**
 * @param string $formattedParent       Format: `networks/{network_code}`
 *                                      Please see {@see NativeStyleServiceClient::networkName()} for help formatting this field.
 * @param string $formattedNamesElement Resource names for the `NativeStyle`s.
 *                                      Format: `networks/{network_code}/nativeStyles/{native_style_id}`
 *                                      Please see {@see NativeStyleServiceClient::nativeStyleName()} for help formatting this field.
 */
function batch_deactivate_native_styles_sample(
    string $formattedParent,
    string $formattedNamesElement
): void {
    // Create a client.
    $nativeStyleServiceClient = new NativeStyleServiceClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var BatchDeactivateNativeStylesResponse $response */
        $response = $nativeStyleServiceClient->batchDeactivateNativeStyles($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 = NativeStyleServiceClient::networkName('[NETWORK_CODE]');
    $formattedNamesElement = NativeStyleServiceClient::nativeStyleName(
        '[NETWORK_CODE]',
        '[NATIVE_STYLE]'
    );

    batch_deactivate_native_styles_sample($formattedParent, $formattedNamesElement);
}

batchUpdateNativeStyles

Batch updates NativeStyle objects.

The async variant is NativeStyleServiceClient::batchUpdateNativeStylesAsync() .

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

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\BatchUpdateNativeStylesResponse
Example
use Google\Ads\AdManager\V1\BatchUpdateNativeStylesRequest;
use Google\Ads\AdManager\V1\BatchUpdateNativeStylesResponse;
use Google\Ads\AdManager\V1\Client\NativeStyleServiceClient;
use Google\Ads\AdManager\V1\NativeStyle;
use Google\Ads\AdManager\V1\Size;
use Google\Ads\AdManager\V1\SizeTypeEnum\SizeType;
use Google\Ads\AdManager\V1\UpdateNativeStyleRequest;
use Google\ApiCore\ApiException;

/**
 * @param string $formattedParent                              The parent resource where `NativeStyles` will be updated.
 *                                                             Format: `networks/{network_code}`
 *                                                             The parent field in the UpdateNativeStyleRequest must match this
 *                                                             field. Please see
 *                                                             {@see NativeStyleServiceClient::networkName()} for help formatting this field.
 * @param string $formattedRequestsNativeStyleCreativeTemplate Immutable. The creative template this native style is associated
 *                                                             with. Format:
 *                                                             "networks/{network_code}/creativeTemplates/{creative_template}"
 *                                                             Please see {@see NativeStyleServiceClient::creativeTemplateName()} for help formatting this field.
 * @param string $requestsNativeStyleDisplayName               The display name of the native style. This attribute has a
 *                                                             maximum length of 255 characters.
 * @param int    $requestsNativeStyleSizeWidth                 The width of the Creative,
 *                                                             [AdUnit][google.ads.admanager.v1.AdUnit], or LineItem.
 * @param int    $requestsNativeStyleSizeHeight                The height of the Creative,
 *                                                             [AdUnit][google.ads.admanager.v1.AdUnit], or LineItem.
 * @param int    $requestsNativeStyleSizeSizeType              The SizeType of the Creative,
 *                                                             [AdUnit][google.ads.admanager.v1.AdUnit], or LineItem.
 */
function batch_update_native_styles_sample(
    string $formattedParent,
    string $formattedRequestsNativeStyleCreativeTemplate,
    string $requestsNativeStyleDisplayName,
    int $requestsNativeStyleSizeWidth,
    int $requestsNativeStyleSizeHeight,
    int $requestsNativeStyleSizeSizeType
): void {
    // Create a client.
    $nativeStyleServiceClient = new NativeStyleServiceClient();

    // Prepare the request message.
    $requestsNativeStyleSize = (new Size())
        ->setWidth($requestsNativeStyleSizeWidth)
        ->setHeight($requestsNativeStyleSizeHeight)
        ->setSizeType($requestsNativeStyleSizeSizeType);
    $requestsNativeStyle = (new NativeStyle())
        ->setCreativeTemplate($formattedRequestsNativeStyleCreativeTemplate)
        ->setDisplayName($requestsNativeStyleDisplayName)
        ->setSize($requestsNativeStyleSize);
    $updateNativeStyleRequest = (new UpdateNativeStyleRequest())
        ->setNativeStyle($requestsNativeStyle);
    $requests = [$updateNativeStyleRequest,];
    $request = (new BatchUpdateNativeStylesRequest())
        ->setParent($formattedParent)
        ->setRequests($requests);

    // Call the API and handle any network failures.
    try {
        /** @var BatchUpdateNativeStylesResponse $response */
        $response = $nativeStyleServiceClient->batchUpdateNativeStyles($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 = NativeStyleServiceClient::networkName('[NETWORK_CODE]');
    $formattedRequestsNativeStyleCreativeTemplate = NativeStyleServiceClient::creativeTemplateName(
        '[NETWORK_CODE]',
        '[CREATIVE_TEMPLATE]'
    );
    $requestsNativeStyleDisplayName = '[DISPLAY_NAME]';
    $requestsNativeStyleSizeWidth = 0;
    $requestsNativeStyleSizeHeight = 0;
    $requestsNativeStyleSizeSizeType = SizeType::SIZE_TYPE_UNSPECIFIED;

    batch_update_native_styles_sample(
        $formattedParent,
        $formattedRequestsNativeStyleCreativeTemplate,
        $requestsNativeStyleDisplayName,
        $requestsNativeStyleSizeWidth,
        $requestsNativeStyleSizeHeight,
        $requestsNativeStyleSizeSizeType
    );
}

getNativeStyle

Retrieves a NativeStyle object.

The async variant is NativeStyleServiceClient::getNativeStyleAsync() .

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

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\NativeStyle
Example
use Google\Ads\AdManager\V1\Client\NativeStyleServiceClient;
use Google\Ads\AdManager\V1\GetNativeStyleRequest;
use Google\Ads\AdManager\V1\NativeStyle;
use Google\ApiCore\ApiException;

/**
 * @param string $formattedName The resource name of the NativeStyle.
 *                              Format: `networks/{network_code}/nativeStyles/{native_style_id}`
 *                              Please see {@see NativeStyleServiceClient::nativeStyleName()} for help formatting this field.
 */
function get_native_style_sample(string $formattedName): void
{
    // Create a client.
    $nativeStyleServiceClient = new NativeStyleServiceClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var NativeStyle $response */
        $response = $nativeStyleServiceClient->getNativeStyle($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 = NativeStyleServiceClient::nativeStyleName('[NETWORK_CODE]', '[NATIVE_STYLE]');

    get_native_style_sample($formattedName);
}

listNativeStyles

Lists NativeStyle objects.

The async variant is NativeStyleServiceClient::listNativeStylesAsync() .

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

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

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

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

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

    list_native_styles_sample($formattedParent);
}

batchActivateNativeStylesAsync

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

batchArchiveNativeStylesAsync

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

batchCreateNativeStylesAsync

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

batchDeactivateNativeStylesAsync

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

batchUpdateNativeStylesAsync

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

getNativeStyleAsync

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

listNativeStylesAsync

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

static::adUnitName

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

Parameters
Name Description
networkCode string
adUnit string
Returns
Type Description
string The formatted ad_unit resource.

static::applicationName

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

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

static::audienceSegmentName

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

Parameters
Name Description
networkCode string
audienceSegment string
Returns
Type Description
string The formatted audience_segment resource.

static::bandwidthGroupName

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

Parameters
Name Description
networkCode string
bandwidthGroup string
Returns
Type Description
string The formatted bandwidth_group resource.

static::browserName

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

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

static::browserLanguageName

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

Parameters
Name Description
networkCode string
browserLanguage string
Returns
Type Description
string The formatted browser_language resource.

static::cmsMetadataValueName

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

Parameters
Name Description
networkCode string
cmsMetadataValue string
Returns
Type Description
string The formatted cms_metadata_value resource.

static::contentName

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

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

static::contentBundleName

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

Parameters
Name Description
networkCode string
contentBundle string
Returns
Type Description
string The formatted content_bundle resource.

static::creativeTemplateName

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

Parameters
Name Description
networkCode string
creativeTemplate string
Returns
Type Description
string The formatted creative_template resource.

static::customTargetingKeyName

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

Parameters
Name Description
networkCode string
customTargetingKey string
Returns
Type Description
string The formatted custom_targeting_key resource.

static::customTargetingValueName

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

Parameters
Name Description
networkCode string
customTargetingValue string
Returns
Type Description
string The formatted custom_targeting_value resource.

static::deviceCapabilityName

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

Parameters
Name Description
networkCode string
deviceCapability string
Returns
Type Description
string The formatted device_capability resource.

static::deviceCategoryName

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

Parameters
Name Description
networkCode string
deviceCategory string
Returns
Type Description
string The formatted device_category resource.

static::deviceManufacturerName

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

Parameters
Name Description
networkCode string
deviceManufacturer string
Returns
Type Description
string The formatted device_manufacturer resource.

static::geoTargetName

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

Parameters
Name Description
networkCode string
geoTarget string
Returns
Type Description
string The formatted geo_target resource.

static::mobileCarrierName

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

Parameters
Name Description
networkCode string
mobileCarrier string
Returns
Type Description
string The formatted mobile_carrier resource.

static::mobileDeviceName

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

Parameters
Name Description
networkCode string
mobileDevice string
Returns
Type Description
string The formatted mobile_device resource.

static::mobileDeviceSubmodelName

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

Parameters
Name Description
networkCode string
mobileDeviceSubmodel string
Returns
Type Description
string The formatted mobile_device_submodel resource.

static::nativeStyleName

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

Parameters
Name Description
networkCode string
nativeStyle string
Returns
Type Description
string The formatted native_style 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::operatingSystemName

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

Parameters
Name Description
networkCode string
operatingSystem string
Returns
Type Description
string The formatted operating_system resource.

static::operatingSystemVersionName

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

Parameters
Name Description
networkCode string
operatingSystemVersion string
Returns
Type Description
string The formatted operating_system_version resource.

static::placementName

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

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

  • adUnit: networks/{network_code}/adUnits/{ad_unit}
  • application: networks/{network_code}/applications/{application}
  • audienceSegment: networks/{network_code}/audienceSegments/{audience_segment}
  • bandwidthGroup: networks/{network_code}/bandwidthGroups/{bandwidth_group}
  • browser: networks/{network_code}/browsers/{browser}
  • browserLanguage: networks/{network_code}/browserLanguages/{browser_language}
  • cmsMetadataValue: networks/{network_code}/cmsMetadataValues/{cms_metadata_value}
  • content: networks/{network_code}/content/{content}
  • contentBundle: networks/{network_code}/contentBundles/{content_bundle}
  • creativeTemplate: networks/{network_code}/creativeTemplates/{creative_template}
  • customTargetingKey: networks/{network_code}/customTargetingKeys/{custom_targeting_key}
  • customTargetingValue: networks/{network_code}/customTargetingValues/{custom_targeting_value}
  • deviceCapability: networks/{network_code}/deviceCapabilities/{device_capability}
  • deviceCategory: networks/{network_code}/deviceCategories/{device_category}
  • deviceManufacturer: networks/{network_code}/deviceManufacturers/{device_manufacturer}
  • geoTarget: networks/{network_code}/geoTargets/{geo_target}
  • mobileCarrier: networks/{network_code}/mobileCarriers/{mobile_carrier}
  • mobileDevice: networks/{network_code}/mobileDevices/{mobile_device}
  • mobileDeviceSubmodel: networks/{network_code}/mobileDeviceSubmodels/{mobile_device_submodel}
  • nativeStyle: networks/{network_code}/nativeStyles/{native_style}
  • network: networks/{network_code}
  • operatingSystem: networks/{network_code}/operatingSystems/{operating_system}
  • operatingSystemVersion: networks/{network_code}/operatingSystemVersions/{operating_system_version}
  • placement: networks/{network_code}/placements/{placement}

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.