Google Cloud Dataplex V1 Client - Class DataProductServiceClient (1.12.0)

Reference documentation and code samples for the Google Cloud Dataplex V1 Client class DataProductServiceClient.

Service Description: DataProductService provides APIs for managing data products and the underlying data assets.

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 \ Cloud \ Dataplex \ 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\Cloud\Dataplex\V1\DataProductServiceClient; $creds = new ServiceAccountCredentials($scopes, $json); $options = new DataProductServiceClient(['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'.

createDataAsset

Creates a data asset.

The async variant is DataProductServiceClient::createDataAssetAsync() .

Parameters
Name Description
request Google\Cloud\Dataplex\V1\CreateDataAssetRequest

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\ApiCore\OperationResponse<Google\Cloud\Dataplex\V1\DataAsset>
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Dataplex\V1\Client\DataProductServiceClient;
use Google\Cloud\Dataplex\V1\CreateDataAssetRequest;
use Google\Cloud\Dataplex\V1\DataAsset;
use Google\Rpc\Status;

/**
 * @param string $formattedParent   The parent resource where this data asset will be created.
 *                                  Format:
 *                                  projects/{project_id_or_number}/locations/{location_id}/dataProducts/{data_product_id}
 *                                  Please see {@see DataProductServiceClient::dataProductName()} for help formatting this field.
 * @param string $dataAssetResource Immutable. Full resource name of the cloud resource represented
 *                                  by the data asset. This must follow
 *                                  https://cloud.google.com/iam/docs/full-resource-names. Example:
 *                                  `//bigquery.googleapis.com/projects/my_project_123/datasets/dataset_456/tables/table_789`
 *                                  Only BigQuery tables and datasets are currently supported.
 *                                  Data asset creator must have getIamPolicy and setIamPolicy permissions on
 *                                  the resource. Data asset creator must also have resource specific get
 *                                  permission, for instance, bigquery.tables.get for BigQuery tables.
 */
function create_data_asset_sample(string $formattedParent, string $dataAssetResource): void
{
    // Create a client.
    $dataProductServiceClient = new DataProductServiceClient();

    // Prepare the request message.
    $dataAsset = (new DataAsset())
        ->setResource($dataAssetResource);
    $request = (new CreateDataAssetRequest())
        ->setParent($formattedParent)
        ->setDataAsset($dataAsset);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $dataProductServiceClient->createDataAsset($request);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var DataAsset $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->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 = DataProductServiceClient::dataProductName(
        '[PROJECT]',
        '[LOCATION]',
        '[DATA_PRODUCT]'
    );
    $dataAssetResource = '[RESOURCE]';

    create_data_asset_sample($formattedParent, $dataAssetResource);
}

createDataProduct

Creates a data product.

The async variant is DataProductServiceClient::createDataProductAsync() .

Parameters
Name Description
request Google\Cloud\Dataplex\V1\CreateDataProductRequest

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\ApiCore\OperationResponse<Google\Cloud\Dataplex\V1\DataProduct>
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Dataplex\V1\Client\DataProductServiceClient;
use Google\Cloud\Dataplex\V1\CreateDataProductRequest;
use Google\Cloud\Dataplex\V1\DataProduct;
use Google\Rpc\Status;

/**
 * @param string $formattedParent               The parent resource where this data product will be created.
 *                                              Format: projects/{project_id_or_number}/locations/{location_id}
 *                                              Please see {@see DataProductServiceClient::locationName()} for help formatting this field.
 * @param string $dataProductDisplayName        User-friendly display name of the data product.
 * @param string $dataProductOwnerEmailsElement Emails of the data product owners.
 */
function create_data_product_sample(
    string $formattedParent,
    string $dataProductDisplayName,
    string $dataProductOwnerEmailsElement
): void {
    // Create a client.
    $dataProductServiceClient = new DataProductServiceClient();

    // Prepare the request message.
    $dataProductOwnerEmails = [$dataProductOwnerEmailsElement,];
    $dataProduct = (new DataProduct())
        ->setDisplayName($dataProductDisplayName)
        ->setOwnerEmails($dataProductOwnerEmails);
    $request = (new CreateDataProductRequest())
        ->setParent($formattedParent)
        ->setDataProduct($dataProduct);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $dataProductServiceClient->createDataProduct($request);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var DataProduct $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->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 = DataProductServiceClient::locationName('[PROJECT]', '[LOCATION]');
    $dataProductDisplayName = '[DISPLAY_NAME]';
    $dataProductOwnerEmailsElement = '[OWNER_EMAILS]';

    create_data_product_sample(
        $formattedParent,
        $dataProductDisplayName,
        $dataProductOwnerEmailsElement
    );
}

deleteDataAsset

Deletes a data asset.

The async variant is DataProductServiceClient::deleteDataAssetAsync() .

Parameters
Name Description
request Google\Cloud\Dataplex\V1\DeleteDataAssetRequest

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\ApiCore\OperationResponse<null>
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Dataplex\V1\Client\DataProductServiceClient;
use Google\Cloud\Dataplex\V1\DeleteDataAssetRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName The name of the data asset to delete.
 *                              Format:
 *                              projects/{project_id_or_number}/locations/{location_id}/dataProducts/{data_product_id}/dataAssets/{data_asset_id}
 *                              Please see {@see DataProductServiceClient::dataAssetName()} for help formatting this field.
 */
function delete_data_asset_sample(string $formattedName): void
{
    // Create a client.
    $dataProductServiceClient = new DataProductServiceClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $dataProductServiceClient->deleteDataAsset($request);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            printf('Operation completed successfully.' . PHP_EOL);
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->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 = DataProductServiceClient::dataAssetName(
        '[PROJECT]',
        '[LOCATION]',
        '[DATA_PRODUCT]',
        '[DATA_ASSET]'
    );

    delete_data_asset_sample($formattedName);
}

deleteDataProduct

Deletes a data product. The deletion will fail if the data product is not empty (i.e. contains at least one data asset).

The async variant is DataProductServiceClient::deleteDataProductAsync() .

Parameters
Name Description
request Google\Cloud\Dataplex\V1\DeleteDataProductRequest

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\ApiCore\OperationResponse<null>
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Dataplex\V1\Client\DataProductServiceClient;
use Google\Cloud\Dataplex\V1\DeleteDataProductRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName The name of the data product to delete.
 *                              Format:
 *                              projects/{project_id_or_number}/locations/{location_id}/dataProducts/{data_product_id}
 *                              Please see {@see DataProductServiceClient::dataProductName()} for help formatting this field.
 */
function delete_data_product_sample(string $formattedName): void
{
    // Create a client.
    $dataProductServiceClient = new DataProductServiceClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $dataProductServiceClient->deleteDataProduct($request);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            printf('Operation completed successfully.' . PHP_EOL);
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->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 = DataProductServiceClient::dataProductName(
        '[PROJECT]',
        '[LOCATION]',
        '[DATA_PRODUCT]'
    );

    delete_data_product_sample($formattedName);
}

getDataAsset

Gets a data asset.

The async variant is DataProductServiceClient::getDataAssetAsync() .

Parameters
Name Description
request Google\Cloud\Dataplex\V1\GetDataAssetRequest

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\Cloud\Dataplex\V1\DataAsset
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Dataplex\V1\Client\DataProductServiceClient;
use Google\Cloud\Dataplex\V1\DataAsset;
use Google\Cloud\Dataplex\V1\GetDataAssetRequest;

/**
 * @param string $formattedName The name of the data asset to retrieve.
 *                              Format:
 *                              projects/{project_id_or_number}/locations/{location_id}/dataProducts/{data_product_id}/dataAssets/{data_asset_id}
 *                              Please see {@see DataProductServiceClient::dataAssetName()} for help formatting this field.
 */
function get_data_asset_sample(string $formattedName): void
{
    // Create a client.
    $dataProductServiceClient = new DataProductServiceClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var DataAsset $response */
        $response = $dataProductServiceClient->getDataAsset($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 = DataProductServiceClient::dataAssetName(
        '[PROJECT]',
        '[LOCATION]',
        '[DATA_PRODUCT]',
        '[DATA_ASSET]'
    );

    get_data_asset_sample($formattedName);
}

getDataProduct

Gets a data product.

The async variant is DataProductServiceClient::getDataProductAsync() .

Parameters
Name Description
request Google\Cloud\Dataplex\V1\GetDataProductRequest

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\Cloud\Dataplex\V1\DataProduct
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Dataplex\V1\Client\DataProductServiceClient;
use Google\Cloud\Dataplex\V1\DataProduct;
use Google\Cloud\Dataplex\V1\GetDataProductRequest;

/**
 * @param string $formattedName The name of the data product to retrieve.
 *                              Format:
 *                              projects/{project_id_or_number}/locations/{location_id}/dataProducts/{data_product_id}
 *                              Please see {@see DataProductServiceClient::dataProductName()} for help formatting this field.
 */
function get_data_product_sample(string $formattedName): void
{
    // Create a client.
    $dataProductServiceClient = new DataProductServiceClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var DataProduct $response */
        $response = $dataProductServiceClient->getDataProduct($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 = DataProductServiceClient::dataProductName(
        '[PROJECT]',
        '[LOCATION]',
        '[DATA_PRODUCT]'
    );

    get_data_product_sample($formattedName);
}

listDataAssets

Lists data assets for a given data product.

The async variant is DataProductServiceClient::listDataAssetsAsync() .

Parameters
Name Description
request Google\Cloud\Dataplex\V1\ListDataAssetsRequest

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\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Dataplex\V1\Client\DataProductServiceClient;
use Google\Cloud\Dataplex\V1\DataAsset;
use Google\Cloud\Dataplex\V1\ListDataAssetsRequest;

/**
 * @param string $formattedParent The parent, which has this collection of data assets.
 *                                Format:
 *                                projects/{project_id_or_number}/locations/{location_id}/dataProducts/{data_product_id}
 *                                Please see {@see DataProductServiceClient::dataProductName()} for help formatting this field.
 */
function list_data_assets_sample(string $formattedParent): void
{
    // Create a client.
    $dataProductServiceClient = new DataProductServiceClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $dataProductServiceClient->listDataAssets($request);

        /** @var DataAsset $element */
        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 = DataProductServiceClient::dataProductName(
        '[PROJECT]',
        '[LOCATION]',
        '[DATA_PRODUCT]'
    );

    list_data_assets_sample($formattedParent);
}

listDataProducts

Lists data products for a given project.

The async variant is DataProductServiceClient::listDataProductsAsync() .

Parameters
Name Description
request Google\Cloud\Dataplex\V1\ListDataProductsRequest

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\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Dataplex\V1\Client\DataProductServiceClient;
use Google\Cloud\Dataplex\V1\DataProduct;
use Google\Cloud\Dataplex\V1\ListDataProductsRequest;

/**
 * @param string $formattedParent The parent, which has this collection of data products.
 *
 *                                Format: `projects/{project_id_or_number}/locations/{location_id}`.
 *
 *                                Supports listing across all locations with the wildcard `-` (hyphen)
 *                                character. Example: `projects/{project_id_or_number}/locations/-`
 *                                Please see {@see DataProductServiceClient::locationName()} for help formatting this field.
 */
function list_data_products_sample(string $formattedParent): void
{
    // Create a client.
    $dataProductServiceClient = new DataProductServiceClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $dataProductServiceClient->listDataProducts($request);

        /** @var DataProduct $element */
        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 = DataProductServiceClient::locationName('[PROJECT]', '[LOCATION]');

    list_data_products_sample($formattedParent);
}

updateDataAsset

Updates a data asset.

The async variant is DataProductServiceClient::updateDataAssetAsync() .

Parameters
Name Description
request Google\Cloud\Dataplex\V1\UpdateDataAssetRequest

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\ApiCore\OperationResponse<Google\Cloud\Dataplex\V1\DataAsset>
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Dataplex\V1\Client\DataProductServiceClient;
use Google\Cloud\Dataplex\V1\DataAsset;
use Google\Cloud\Dataplex\V1\UpdateDataAssetRequest;
use Google\Rpc\Status;

/**
 * @param string $dataAssetResource Immutable. Full resource name of the cloud resource represented
 *                                  by the data asset. This must follow
 *                                  https://cloud.google.com/iam/docs/full-resource-names. Example:
 *                                  `//bigquery.googleapis.com/projects/my_project_123/datasets/dataset_456/tables/table_789`
 *                                  Only BigQuery tables and datasets are currently supported.
 *                                  Data asset creator must have getIamPolicy and setIamPolicy permissions on
 *                                  the resource. Data asset creator must also have resource specific get
 *                                  permission, for instance, bigquery.tables.get for BigQuery tables.
 */
function update_data_asset_sample(string $dataAssetResource): void
{
    // Create a client.
    $dataProductServiceClient = new DataProductServiceClient();

    // Prepare the request message.
    $dataAsset = (new DataAsset())
        ->setResource($dataAssetResource);
    $request = (new UpdateDataAssetRequest())
        ->setDataAsset($dataAsset);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $dataProductServiceClient->updateDataAsset($request);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var DataAsset $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->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
{
    $dataAssetResource = '[RESOURCE]';

    update_data_asset_sample($dataAssetResource);
}

updateDataProduct

Updates a data product.

The async variant is DataProductServiceClient::updateDataProductAsync() .

Parameters
Name Description
request Google\Cloud\Dataplex\V1\UpdateDataProductRequest

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\ApiCore\OperationResponse<Google\Cloud\Dataplex\V1\DataProduct>
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Dataplex\V1\Client\DataProductServiceClient;
use Google\Cloud\Dataplex\V1\DataProduct;
use Google\Cloud\Dataplex\V1\UpdateDataProductRequest;
use Google\Rpc\Status;

/**
 * @param string $dataProductDisplayName        User-friendly display name of the data product.
 * @param string $dataProductOwnerEmailsElement Emails of the data product owners.
 */
function update_data_product_sample(
    string $dataProductDisplayName,
    string $dataProductOwnerEmailsElement
): void {
    // Create a client.
    $dataProductServiceClient = new DataProductServiceClient();

    // Prepare the request message.
    $dataProductOwnerEmails = [$dataProductOwnerEmailsElement,];
    $dataProduct = (new DataProduct())
        ->setDisplayName($dataProductDisplayName)
        ->setOwnerEmails($dataProductOwnerEmails);
    $request = (new UpdateDataProductRequest())
        ->setDataProduct($dataProduct);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $dataProductServiceClient->updateDataProduct($request);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var DataProduct $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->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
{
    $dataProductDisplayName = '[DISPLAY_NAME]';
    $dataProductOwnerEmailsElement = '[OWNER_EMAILS]';

    update_data_product_sample($dataProductDisplayName, $dataProductOwnerEmailsElement);
}

getLocation

Gets information about a location.

The async variant is DataProductServiceClient::getLocationAsync() .

Parameters
Name Description
request Google\Cloud\Location\GetLocationRequest

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\Cloud\Location\Location
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Dataplex\V1\Client\DataProductServiceClient;
use Google\Cloud\Location\GetLocationRequest;
use Google\Cloud\Location\Location;

/**
 * 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 get_location_sample(): void
{
    // Create a client.
    $dataProductServiceClient = new DataProductServiceClient();

    // Prepare the request message.
    $request = new GetLocationRequest();

    // Call the API and handle any network failures.
    try {
        /** @var Location $response */
        $response = $dataProductServiceClient->getLocation($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

listLocations

Lists information about the supported locations for this service.

This method can be called in two ways:

List all public locations: Use the path GET /v1/locations. List project-visible locations: Use the path GET /v1/projects/{project_id}/locations. This may include public locations as well as private or other locations specifically visible to the project.

The async variant is DataProductServiceClient::listLocationsAsync() .

Parameters
Name Description
request Google\Cloud\Location\ListLocationsRequest

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\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Dataplex\V1\Client\DataProductServiceClient;
use Google\Cloud\Location\ListLocationsRequest;
use Google\Cloud\Location\Location;

/**
 * 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 list_locations_sample(): void
{
    // Create a client.
    $dataProductServiceClient = new DataProductServiceClient();

    // Prepare the request message.
    $request = new ListLocationsRequest();

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $dataProductServiceClient->listLocations($request);

        /** @var Location $element */
        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());
    }
}

getIamPolicy

Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.

The async variant is DataProductServiceClient::getIamPolicyAsync() .

Parameters
Name Description
request Google\Cloud\Iam\V1\GetIamPolicyRequest

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\Cloud\Iam\V1\Policy
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Dataplex\V1\Client\DataProductServiceClient;
use Google\Cloud\Iam\V1\GetIamPolicyRequest;
use Google\Cloud\Iam\V1\Policy;

/**
 * @param string $resource REQUIRED: The resource for which the policy is being requested.
 *                         See the operation documentation for the appropriate value for this field.
 */
function get_iam_policy_sample(string $resource): void
{
    // Create a client.
    $dataProductServiceClient = new DataProductServiceClient();

    // Prepare the request message.
    $request = (new GetIamPolicyRequest())
        ->setResource($resource);

    // Call the API and handle any network failures.
    try {
        /** @var Policy $response */
        $response = $dataProductServiceClient->getIamPolicy($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
{
    $resource = '[RESOURCE]';

    get_iam_policy_sample($resource);
}

setIamPolicy

Sets the access control policy on the specified resource. Replaces any existing policy.

Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED errors.

The async variant is DataProductServiceClient::setIamPolicyAsync() .

Parameters
Name Description
request Google\Cloud\Iam\V1\SetIamPolicyRequest

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\Cloud\Iam\V1\Policy
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Dataplex\V1\Client\DataProductServiceClient;
use Google\Cloud\Iam\V1\Policy;
use Google\Cloud\Iam\V1\SetIamPolicyRequest;

/**
 * @param string $resource REQUIRED: The resource for which the policy is being specified.
 *                         See the operation documentation for the appropriate value for this field.
 */
function set_iam_policy_sample(string $resource): void
{
    // Create a client.
    $dataProductServiceClient = new DataProductServiceClient();

    // Prepare the request message.
    $policy = new Policy();
    $request = (new SetIamPolicyRequest())
        ->setResource($resource)
        ->setPolicy($policy);

    // Call the API and handle any network failures.
    try {
        /** @var Policy $response */
        $response = $dataProductServiceClient->setIamPolicy($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
{
    $resource = '[RESOURCE]';

    set_iam_policy_sample($resource);
}

testIamPermissions

Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a NOT_FOUND error.

Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.

The async variant is DataProductServiceClient::testIamPermissionsAsync() .

Parameters
Name Description
request Google\Cloud\Iam\V1\TestIamPermissionsRequest

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\Cloud\Iam\V1\TestIamPermissionsResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Dataplex\V1\Client\DataProductServiceClient;
use Google\Cloud\Iam\V1\TestIamPermissionsRequest;
use Google\Cloud\Iam\V1\TestIamPermissionsResponse;

/**
 * @param string $resource           REQUIRED: The resource for which the policy detail is being requested.
 *                                   See the operation documentation for the appropriate value for this field.
 * @param string $permissionsElement The set of permissions to check for the `resource`. Permissions with
 *                                   wildcards (such as '*' or 'storage.*') are not allowed. For more
 *                                   information see
 *                                   [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
 */
function test_iam_permissions_sample(string $resource, string $permissionsElement): void
{
    // Create a client.
    $dataProductServiceClient = new DataProductServiceClient();

    // Prepare the request message.
    $permissions = [$permissionsElement,];
    $request = (new TestIamPermissionsRequest())
        ->setResource($resource)
        ->setPermissions($permissions);

    // Call the API and handle any network failures.
    try {
        /** @var TestIamPermissionsResponse $response */
        $response = $dataProductServiceClient->testIamPermissions($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
{
    $resource = '[RESOURCE]';
    $permissionsElement = '[PERMISSIONS]';

    test_iam_permissions_sample($resource, $permissionsElement);
}

createDataAssetAsync

Parameters
Name Description
request Google\Cloud\Dataplex\V1\CreateDataAssetRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

createDataProductAsync

Parameters
Name Description
request Google\Cloud\Dataplex\V1\CreateDataProductRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

deleteDataAssetAsync

Parameters
Name Description
request Google\Cloud\Dataplex\V1\DeleteDataAssetRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

deleteDataProductAsync

Parameters
Name Description
request Google\Cloud\Dataplex\V1\DeleteDataProductRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

getDataAssetAsync

Parameters
Name Description
request Google\Cloud\Dataplex\V1\GetDataAssetRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Dataplex\V1\DataAsset>

getDataProductAsync

Parameters
Name Description
request Google\Cloud\Dataplex\V1\GetDataProductRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Dataplex\V1\DataProduct>

listDataAssetsAsync

Parameters
Name Description
request Google\Cloud\Dataplex\V1\ListDataAssetsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse>

listDataProductsAsync

Parameters
Name Description
request Google\Cloud\Dataplex\V1\ListDataProductsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse>

updateDataAssetAsync

Parameters
Name Description
request Google\Cloud\Dataplex\V1\UpdateDataAssetRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

updateDataProductAsync

Parameters
Name Description
request Google\Cloud\Dataplex\V1\UpdateDataProductRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

getLocationAsync

Parameters
Name Description
request Google\Cloud\Location\GetLocationRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Location\Location>

listLocationsAsync

Parameters
Name Description
request Google\Cloud\Location\ListLocationsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse>

getIamPolicyAsync

Parameters
Name Description
request Google\Cloud\Iam\V1\GetIamPolicyRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Iam\V1\Policy>

setIamPolicyAsync

Parameters
Name Description
request Google\Cloud\Iam\V1\SetIamPolicyRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Iam\V1\Policy>

testIamPermissionsAsync

Parameters
Name Description
request Google\Cloud\Iam\V1\TestIamPermissionsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Iam\V1\TestIamPermissionsResponse>

getOperationsClient

Return an OperationsClient object with the same endpoint as $this.

Returns
Type Description
Google\LongRunning\Client\OperationsClient

resumeOperation

Resume an existing long running operation that was previously started by a long running API method. If $methodName is not provided, or does not match a long running API method, then the operation can still be resumed, but the OperationResponse object will not deserialize the final response.

Parameters
Name Description
operationName string

The name of the long running operation

methodName string

The name of the method used to start the operation

Returns
Type Description
Google\ApiCore\OperationResponse

static::dataAssetName

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

Parameters
Name Description
project string
location string
dataProduct string
dataAsset string
Returns
Type Description
string The formatted data_asset resource.

static::dataProductName

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

Parameters
Name Description
project string
location string
dataProduct string
Returns
Type Description
string The formatted data_product resource.

static::locationName

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

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

  • dataAsset: projects/{project}/locations/{location}/dataProducts/{data_product}/dataAssets/{data_asset}
  • dataProduct: projects/{project}/locations/{location}/dataProducts/{data_product}
  • location: projects/{project}/locations/{location}

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.