Google Cloud App Topology V1 Client - Class AppTopologyClient (0.2.0)

Reference documentation and code samples for the Google Cloud App Topology V1 Client class AppTopologyClient.

Service Description: Service describing handlers for resources

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 \ AppTopology \ V1 \ Client

Methods

__construct

Constructor.

Parameters
Name Description
options array|Google\ApiCore\Options\ClientOptions

Optional. Options for configuring the service API wrapper.

↳ apiEndpoint string

The address of the API remote host. May optionally include the port, formatted as "

↳ credentials Google\Auth\FetchAuthTokenInterface|Google\ApiCore\CredentialsWrapper

This option should only be used with a pre-constructed Google\Auth\FetchAuthTokenInterface or Google\ApiCore\CredentialsWrapper object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored. Important: If you are providing a path to a credentials file, or a decoded credentials file as a PHP array, this usage is now DEPRECATED. Providing an unvalidated credential configuration to Google APIs can compromise the security of your systems and data. It is recommended to create the credentials explicitly use Google\Auth\Credentials\ServiceAccountCredentials; use Google\Cloud\AppTopology\V1\AppTopologyClient; $creds = new ServiceAccountCredentials($scopes, $json); $options = new AppTopologyClient(['credentials' => $creds]); https://cloud.google.com/docs/authentication/external/externally-sourced-credentials

↳ credentialsConfig array

Options used to configure credentials, including auth token caching, for the client. For a full list of supporting configuration options, see Google\ApiCore\CredentialsWrapper::build() .

↳ disableRetries bool

Determines whether or not retries defined by the client configuration should be disabled. Defaults to false.

↳ clientConfig string|array

Client method configuration, including retry settings. This option can be either a path to a JSON file, or a PHP array containing the decoded JSON data. By default this settings points to the default client config file, which is provided in the resources folder.

↳ transport string|Google\ApiCore\Transport\TransportInterface

The transport used for executing network requests. 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|Psr\Log\LoggerInterface

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

↳ universeDomain string

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

exploreSchema

Explores the topology schema starting from given node types or label names up to a specified hop depth.

The async variant is AppTopologyClient::exploreSchemaAsync() .

Parameters
Name Description
request Google\Cloud\AppTopology\V1\ExploreSchemaRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\RetrySettings|array

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

Returns
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\AppTopology\V1\Client\AppTopologyClient;
use Google\Cloud\AppTopology\V1\ExploreSchemaRequest;
use Google\Cloud\AppTopology\V1\NodeType;

/**
 * @param string $formattedName The name of the singleton domain schema resource.
 *                              Format: `projects/{project}/locations/{location}/domains/{domain}/schema`
 *                              Please see {@see AppTopologyClient::schemaName()} for help formatting this field.
 */
function explore_schema_sample(string $formattedName): void
{
    // Create a client.
    $appTopologyClient = new AppTopologyClient();

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

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

        /** @var NodeType $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
{
    $formattedName = AppTopologyClient::schemaName('[PROJECT]', '[LOCATION]', '[DOMAIN]');

    explore_schema_sample($formattedName);
}

generateDiscoveredResourcesTopology

Generate the topology for all resources in the given project. If the project represents an app boundary, the topology is generated for all resources in the boundary.

The async variant is AppTopologyClient::generateDiscoveredResourcesTopologyAsync() .

Parameters
Name Description
request Google\Cloud\AppTopology\V1\GenerateDiscoveredResourcesTopologyRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\RetrySettings|array

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

Returns
Type Description
Google\Cloud\AppTopology\V1\GenerateDiscoveredResourcesTopologyResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\AppTopology\V1\Client\AppTopologyClient;
use Google\Cloud\AppTopology\V1\GenerateDiscoveredResourcesTopologyRequest;
use Google\Cloud\AppTopology\V1\GenerateDiscoveredResourcesTopologyResponse;

/**
 * @param string $formattedName                   The project to query discoverable resources on.
 *                                                Expected format:
 *                                                `projects/{project}/locations/{location}/discoveredResourcesTopology`.
 *                                                Only `global` location is supported. Please see
 *                                                {@see AppTopologyClient::discoveredResourcesTopologyName()} for help formatting this field.
 * @param string $formattedTopologyDomainsElement The full resource name of the domain of the app topology.
 *                                                Format: `projects/{project}/locations/{location}/domains/{domain}`
 *                                                Caller must have apptopology.domains.get permission on each of the domains. Please see
 *                                                {@see AppTopologyClient::domainName()} for help formatting this field.
 */
function generate_discovered_resources_topology_sample(
    string $formattedName,
    string $formattedTopologyDomainsElement
): void {
    // Create a client.
    $appTopologyClient = new AppTopologyClient();

    // Prepare the request message.
    $formattedTopologyDomains = [$formattedTopologyDomainsElement,];
    $request = (new GenerateDiscoveredResourcesTopologyRequest())
        ->setName($formattedName)
        ->setTopologyDomains($formattedTopologyDomains);

    // Call the API and handle any network failures.
    try {
        /** @var GenerateDiscoveredResourcesTopologyResponse $response */
        $response = $appTopologyClient->generateDiscoveredResourcesTopology($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 = AppTopologyClient::discoveredResourcesTopologyName('[PROJECT]', '[LOCATION]');
    $formattedTopologyDomainsElement = AppTopologyClient::domainName(
        '[PROJECT]',
        '[LOCATION]',
        '[DOMAIN]'
    );

    generate_discovered_resources_topology_sample($formattedName, $formattedTopologyDomainsElement);
}

getDomain

Retrieves the specified topology domain.

The async variant is AppTopologyClient::getDomainAsync() .

Parameters
Name Description
request Google\Cloud\AppTopology\V1\GetDomainRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\RetrySettings|array

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

Returns
Type Description
Google\Cloud\AppTopology\V1\Domain
Example
use Google\ApiCore\ApiException;
use Google\Cloud\AppTopology\V1\Client\AppTopologyClient;
use Google\Cloud\AppTopology\V1\Domain;
use Google\Cloud\AppTopology\V1\GetDomainRequest;

/**
 * @param string $formattedName The name of the domain to retrieve.
 *                              Format: `projects/{project}/locations/{location}/domains/{domain}`
 *                              Please see {@see AppTopologyClient::domainName()} for help formatting this field.
 */
function get_domain_sample(string $formattedName): void
{
    // Create a client.
    $appTopologyClient = new AppTopologyClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Domain $response */
        $response = $appTopologyClient->getDomain($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 = AppTopologyClient::domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]');

    get_domain_sample($formattedName);
}

getSchema

Retrieves the schema for the specified topology domain. The schema defines the NodeTypes and EdgeTypes that are supported in GenerateDiscoveredResourcesTopology requests and responses for a given domain.

The async variant is AppTopologyClient::getSchemaAsync() .

Parameters
Name Description
request Google\Cloud\AppTopology\V1\GetSchemaRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\RetrySettings|array

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

Returns
Type Description
Google\Cloud\AppTopology\V1\Schema
Example
use Google\ApiCore\ApiException;
use Google\Cloud\AppTopology\V1\Client\AppTopologyClient;
use Google\Cloud\AppTopology\V1\GetSchemaRequest;
use Google\Cloud\AppTopology\V1\Schema;

/**
 * @param string $formattedName The name of the singleton domain schema resource.
 *                              Format: `projects/{project}/locations/{location}/domains/{domain}/schema`
 *                              Please see {@see AppTopologyClient::schemaName()} for help formatting this field.
 */
function get_schema_sample(string $formattedName): void
{
    // Create a client.
    $appTopologyClient = new AppTopologyClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Schema $response */
        $response = $appTopologyClient->getSchema($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 = AppTopologyClient::schemaName('[PROJECT]', '[LOCATION]', '[DOMAIN]');

    get_schema_sample($formattedName);
}

listDomains

Lists the topology domains available in a specific location.

Only global location is supported.

The async variant is AppTopologyClient::listDomainsAsync() .

Parameters
Name Description
request Google\Cloud\AppTopology\V1\ListDomainsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\RetrySettings|array

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

Returns
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\AppTopology\V1\Client\AppTopologyClient;
use Google\Cloud\AppTopology\V1\Domain;
use Google\Cloud\AppTopology\V1\ListDomainsRequest;

/**
 * @param string $formattedParent The parent location to list domains for.
 *                                Format: `projects/{project}/locations/{location}`
 *                                Only `global` location is supported. Please see
 *                                {@see AppTopologyClient::locationName()} for help formatting this field.
 */
function list_domains_sample(string $formattedParent): void
{
    // Create a client.
    $appTopologyClient = new AppTopologyClient();

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

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

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

    list_domains_sample($formattedParent);
}

getLocation

Gets information about a location.

The async variant is AppTopologyClient::getLocationAsync() .

Parameters
Name Description
request Google\Cloud\Location\GetLocationRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\RetrySettings|array

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

Returns
Type Description
Google\Cloud\Location\Location
Example
use Google\ApiCore\ApiException;
use Google\Cloud\AppTopology\V1\Client\AppTopologyClient;
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.
    $appTopologyClient = new AppTopologyClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Location $response */
        $response = $appTopologyClient->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 lists locations based on the resource scope provided in the ListLocationsRequest.name field: * Global locations: If name is empty, the method lists the public locations available to all projects. * Project-specific locations: If name follows the format projects/{project}, the method lists locations visible to that specific project. This includes public, private, or other project-specific locations enabled for the project.

For gRPC and client library implementations, the resource name is passed as the name field. For direct service calls, the resource name is incorporated into the request path based on the specific service implementation and version.

The async variant is AppTopologyClient::listLocationsAsync() .

Parameters
Name Description
request Google\Cloud\Location\ListLocationsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings Google\ApiCore\RetrySettings|array

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

Returns
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\AppTopology\V1\Client\AppTopologyClient;
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.
    $appTopologyClient = new AppTopologyClient();

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

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

exploreSchemaAsync

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

generateDiscoveredResourcesTopologyAsync

Parameters
Name Description
request Google\Cloud\AppTopology\V1\GenerateDiscoveredResourcesTopologyRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\AppTopology\V1\GenerateDiscoveredResourcesTopologyResponse>

getDomainAsync

Parameters
Name Description
request Google\Cloud\AppTopology\V1\GetDomainRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\AppTopology\V1\Domain>

getSchemaAsync

Parameters
Name Description
request Google\Cloud\AppTopology\V1\GetSchemaRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\AppTopology\V1\Schema>

listDomainsAsync

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

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>

static::discoveredResourcesTopologyName

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

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

static::domainName

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

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

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

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

  • discoveredResourcesTopology: projects/{project}/locations/{location}/discoveredResourcesTopology
  • domain: projects/{project}/locations/{location}/domains/{domain}
  • location: projects/{project}/locations/{location}
  • schema: projects/{project}/locations/{location}/domains/{domain}/schema

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.