Google Cloud Dataplex V1 Client - Class MetadataServiceClient (0.2.3)

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

Service Description: Metadata service manages metadata resources such as tables, filesets and partitions.

This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:

$metadataServiceClient = new MetadataServiceClient();
try {
    $formattedParent = $metadataServiceClient->zoneName('[PROJECT]', '[LOCATION]', '[LAKE]', '[ZONE]');
    $entity = new Entity();
    $response = $metadataServiceClient->createEntity($formattedParent, $entity);
} finally {
    $metadataServiceClient->close();
}

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.

Methods

entityName

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

Parameters
NameDescription
project string
location string
lake string
zone string
entity string
Returns
TypeDescription
stringThe formatted entity resource.

partitionName

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

Parameters
NameDescription
project string
location string
lake string
zone string
entity string
partition string
Returns
TypeDescription
stringThe formatted partition resource.

zoneName

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

Parameters
NameDescription
project string
location string
lake string
zone string
Returns
TypeDescription
stringThe formatted zone resource.

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

  • entity: projects/{project}/locations/{location}/lakes/{lake}/zones/{zone}/entities/{entity}
  • partition: projects/{project}/locations/{location}/lakes/{lake}/zones/{zone}/entities/{entity}/partitions/{partition}
  • zone: projects/{project}/locations/{location}/lakes/{lake}/zones/{zone}

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
NameDescription
formattedName string

The formatted name string

template string

Optional name of template to match

Returns
TypeDescription
arrayAn associative array from name component IDs to component values.

__construct

Constructor.

Parameters
NameDescription
options array

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 string|array|FetchAuthTokenInterface|CredentialsWrapper

The credentials to be used by the client to authorize API calls. This option accepts either a path to a credentials file, or a decoded credentials file as a PHP array. Advanced usage: In addition, this option can also accept a pre-constructed Google\Auth\FetchAuthTokenInterface object or Google\ApiCore\CredentialsWrapper object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored.

↳ 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.

createEntity

Create a metadata entity.

Parameters
NameDescription
parent string

Required. The resource name of the parent zone: projects/{project_number}/locations/{location_id}/lakes/{lake_id}/zones/{zone_id}.

entity Google\Cloud\Dataplex\V1\Entity

Required. Entity resource.

optionalArgs array

Optional.

↳ validateOnly bool

Optional. Only validate the request, but do not perform mutations. The default is false.

↳ 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
TypeDescription
Google\Cloud\Dataplex\V1\Entity
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Dataplex\V1\Entity;
use Google\Cloud\Dataplex\V1\Entity\Type;
use Google\Cloud\Dataplex\V1\MetadataServiceClient;
use Google\Cloud\Dataplex\V1\Schema;
use Google\Cloud\Dataplex\V1\StorageFormat;
use Google\Cloud\Dataplex\V1\StorageSystem;

/**
 * @param string $formattedParent         The resource name of the parent zone:
 *                                        `projects/{project_number}/locations/{location_id}/lakes/{lake_id}/zones/{zone_id}`. Please see
 *                                        {@see MetadataServiceClient::zoneName()} for help formatting this field.
 * @param string $entityId                A user-provided entity ID. It is mutable, and will be used as the
 *                                        published table name. Specifying a new ID in an update entity
 *                                        request will override the existing value.
 *                                        The ID must contain only letters (a-z, A-Z), numbers (0-9), and
 *                                        underscores. Must begin with a letter and consist of 256 or fewer
 *                                        characters.
 * @param int    $entityType              Immutable. The type of entity.
 * @param string $entityAsset             Immutable. The ID of the asset associated with the storage
 *                                        location containing the entity data. The entity must be with in the same
 *                                        zone with the asset.
 * @param string $entityDataPath          Immutable. The storage path of the entity data.
 *                                        For Cloud Storage data, this is the fully-qualified path to the entity,
 *                                        such as `gs://bucket/path/to/data`. For BigQuery data, this is the name of
 *                                        the table resource, such as
 *                                        `projects/project_id/datasets/dataset_id/tables/table_id`.
 * @param int    $entitySystem            Immutable. Identifies the storage system of the entity data.
 * @param string $entityFormatMimeType    The mime type descriptor for the data. Must match the pattern
 *                                        {type}/{subtype}. Supported values:
 *
 *                                        - application/x-parquet
 *                                        - application/x-avro
 *                                        - application/x-orc
 *                                        - application/x-tfrecord
 *                                        - application/x-parquet+iceberg
 *                                        - application/x-avro+iceberg
 *                                        - application/x-orc+iceberg
 *                                        - application/json
 *                                        - application/{subtypes}
 *                                        - text/csv
 *                                        - text/<subtypes>
 *                                        - image/{image subtype}
 *                                        - video/{video subtype}
 *                                        - audio/{audio subtype}
 * @param bool   $entitySchemaUserManaged Set to `true` if user-managed or `false` if managed by Dataplex.
 *                                        The default is `false` (managed by Dataplex).
 *
 *                                        - Set to `false`to enable Dataplex discovery to update the schema.
 *                                        including new data discovery, schema inference, and schema evolution.
 *                                        Users retain the ability to input and edit the schema. Dataplex
 *                                        treats schema input by the user as though produced
 *                                        by a previous Dataplex discovery operation, and it will
 *                                        evolve the schema and take action based on that treatment.
 *
 *                                        - Set to `true` to fully manage the entity
 *                                        schema. This setting guarantees that Dataplex will not
 *                                        change schema fields.
 */
function create_entity_sample(
    string $formattedParent,
    string $entityId,
    int $entityType,
    string $entityAsset,
    string $entityDataPath,
    int $entitySystem,
    string $entityFormatMimeType,
    bool $entitySchemaUserManaged
): void {
    // Create a client.
    $metadataServiceClient = new MetadataServiceClient();

    // Prepare any non-scalar elements to be passed along with the request.
    $entityFormat = (new StorageFormat())
        ->setMimeType($entityFormatMimeType);
    $entitySchema = (new Schema())
        ->setUserManaged($entitySchemaUserManaged);
    $entity = (new Entity())
        ->setId($entityId)
        ->setType($entityType)
        ->setAsset($entityAsset)
        ->setDataPath($entityDataPath)
        ->setSystem($entitySystem)
        ->setFormat($entityFormat)
        ->setSchema($entitySchema);

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

/**
 * 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 = MetadataServiceClient::zoneName('[PROJECT]', '[LOCATION]', '[LAKE]', '[ZONE]');
    $entityId = '[ID]';
    $entityType = Type::TYPE_UNSPECIFIED;
    $entityAsset = '[ASSET]';
    $entityDataPath = '[DATA_PATH]';
    $entitySystem = StorageSystem::STORAGE_SYSTEM_UNSPECIFIED;
    $entityFormatMimeType = '[MIME_TYPE]';
    $entitySchemaUserManaged = false;

    create_entity_sample(
        $formattedParent,
        $entityId,
        $entityType,
        $entityAsset,
        $entityDataPath,
        $entitySystem,
        $entityFormatMimeType,
        $entitySchemaUserManaged
    );
}

createPartition

Create a metadata partition.

Parameters
NameDescription
parent string

Required. The resource name of the parent zone: projects/{project_number}/locations/{location_id}/lakes/{lake_id}/zones/{zone_id}/entities/{entity_id}.

partition Google\Cloud\Dataplex\V1\Partition

Required. Partition resource.

optionalArgs array

Optional.

↳ validateOnly bool

Optional. Only validate the request, but do not perform mutations. The default is false.

↳ 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
TypeDescription
Google\Cloud\Dataplex\V1\Partition
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Dataplex\V1\MetadataServiceClient;
use Google\Cloud\Dataplex\V1\Partition;

/**
 * @param string $formattedParent        The resource name of the parent zone:
 *                                       `projects/{project_number}/locations/{location_id}/lakes/{lake_id}/zones/{zone_id}/entities/{entity_id}`. Please see
 *                                       {@see MetadataServiceClient::entityName()} for help formatting this field.
 * @param string $partitionValuesElement Immutable. The set of values representing the partition, which
 *                                       correspond to the partition schema defined in the parent entity.
 * @param string $partitionLocation      Immutable. The location of the entity data within the partition,
 *                                       for example, `gs://bucket/path/to/entity/key1=value1/key2=value2`. Or
 *                                       `projects/<project_id>/datasets/<dataset_id>/tables/<table_id>`
 */
function create_partition_sample(
    string $formattedParent,
    string $partitionValuesElement,
    string $partitionLocation
): void {
    // Create a client.
    $metadataServiceClient = new MetadataServiceClient();

    // Prepare any non-scalar elements to be passed along with the request.
    $partitionValues = [$partitionValuesElement,];
    $partition = (new Partition())
        ->setValues($partitionValues)
        ->setLocation($partitionLocation);

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

/**
 * 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 = MetadataServiceClient::entityName(
        '[PROJECT]',
        '[LOCATION]',
        '[LAKE]',
        '[ZONE]',
        '[ENTITY]'
    );
    $partitionValuesElement = '[VALUES]';
    $partitionLocation = '[LOCATION]';

    create_partition_sample($formattedParent, $partitionValuesElement, $partitionLocation);
}

deleteEntity

Delete a metadata entity.

Parameters
NameDescription
name string

Required. The resource name of the entity: projects/{project_number}/locations/{location_id}/lakes/{lake_id}/zones/{zone_id}/entities/{entity_id}.

etag string

Required. The etag associated with the entity, which can be retrieved with a GetEntity request.

optionalArgs 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.

Example
use Google\ApiCore\ApiException;
use Google\Cloud\Dataplex\V1\MetadataServiceClient;

/**
 * @param string $formattedName The resource name of the entity:
 *                              `projects/{project_number}/locations/{location_id}/lakes/{lake_id}/zones/{zone_id}/entities/{entity_id}`. Please see
 *                              {@see MetadataServiceClient::entityName()} for help formatting this field.
 * @param string $etag          The etag associated with the entity, which can be retrieved with
 *                              a [GetEntity][] request.
 */
function delete_entity_sample(string $formattedName, string $etag): void
{
    // Create a client.
    $metadataServiceClient = new MetadataServiceClient();

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

/**
 * 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 = MetadataServiceClient::entityName(
        '[PROJECT]',
        '[LOCATION]',
        '[LAKE]',
        '[ZONE]',
        '[ENTITY]'
    );
    $etag = '[ETAG]';

    delete_entity_sample($formattedName, $etag);
}

deletePartition

Delete a metadata partition.

Parameters
NameDescription
name string

Required. The resource name of the partition. format: projects/{project_number}/locations/{location_id}/lakes/{lake_id}/zones/{zone_id}/entities/{entity_id}/partitions/{partition_value_path}. The {partition_value_path} segment consists of an ordered sequence of partition values separated by "/". All values must be provided.

optionalArgs array

Optional.

↳ etag string

Optional. The etag associated with the partition.

↳ 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.

Example
use Google\ApiCore\ApiException;
use Google\Cloud\Dataplex\V1\MetadataServiceClient;

/**
 * @param string $formattedName The resource name of the partition.
 *                              format:
 *                              `projects/{project_number}/locations/{location_id}/lakes/{lake_id}/zones/{zone_id}/entities/{entity_id}/partitions/{partition_value_path}`.
 *                              The {partition_value_path} segment consists of an ordered sequence of
 *                              partition values separated by "/". All values must be provided. Please see
 *                              {@see MetadataServiceClient::partitionName()} for help formatting this field.
 */
function delete_partition_sample(string $formattedName): void
{
    // Create a client.
    $metadataServiceClient = new MetadataServiceClient();

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

/**
 * 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 = MetadataServiceClient::partitionName(
        '[PROJECT]',
        '[LOCATION]',
        '[LAKE]',
        '[ZONE]',
        '[ENTITY]',
        '[PARTITION]'
    );

    delete_partition_sample($formattedName);
}

getEntity

Get a metadata entity.

Parameters
NameDescription
name string

Required. The resource name of the entity: projects/{project_number}/locations/{location_id}/lakes/{lake_id}/zones/{zone_id}/entities/{entity_id}.

optionalArgs array

Optional.

↳ view int

Optional. Used to select the subset of entity information to return. Defaults to BASIC. For allowed values, use constants defined on Google\Cloud\Dataplex\V1\GetEntityRequest\EntityView

↳ 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
TypeDescription
Google\Cloud\Dataplex\V1\Entity
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Dataplex\V1\Entity;
use Google\Cloud\Dataplex\V1\MetadataServiceClient;

/**
 * @param string $formattedName The resource name of the entity:
 *                              `projects/{project_number}/locations/{location_id}/lakes/{lake_id}/zones/{zone_id}/entities/{entity_id}.`
 *                              Please see {@see MetadataServiceClient::entityName()} for help formatting this field.
 */
function get_entity_sample(string $formattedName): void
{
    // Create a client.
    $metadataServiceClient = new MetadataServiceClient();

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

/**
 * 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 = MetadataServiceClient::entityName(
        '[PROJECT]',
        '[LOCATION]',
        '[LAKE]',
        '[ZONE]',
        '[ENTITY]'
    );

    get_entity_sample($formattedName);
}

getPartition

Get a metadata partition of an entity.

Parameters
NameDescription
name string

Required. The resource name of the partition: projects/{project_number}/locations/{location_id}/lakes/{lake_id}/zones/{zone_id}/entities/{entity_id}/partitions/{partition_value_path}. The {partition_value_path} segment consists of an ordered sequence of partition values separated by "/". All values must be provided.

optionalArgs 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
TypeDescription
Google\Cloud\Dataplex\V1\Partition
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Dataplex\V1\MetadataServiceClient;
use Google\Cloud\Dataplex\V1\Partition;

/**
 * @param string $formattedName The resource name of the partition:
 *                              `projects/{project_number}/locations/{location_id}/lakes/{lake_id}/zones/{zone_id}/entities/{entity_id}/partitions/{partition_value_path}`.
 *                              The {partition_value_path} segment consists of an ordered sequence of
 *                              partition values separated by "/". All values must be provided. Please see
 *                              {@see MetadataServiceClient::partitionName()} for help formatting this field.
 */
function get_partition_sample(string $formattedName): void
{
    // Create a client.
    $metadataServiceClient = new MetadataServiceClient();

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

/**
 * 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 = MetadataServiceClient::partitionName(
        '[PROJECT]',
        '[LOCATION]',
        '[LAKE]',
        '[ZONE]',
        '[ENTITY]',
        '[PARTITION]'
    );

    get_partition_sample($formattedName);
}

listEntities

List metadata entities in a zone.

Parameters
NameDescription
parent string

Required. The resource name of the parent zone: projects/{project_number}/locations/{location_id}/lakes/{lake_id}/zones/{zone_id}.

view int

Required. Specify the entity view to make a partial list request. For allowed values, use constants defined on {@see \Google\Cloud\Dataplex\V1\ListEntitiesRequest\EntityView}

optionalArgs array

Optional.

↳ pageSize int

The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved.

↳ pageToken string

A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API.

↳ filter string

Optional. The following filter parameters can be added to the URL to limit the entities returned by the API: - Entity ID: ?filter="id=entityID" - Asset ID: ?filter="asset=assetID" - Data path ?filter="data_path=gs://my-bucket" - Is HIVE compatible: ?filter="hive_compatible=true" - Is BigQuery compatible: ?filter="bigquery_compatible=true"

↳ 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
TypeDescription
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Dataplex\V1\Entity;
use Google\Cloud\Dataplex\V1\ListEntitiesRequest\EntityView;
use Google\Cloud\Dataplex\V1\MetadataServiceClient;

/**
 * @param string $formattedParent The resource name of the parent zone:
 *                                `projects/{project_number}/locations/{location_id}/lakes/{lake_id}/zones/{zone_id}`. Please see
 *                                {@see MetadataServiceClient::zoneName()} for help formatting this field.
 * @param int    $view            Specify the entity view to make a partial list request.
 */
function list_entities_sample(string $formattedParent, int $view): void
{
    // Create a client.
    $metadataServiceClient = new MetadataServiceClient();

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $metadataServiceClient->listEntities($formattedParent, $view);

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

/**
 * 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 = MetadataServiceClient::zoneName('[PROJECT]', '[LOCATION]', '[LAKE]', '[ZONE]');
    $view = EntityView::ENTITY_VIEW_UNSPECIFIED;

    list_entities_sample($formattedParent, $view);
}

listPartitions

List metadata partitions of an entity.

Parameters
NameDescription
parent string

Required. The resource name of the parent entity: projects/{project_number}/locations/{location_id}/lakes/{lake_id}/zones/{zone_id}/entities/{entity_id}.

optionalArgs array

Optional.

↳ pageSize int

The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved.

↳ pageToken string

A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API.

↳ filter string

Optional. Filter the partitions returned to the caller using a key value pair expression. Supported operators and syntax: - logic operators: AND, OR - comparison operators: <, >, >=, <= ,=, != - LIKE operators: - The right hand of a LIKE operator supports "." and "" for wildcard searches, for example "value1 LIKE ".oo." - parenthetical grouping: ( ) Sample filter expression: `?filter="key1 < value1 OR key2 > value2" **Notes:* - Keys to the left of operators are case insensitive. - Partition results are sorted first by creation time, then by lexicographic order. - Up to 20 key value filter pairs are allowed, but due to performance considerations, only the first 10 will be used as a filter.

↳ 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
TypeDescription
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Dataplex\V1\MetadataServiceClient;
use Google\Cloud\Dataplex\V1\Partition;

/**
 * @param string $formattedParent The resource name of the parent entity:
 *                                `projects/{project_number}/locations/{location_id}/lakes/{lake_id}/zones/{zone_id}/entities/{entity_id}`. Please see
 *                                {@see MetadataServiceClient::entityName()} for help formatting this field.
 */
function list_partitions_sample(string $formattedParent): void
{
    // Create a client.
    $metadataServiceClient = new MetadataServiceClient();

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

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

/**
 * 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 = MetadataServiceClient::entityName(
        '[PROJECT]',
        '[LOCATION]',
        '[LAKE]',
        '[ZONE]',
        '[ENTITY]'
    );

    list_partitions_sample($formattedParent);
}

updateEntity

Update a metadata entity. Only supports full resource update.

Parameters
NameDescription
entity Google\Cloud\Dataplex\V1\Entity

Required. Update description.

optionalArgs array

Optional.

↳ validateOnly bool

Optional. Only validate the request, but do not perform mutations. The default is false.

↳ 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
TypeDescription
Google\Cloud\Dataplex\V1\Entity
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Dataplex\V1\Entity;
use Google\Cloud\Dataplex\V1\Entity\Type;
use Google\Cloud\Dataplex\V1\MetadataServiceClient;
use Google\Cloud\Dataplex\V1\Schema;
use Google\Cloud\Dataplex\V1\StorageFormat;
use Google\Cloud\Dataplex\V1\StorageSystem;

/**
 * @param string $entityId                A user-provided entity ID. It is mutable, and will be used as the
 *                                        published table name. Specifying a new ID in an update entity
 *                                        request will override the existing value.
 *                                        The ID must contain only letters (a-z, A-Z), numbers (0-9), and
 *                                        underscores. Must begin with a letter and consist of 256 or fewer
 *                                        characters.
 * @param int    $entityType              Immutable. The type of entity.
 * @param string $entityAsset             Immutable. The ID of the asset associated with the storage
 *                                        location containing the entity data. The entity must be with in the same
 *                                        zone with the asset.
 * @param string $entityDataPath          Immutable. The storage path of the entity data.
 *                                        For Cloud Storage data, this is the fully-qualified path to the entity,
 *                                        such as `gs://bucket/path/to/data`. For BigQuery data, this is the name of
 *                                        the table resource, such as
 *                                        `projects/project_id/datasets/dataset_id/tables/table_id`.
 * @param int    $entitySystem            Immutable. Identifies the storage system of the entity data.
 * @param string $entityFormatMimeType    The mime type descriptor for the data. Must match the pattern
 *                                        {type}/{subtype}. Supported values:
 *
 *                                        - application/x-parquet
 *                                        - application/x-avro
 *                                        - application/x-orc
 *                                        - application/x-tfrecord
 *                                        - application/x-parquet+iceberg
 *                                        - application/x-avro+iceberg
 *                                        - application/x-orc+iceberg
 *                                        - application/json
 *                                        - application/{subtypes}
 *                                        - text/csv
 *                                        - text/<subtypes>
 *                                        - image/{image subtype}
 *                                        - video/{video subtype}
 *                                        - audio/{audio subtype}
 * @param bool   $entitySchemaUserManaged Set to `true` if user-managed or `false` if managed by Dataplex.
 *                                        The default is `false` (managed by Dataplex).
 *
 *                                        - Set to `false`to enable Dataplex discovery to update the schema.
 *                                        including new data discovery, schema inference, and schema evolution.
 *                                        Users retain the ability to input and edit the schema. Dataplex
 *                                        treats schema input by the user as though produced
 *                                        by a previous Dataplex discovery operation, and it will
 *                                        evolve the schema and take action based on that treatment.
 *
 *                                        - Set to `true` to fully manage the entity
 *                                        schema. This setting guarantees that Dataplex will not
 *                                        change schema fields.
 */
function update_entity_sample(
    string $entityId,
    int $entityType,
    string $entityAsset,
    string $entityDataPath,
    int $entitySystem,
    string $entityFormatMimeType,
    bool $entitySchemaUserManaged
): void {
    // Create a client.
    $metadataServiceClient = new MetadataServiceClient();

    // Prepare any non-scalar elements to be passed along with the request.
    $entityFormat = (new StorageFormat())
        ->setMimeType($entityFormatMimeType);
    $entitySchema = (new Schema())
        ->setUserManaged($entitySchemaUserManaged);
    $entity = (new Entity())
        ->setId($entityId)
        ->setType($entityType)
        ->setAsset($entityAsset)
        ->setDataPath($entityDataPath)
        ->setSystem($entitySystem)
        ->setFormat($entityFormat)
        ->setSchema($entitySchema);

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

/**
 * 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
{
    $entityId = '[ID]';
    $entityType = Type::TYPE_UNSPECIFIED;
    $entityAsset = '[ASSET]';
    $entityDataPath = '[DATA_PATH]';
    $entitySystem = StorageSystem::STORAGE_SYSTEM_UNSPECIFIED;
    $entityFormatMimeType = '[MIME_TYPE]';
    $entitySchemaUserManaged = false;

    update_entity_sample(
        $entityId,
        $entityType,
        $entityAsset,
        $entityDataPath,
        $entitySystem,
        $entityFormatMimeType,
        $entitySchemaUserManaged
    );
}

getIamPolicy

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

Parameters
NameDescription
resource string

REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field.

optionalArgs array

Optional.

↳ options GetPolicyOptions

OPTIONAL: A GetPolicyOptions object for specifying options to GetIamPolicy.

↳ 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
TypeDescription
Google\Cloud\Iam\V1\Policy
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Dataplex\V1\MetadataServiceClient;
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.
    $metadataServiceClient = new MetadataServiceClient();

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

/**
 * 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.

Parameters
NameDescription
resource string

REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field.

policy Google\Cloud\Iam\V1\Policy

REQUIRED: The complete policy to be applied to the resource. The size of the policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud Platform services (such as Projects) might reject them.

optionalArgs array

Optional.

↳ updateMask FieldMask

OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only the fields in the mask will be modified. If no mask is provided, the following default mask is used: paths: "bindings, etag"

↳ 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
TypeDescription
Google\Cloud\Iam\V1\Policy
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Dataplex\V1\MetadataServiceClient;
use Google\Cloud\Iam\V1\Policy;

/**
 * @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.
    $metadataServiceClient = new MetadataServiceClient();

    // Prepare any non-scalar elements to be passed along with the request.
    $policy = new Policy();

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

/**
 * 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.

Parameters
NameDescription
resource string

REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field.

permissions string[]

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.

optionalArgs 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
TypeDescription
Google\Cloud\Iam\V1\TestIamPermissionsResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Dataplex\V1\MetadataServiceClient;
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.
    $metadataServiceClient = new MetadataServiceClient();

    // Prepare any non-scalar elements to be passed along with the request.
    $permissions = [$permissionsElement,];

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

/**
 * 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);
}

getLocation

Gets information about a location.

Parameters
NameDescription
optionalArgs array

Optional.

↳ name string

Resource name for the location.

↳ 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
TypeDescription
Google\Cloud\Location\Location
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Dataplex\V1\MetadataServiceClient;
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.
    $metadataServiceClient = new MetadataServiceClient();

    // Call the API and handle any network failures.
    try {
        /** @var Location $response */
        $response = $metadataServiceClient->getLocation();
        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.

Parameters
NameDescription
optionalArgs array

Optional.

↳ name string

The resource that owns the locations collection, if applicable.

↳ filter string

The standard list filter.

↳ pageSize int

The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved.

↳ pageToken string

A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API.

↳ 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
TypeDescription
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Dataplex\V1\MetadataServiceClient;
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.
    $metadataServiceClient = new MetadataServiceClient();

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

        /** @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());
    }
}

Constants

SERVICE_NAME

Value: 'google.cloud.dataplex.v1.MetadataService'

The name of the service.

SERVICE_ADDRESS

Value: 'dataplex.googleapis.com'

The default address of the service.

DEFAULT_SERVICE_PORT

Value: 443

The default port of the service.

CODEGEN_NAME

Value: 'gapic'

The name of the code generator, to be included in the agent header.