Google Cloud Api Hub V1 Client - Class ApiHubClient (0.1.0)

Reference documentation and code samples for the Google Cloud Api Hub V1 Client class ApiHubClient.

Service Description: This service provides all methods related to the API hub.

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

Methods

__construct

Constructor.

Parameters
Name Description
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.

createApi

Create an API resource in the API hub.

Once an API resource is created, versions can be added to it.

The async variant is Google\Cloud\ApiHub\V1\Client\ApiHubClient::createApiAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\CreateApiRequest

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\ApiHub\V1\Api
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\Api;
use Google\Cloud\ApiHub\V1\Client\ApiHubClient;
use Google\Cloud\ApiHub\V1\CreateApiRequest;

/**
 * @param string $formattedParent The parent resource for the API resource.
 *                                Format: `projects/{project}/locations/{location}`
 *                                Please see {@see ApiHubClient::locationName()} for help formatting this field.
 * @param string $apiDisplayName  The display name of the API resource.
 */
function create_api_sample(string $formattedParent, string $apiDisplayName): void
{
    // Create a client.
    $apiHubClient = new ApiHubClient();

    // Prepare the request message.
    $api = (new Api())
        ->setDisplayName($apiDisplayName);
    $request = (new CreateApiRequest())
        ->setParent($formattedParent)
        ->setApi($api);

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

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = ApiHubClient::locationName('[PROJECT]', '[LOCATION]');
    $apiDisplayName = '[DISPLAY_NAME]';

    create_api_sample($formattedParent, $apiDisplayName);
}

createAttribute

Create a user defined attribute.

Certain pre defined attributes are already created by the API hub. These attributes will have type as SYSTEM_DEFINED and can be listed via ListAttributes method. Allowed values for the same can be updated via UpdateAttribute method.

The async variant is Google\Cloud\ApiHub\V1\Client\ApiHubClient::createAttributeAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\CreateAttributeRequest

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\ApiHub\V1\Attribute
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\Attribute;
use Google\Cloud\ApiHub\V1\Attribute\DataType;
use Google\Cloud\ApiHub\V1\Attribute\Scope;
use Google\Cloud\ApiHub\V1\Client\ApiHubClient;
use Google\Cloud\ApiHub\V1\CreateAttributeRequest;

/**
 * @param string $formattedParent      The parent resource for Attribute.
 *                                     Format: `projects/{project}/locations/{location}`
 *                                     Please see {@see ApiHubClient::locationName()} for help formatting this field.
 * @param string $attributeDisplayName The display name of the attribute.
 * @param int    $attributeScope       The scope of the attribute. It represents the resource in the API
 *                                     Hub to which the attribute can be linked.
 * @param int    $attributeDataType    The type of the data of the attribute.
 */
function create_attribute_sample(
    string $formattedParent,
    string $attributeDisplayName,
    int $attributeScope,
    int $attributeDataType
): void {
    // Create a client.
    $apiHubClient = new ApiHubClient();

    // Prepare the request message.
    $attribute = (new Attribute())
        ->setDisplayName($attributeDisplayName)
        ->setScope($attributeScope)
        ->setDataType($attributeDataType);
    $request = (new CreateAttributeRequest())
        ->setParent($formattedParent)
        ->setAttribute($attribute);

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

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = ApiHubClient::locationName('[PROJECT]', '[LOCATION]');
    $attributeDisplayName = '[DISPLAY_NAME]';
    $attributeScope = Scope::SCOPE_UNSPECIFIED;
    $attributeDataType = DataType::DATA_TYPE_UNSPECIFIED;

    create_attribute_sample(
        $formattedParent,
        $attributeDisplayName,
        $attributeScope,
        $attributeDataType
    );
}

createDeployment

Create a deployment resource in the API hub.

Once a deployment resource is created, it can be associated with API versions.

The async variant is Google\Cloud\ApiHub\V1\Client\ApiHubClient::createDeploymentAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\CreateDeploymentRequest

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\ApiHub\V1\Deployment
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\AttributeValues;
use Google\Cloud\ApiHub\V1\Client\ApiHubClient;
use Google\Cloud\ApiHub\V1\CreateDeploymentRequest;
use Google\Cloud\ApiHub\V1\Deployment;

/**
 * @param string $formattedParent            The parent resource for the deployment resource.
 *                                           Format: `projects/{project}/locations/{location}`
 *                                           Please see {@see ApiHubClient::locationName()} for help formatting this field.
 * @param string $deploymentDisplayName      The display name of the deployment.
 * @param string $deploymentResourceUri      A URI to the runtime resource. This URI can be used to manage the
 *                                           resource. For example, if the runtime resource is of type APIGEE_PROXY,
 *                                           then this field will contain the URI to the management UI of the proxy.
 * @param string $deploymentEndpointsElement The endpoints at which this deployment resource is listening for
 *                                           API requests. This could be a list of complete URIs, hostnames or an IP
 *                                           addresses.
 */
function create_deployment_sample(
    string $formattedParent,
    string $deploymentDisplayName,
    string $deploymentResourceUri,
    string $deploymentEndpointsElement
): void {
    // Create a client.
    $apiHubClient = new ApiHubClient();

    // Prepare the request message.
    $deploymentDeploymentType = new AttributeValues();
    $deploymentEndpoints = [$deploymentEndpointsElement,];
    $deployment = (new Deployment())
        ->setDisplayName($deploymentDisplayName)
        ->setDeploymentType($deploymentDeploymentType)
        ->setResourceUri($deploymentResourceUri)
        ->setEndpoints($deploymentEndpoints);
    $request = (new CreateDeploymentRequest())
        ->setParent($formattedParent)
        ->setDeployment($deployment);

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

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = ApiHubClient::locationName('[PROJECT]', '[LOCATION]');
    $deploymentDisplayName = '[DISPLAY_NAME]';
    $deploymentResourceUri = '[RESOURCE_URI]';
    $deploymentEndpointsElement = '[ENDPOINTS]';

    create_deployment_sample(
        $formattedParent,
        $deploymentDisplayName,
        $deploymentResourceUri,
        $deploymentEndpointsElement
    );
}

createExternalApi

Create an External API resource in the API hub.

The async variant is Google\Cloud\ApiHub\V1\Client\ApiHubClient::createExternalApiAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\CreateExternalApiRequest

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\ApiHub\V1\ExternalApi
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\Client\ApiHubClient;
use Google\Cloud\ApiHub\V1\CreateExternalApiRequest;
use Google\Cloud\ApiHub\V1\ExternalApi;

/**
 * @param string $formattedParent        The parent resource for the External API resource.
 *                                       Format: `projects/{project}/locations/{location}`
 *                                       Please see {@see ApiHubClient::locationName()} for help formatting this field.
 * @param string $externalApiDisplayName Display name of the external API. Max length is 63 characters
 *                                       (Unicode Code Points).
 */
function create_external_api_sample(string $formattedParent, string $externalApiDisplayName): void
{
    // Create a client.
    $apiHubClient = new ApiHubClient();

    // Prepare the request message.
    $externalApi = (new ExternalApi())
        ->setDisplayName($externalApiDisplayName);
    $request = (new CreateExternalApiRequest())
        ->setParent($formattedParent)
        ->setExternalApi($externalApi);

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

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = ApiHubClient::locationName('[PROJECT]', '[LOCATION]');
    $externalApiDisplayName = '[DISPLAY_NAME]';

    create_external_api_sample($formattedParent, $externalApiDisplayName);
}

createSpec

Add a spec to an API version in the API hub.

Multiple specs can be added to an API version. Note, while adding a spec, at least one of contents or source_uri must be provided. If contents is provided, then spec_type must also be provided.

On adding a spec with contents to the version, the operations present in it will be added to the version.Note that the file contents in the spec should be of the same type as defined in the projects/{project}/locations/{location}/attributes/system-spec-type attribute associated with spec resource. Note that specs of various types can be uploaded, however parsing of details is supported for OpenAPI spec currently.

In order to access the information parsed from the spec, use the GetSpec method. In order to access the raw contents for a particular spec, use the GetSpecContents method. In order to access the operations parsed from the spec, use the ListAPIOperations method.

The async variant is Google\Cloud\ApiHub\V1\Client\ApiHubClient::createSpecAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\CreateSpecRequest

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\ApiHub\V1\Spec
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\AttributeValues;
use Google\Cloud\ApiHub\V1\Client\ApiHubClient;
use Google\Cloud\ApiHub\V1\CreateSpecRequest;
use Google\Cloud\ApiHub\V1\Spec;

/**
 * @param string $formattedParent The parent resource for Spec.
 *                                Format:
 *                                `projects/{project}/locations/{location}/apis/{api}/versions/{version}`
 *                                Please see {@see ApiHubClient::versionName()} for help formatting this field.
 * @param string $specDisplayName The display name of the spec.
 *                                This can contain the file name of the spec.
 */
function create_spec_sample(string $formattedParent, string $specDisplayName): void
{
    // Create a client.
    $apiHubClient = new ApiHubClient();

    // Prepare the request message.
    $specSpecType = new AttributeValues();
    $spec = (new Spec())
        ->setDisplayName($specDisplayName)
        ->setSpecType($specSpecType);
    $request = (new CreateSpecRequest())
        ->setParent($formattedParent)
        ->setSpec($spec);

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

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = ApiHubClient::versionName('[PROJECT]', '[LOCATION]', '[API]', '[VERSION]');
    $specDisplayName = '[DISPLAY_NAME]';

    create_spec_sample($formattedParent, $specDisplayName);
}

createVersion

Create an API version for an API resource in the API hub.

The async variant is Google\Cloud\ApiHub\V1\Client\ApiHubClient::createVersionAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\CreateVersionRequest

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\ApiHub\V1\Version
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\Client\ApiHubClient;
use Google\Cloud\ApiHub\V1\CreateVersionRequest;
use Google\Cloud\ApiHub\V1\Version;

/**
 * @param string $formattedParent    The parent resource for API version.
 *                                   Format: `projects/{project}/locations/{location}/apis/{api}`
 *                                   Please see {@see ApiHubClient::apiName()} for help formatting this field.
 * @param string $versionDisplayName The display name of the version.
 */
function create_version_sample(string $formattedParent, string $versionDisplayName): void
{
    // Create a client.
    $apiHubClient = new ApiHubClient();

    // Prepare the request message.
    $version = (new Version())
        ->setDisplayName($versionDisplayName);
    $request = (new CreateVersionRequest())
        ->setParent($formattedParent)
        ->setVersion($version);

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

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = ApiHubClient::apiName('[PROJECT]', '[LOCATION]', '[API]');
    $versionDisplayName = '[DISPLAY_NAME]';

    create_version_sample($formattedParent, $versionDisplayName);
}

deleteApi

Delete an API resource in the API hub. API can only be deleted if all underlying versions are deleted.

The async variant is Google\Cloud\ApiHub\V1\Client\ApiHubClient::deleteApiAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\DeleteApiRequest

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.

Example
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\Client\ApiHubClient;
use Google\Cloud\ApiHub\V1\DeleteApiRequest;

/**
 * @param string $formattedName The name of the API resource to delete.
 *                              Format: `projects/{project}/locations/{location}/apis/{api}`
 *                              Please see {@see ApiHubClient::apiName()} for help formatting this field.
 */
function delete_api_sample(string $formattedName): void
{
    // Create a client.
    $apiHubClient = new ApiHubClient();

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

    // Call the API and handle any network failures.
    try {
        $apiHubClient->deleteApi($request);
        printf('Call completed successfully.' . PHP_EOL);
    } 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 = ApiHubClient::apiName('[PROJECT]', '[LOCATION]', '[API]');

    delete_api_sample($formattedName);
}

deleteAttribute

Delete an attribute.

Note: System defined attributes cannot be deleted. All associations of the attribute being deleted with any API hub resource will also get deleted.

The async variant is Google\Cloud\ApiHub\V1\Client\ApiHubClient::deleteAttributeAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\DeleteAttributeRequest

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.

Example
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\Client\ApiHubClient;
use Google\Cloud\ApiHub\V1\DeleteAttributeRequest;

/**
 * @param string $formattedName The name of the attribute to delete.
 *                              Format:
 *                              `projects/{project}/locations/{location}/attributes/{attribute}`
 *                              Please see {@see ApiHubClient::attributeName()} for help formatting this field.
 */
function delete_attribute_sample(string $formattedName): void
{
    // Create a client.
    $apiHubClient = new ApiHubClient();

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

    // Call the API and handle any network failures.
    try {
        $apiHubClient->deleteAttribute($request);
        printf('Call completed successfully.' . PHP_EOL);
    } 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 = ApiHubClient::attributeName('[PROJECT]', '[LOCATION]', '[ATTRIBUTE]');

    delete_attribute_sample($formattedName);
}

deleteDeployment

Delete a deployment resource in the API hub.

The async variant is Google\Cloud\ApiHub\V1\Client\ApiHubClient::deleteDeploymentAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\DeleteDeploymentRequest

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.

Example
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\Client\ApiHubClient;
use Google\Cloud\ApiHub\V1\DeleteDeploymentRequest;

/**
 * @param string $formattedName The name of the deployment resource to delete.
 *                              Format: `projects/{project}/locations/{location}/deployments/{deployment}`
 *                              Please see {@see ApiHubClient::deploymentName()} for help formatting this field.
 */
function delete_deployment_sample(string $formattedName): void
{
    // Create a client.
    $apiHubClient = new ApiHubClient();

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

    // Call the API and handle any network failures.
    try {
        $apiHubClient->deleteDeployment($request);
        printf('Call completed successfully.' . PHP_EOL);
    } 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 = ApiHubClient::deploymentName('[PROJECT]', '[LOCATION]', '[DEPLOYMENT]');

    delete_deployment_sample($formattedName);
}

deleteExternalApi

Delete an External API resource in the API hub.

The async variant is Google\Cloud\ApiHub\V1\Client\ApiHubClient::deleteExternalApiAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\DeleteExternalApiRequest

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.

Example
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\Client\ApiHubClient;
use Google\Cloud\ApiHub\V1\DeleteExternalApiRequest;

/**
 * @param string $formattedName The name of the External API resource to delete.
 *                              Format:
 *                              `projects/{project}/locations/{location}/externalApis/{externalApi}`
 *                              Please see {@see ApiHubClient::externalApiName()} for help formatting this field.
 */
function delete_external_api_sample(string $formattedName): void
{
    // Create a client.
    $apiHubClient = new ApiHubClient();

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

    // Call the API and handle any network failures.
    try {
        $apiHubClient->deleteExternalApi($request);
        printf('Call completed successfully.' . PHP_EOL);
    } 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 = ApiHubClient::externalApiName('[PROJECT]', '[LOCATION]', '[EXTERNAL_API]');

    delete_external_api_sample($formattedName);
}

deleteSpec

Delete a spec.

Deleting a spec will also delete the associated operations from the version.

The async variant is Google\Cloud\ApiHub\V1\Client\ApiHubClient::deleteSpecAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\DeleteSpecRequest

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.

Example
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\Client\ApiHubClient;
use Google\Cloud\ApiHub\V1\DeleteSpecRequest;

/**
 * @param string $formattedName The name of the spec  to delete.
 *                              Format:
 *                              `projects/{project}/locations/{location}/apis/{api}/versions/{version}/specs/{spec}`
 *                              Please see {@see ApiHubClient::specName()} for help formatting this field.
 */
function delete_spec_sample(string $formattedName): void
{
    // Create a client.
    $apiHubClient = new ApiHubClient();

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

    // Call the API and handle any network failures.
    try {
        $apiHubClient->deleteSpec($request);
        printf('Call completed successfully.' . PHP_EOL);
    } 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 = ApiHubClient::specName('[PROJECT]', '[LOCATION]', '[API]', '[VERSION]', '[SPEC]');

    delete_spec_sample($formattedName);
}

deleteVersion

Delete an API version. Version can only be deleted if all underlying specs, operations, definitions and linked deployments are deleted.

The async variant is Google\Cloud\ApiHub\V1\Client\ApiHubClient::deleteVersionAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\DeleteVersionRequest

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.

Example
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\Client\ApiHubClient;
use Google\Cloud\ApiHub\V1\DeleteVersionRequest;

/**
 * @param string $formattedName The name of the version to delete.
 *                              Format:
 *                              `projects/{project}/locations/{location}/apis/{api}/versions/{version}`
 *                              Please see {@see ApiHubClient::versionName()} for help formatting this field.
 */
function delete_version_sample(string $formattedName): void
{
    // Create a client.
    $apiHubClient = new ApiHubClient();

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

    // Call the API and handle any network failures.
    try {
        $apiHubClient->deleteVersion($request);
        printf('Call completed successfully.' . PHP_EOL);
    } 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 = ApiHubClient::versionName('[PROJECT]', '[LOCATION]', '[API]', '[VERSION]');

    delete_version_sample($formattedName);
}

getApi

Get API resource details including the API versions contained in it.

The async variant is Google\Cloud\ApiHub\V1\Client\ApiHubClient::getApiAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\GetApiRequest

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\ApiHub\V1\Api
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\Api;
use Google\Cloud\ApiHub\V1\Client\ApiHubClient;
use Google\Cloud\ApiHub\V1\GetApiRequest;

/**
 * @param string $formattedName The name of the API resource to retrieve.
 *                              Format: `projects/{project}/locations/{location}/apis/{api}`
 *                              Please see {@see ApiHubClient::apiName()} for help formatting this field.
 */
function get_api_sample(string $formattedName): void
{
    // Create a client.
    $apiHubClient = new ApiHubClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Api $response */
        $response = $apiHubClient->getApi($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 = ApiHubClient::apiName('[PROJECT]', '[LOCATION]', '[API]');

    get_api_sample($formattedName);
}

getApiOperation

Get details about a particular operation in API version.

The async variant is Google\Cloud\ApiHub\V1\Client\ApiHubClient::getApiOperationAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\GetApiOperationRequest

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\ApiHub\V1\ApiOperation
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\ApiOperation;
use Google\Cloud\ApiHub\V1\Client\ApiHubClient;
use Google\Cloud\ApiHub\V1\GetApiOperationRequest;

/**
 * @param string $formattedName The name of the operation to retrieve.
 *                              Format:
 *                              `projects/{project}/locations/{location}/apis/{api}/versions/{version}/operations/{operation}`
 *                              Please see {@see ApiHubClient::apiOperationName()} for help formatting this field.
 */
function get_api_operation_sample(string $formattedName): void
{
    // Create a client.
    $apiHubClient = new ApiHubClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var ApiOperation $response */
        $response = $apiHubClient->getApiOperation($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 = ApiHubClient::apiOperationName(
        '[PROJECT]',
        '[LOCATION]',
        '[API]',
        '[VERSION]',
        '[OPERATION]'
    );

    get_api_operation_sample($formattedName);
}

getAttribute

Get details about the attribute.

The async variant is Google\Cloud\ApiHub\V1\Client\ApiHubClient::getAttributeAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\GetAttributeRequest

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\ApiHub\V1\Attribute
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\Attribute;
use Google\Cloud\ApiHub\V1\Client\ApiHubClient;
use Google\Cloud\ApiHub\V1\GetAttributeRequest;

/**
 * @param string $formattedName The name of the attribute to retrieve.
 *                              Format:
 *                              `projects/{project}/locations/{location}/attributes/{attribute}`
 *                              Please see {@see ApiHubClient::attributeName()} for help formatting this field.
 */
function get_attribute_sample(string $formattedName): void
{
    // Create a client.
    $apiHubClient = new ApiHubClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Attribute $response */
        $response = $apiHubClient->getAttribute($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 = ApiHubClient::attributeName('[PROJECT]', '[LOCATION]', '[ATTRIBUTE]');

    get_attribute_sample($formattedName);
}

getDefinition

Get details about a definition in an API version.

The async variant is Google\Cloud\ApiHub\V1\Client\ApiHubClient::getDefinitionAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\GetDefinitionRequest

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\ApiHub\V1\Definition
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\Client\ApiHubClient;
use Google\Cloud\ApiHub\V1\Definition;
use Google\Cloud\ApiHub\V1\GetDefinitionRequest;

/**
 * @param string $formattedName The name of the definition to retrieve.
 *                              Format:
 *                              `projects/{project}/locations/{location}/apis/{api}/versions/{version}/definitions/{definition}`
 *                              Please see {@see ApiHubClient::definitionName()} for help formatting this field.
 */
function get_definition_sample(string $formattedName): void
{
    // Create a client.
    $apiHubClient = new ApiHubClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Definition $response */
        $response = $apiHubClient->getDefinition($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 = ApiHubClient::definitionName(
        '[PROJECT]',
        '[LOCATION]',
        '[API]',
        '[VERSION]',
        '[DEFINITION]'
    );

    get_definition_sample($formattedName);
}

getDeployment

Get details about a deployment and the API versions linked to it.

The async variant is Google\Cloud\ApiHub\V1\Client\ApiHubClient::getDeploymentAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\GetDeploymentRequest

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\ApiHub\V1\Deployment
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\Client\ApiHubClient;
use Google\Cloud\ApiHub\V1\Deployment;
use Google\Cloud\ApiHub\V1\GetDeploymentRequest;

/**
 * @param string $formattedName The name of the deployment resource to retrieve.
 *                              Format: `projects/{project}/locations/{location}/deployments/{deployment}`
 *                              Please see {@see ApiHubClient::deploymentName()} for help formatting this field.
 */
function get_deployment_sample(string $formattedName): void
{
    // Create a client.
    $apiHubClient = new ApiHubClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Deployment $response */
        $response = $apiHubClient->getDeployment($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 = ApiHubClient::deploymentName('[PROJECT]', '[LOCATION]', '[DEPLOYMENT]');

    get_deployment_sample($formattedName);
}

getExternalApi

Get details about an External API resource in the API hub.

The async variant is Google\Cloud\ApiHub\V1\Client\ApiHubClient::getExternalApiAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\GetExternalApiRequest

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\ApiHub\V1\ExternalApi
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\Client\ApiHubClient;
use Google\Cloud\ApiHub\V1\ExternalApi;
use Google\Cloud\ApiHub\V1\GetExternalApiRequest;

/**
 * @param string $formattedName The name of the External API resource to retrieve.
 *                              Format:
 *                              `projects/{project}/locations/{location}/externalApis/{externalApi}`
 *                              Please see {@see ApiHubClient::externalApiName()} for help formatting this field.
 */
function get_external_api_sample(string $formattedName): void
{
    // Create a client.
    $apiHubClient = new ApiHubClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var ExternalApi $response */
        $response = $apiHubClient->getExternalApi($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 = ApiHubClient::externalApiName('[PROJECT]', '[LOCATION]', '[EXTERNAL_API]');

    get_external_api_sample($formattedName);
}

getSpec

Get details about the information parsed from a spec.

Note that this method does not return the raw spec contents. Use GetSpecContents method to retrieve the same.

The async variant is Google\Cloud\ApiHub\V1\Client\ApiHubClient::getSpecAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\GetSpecRequest

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\ApiHub\V1\Spec
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\Client\ApiHubClient;
use Google\Cloud\ApiHub\V1\GetSpecRequest;
use Google\Cloud\ApiHub\V1\Spec;

/**
 * @param string $formattedName The name of the spec to retrieve.
 *                              Format:
 *                              `projects/{project}/locations/{location}/apis/{api}/versions/{version}/specs/{spec}`
 *                              Please see {@see ApiHubClient::specName()} for help formatting this field.
 */
function get_spec_sample(string $formattedName): void
{
    // Create a client.
    $apiHubClient = new ApiHubClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Spec $response */
        $response = $apiHubClient->getSpec($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 = ApiHubClient::specName('[PROJECT]', '[LOCATION]', '[API]', '[VERSION]', '[SPEC]');

    get_spec_sample($formattedName);
}

getSpecContents

Parameters
Name Description
request Google\Cloud\ApiHub\V1\GetSpecContentsRequest

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\ApiHub\V1\SpecContents
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\Client\ApiHubClient;
use Google\Cloud\ApiHub\V1\GetSpecContentsRequest;
use Google\Cloud\ApiHub\V1\SpecContents;

/**
 * @param string $formattedName The name of the spec whose contents need to be retrieved.
 *                              Format:
 *                              `projects/{project}/locations/{location}/apis/{api}/versions/{version}/specs/{spec}`
 *                              Please see {@see ApiHubClient::specName()} for help formatting this field.
 */
function get_spec_contents_sample(string $formattedName): void
{
    // Create a client.
    $apiHubClient = new ApiHubClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var SpecContents $response */
        $response = $apiHubClient->getSpecContents($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 = ApiHubClient::specName('[PROJECT]', '[LOCATION]', '[API]', '[VERSION]', '[SPEC]');

    get_spec_contents_sample($formattedName);
}

getVersion

Get details about the API version of an API resource. This will include information about the specs and operations present in the API version as well as the deployments linked to it.

The async variant is Google\Cloud\ApiHub\V1\Client\ApiHubClient::getVersionAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\GetVersionRequest

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\ApiHub\V1\Version
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\Client\ApiHubClient;
use Google\Cloud\ApiHub\V1\GetVersionRequest;
use Google\Cloud\ApiHub\V1\Version;

/**
 * @param string $formattedName The name of the API version to retrieve.
 *                              Format:
 *                              `projects/{project}/locations/{location}/apis/{api}/versions/{version}`
 *                              Please see {@see ApiHubClient::versionName()} for help formatting this field.
 */
function get_version_sample(string $formattedName): void
{
    // Create a client.
    $apiHubClient = new ApiHubClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Version $response */
        $response = $apiHubClient->getVersion($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 = ApiHubClient::versionName('[PROJECT]', '[LOCATION]', '[API]', '[VERSION]');

    get_version_sample($formattedName);
}

listApiOperations

List operations in an API version.

The async variant is Google\Cloud\ApiHub\V1\Client\ApiHubClient::listApiOperationsAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\ListApiOperationsRequest

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\ApiHub\V1\ApiOperation;
use Google\Cloud\ApiHub\V1\Client\ApiHubClient;
use Google\Cloud\ApiHub\V1\ListApiOperationsRequest;

/**
 * @param string $formattedParent The parent which owns this collection of operations i.e., the API
 *                                version. Format:
 *                                `projects/{project}/locations/{location}/apis/{api}/versions/{version}`
 *                                Please see {@see ApiHubClient::versionName()} for help formatting this field.
 */
function list_api_operations_sample(string $formattedParent): void
{
    // Create a client.
    $apiHubClient = new ApiHubClient();

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

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

        /** @var ApiOperation $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 = ApiHubClient::versionName('[PROJECT]', '[LOCATION]', '[API]', '[VERSION]');

    list_api_operations_sample($formattedParent);
}

listApis

List API resources in the API hub.

The async variant is Google\Cloud\ApiHub\V1\Client\ApiHubClient::listApisAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\ListApisRequest

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\ApiHub\V1\Api;
use Google\Cloud\ApiHub\V1\Client\ApiHubClient;
use Google\Cloud\ApiHub\V1\ListApisRequest;

/**
 * @param string $formattedParent The parent, which owns this collection of API resources.
 *                                Format: `projects/{project}/locations/{location}`
 *                                Please see {@see ApiHubClient::locationName()} for help formatting this field.
 */
function list_apis_sample(string $formattedParent): void
{
    // Create a client.
    $apiHubClient = new ApiHubClient();

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

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

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

    list_apis_sample($formattedParent);
}

listAttributes

List all attributes.

The async variant is Google\Cloud\ApiHub\V1\Client\ApiHubClient::listAttributesAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\ListAttributesRequest

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\ApiHub\V1\Attribute;
use Google\Cloud\ApiHub\V1\Client\ApiHubClient;
use Google\Cloud\ApiHub\V1\ListAttributesRequest;

/**
 * @param string $formattedParent The parent resource for Attribute.
 *                                Format: `projects/{project}/locations/{location}`
 *                                Please see {@see ApiHubClient::locationName()} for help formatting this field.
 */
function list_attributes_sample(string $formattedParent): void
{
    // Create a client.
    $apiHubClient = new ApiHubClient();

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

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

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

    list_attributes_sample($formattedParent);
}

listDeployments

List deployment resources in the API hub.

The async variant is Google\Cloud\ApiHub\V1\Client\ApiHubClient::listDeploymentsAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\ListDeploymentsRequest

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\ApiHub\V1\Client\ApiHubClient;
use Google\Cloud\ApiHub\V1\Deployment;
use Google\Cloud\ApiHub\V1\ListDeploymentsRequest;

/**
 * @param string $formattedParent The parent, which owns this collection of deployment resources.
 *                                Format: `projects/{project}/locations/{location}`
 *                                Please see {@see ApiHubClient::locationName()} for help formatting this field.
 */
function list_deployments_sample(string $formattedParent): void
{
    // Create a client.
    $apiHubClient = new ApiHubClient();

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

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

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

    list_deployments_sample($formattedParent);
}

listExternalApis

List External API resources in the API hub.

The async variant is Google\Cloud\ApiHub\V1\Client\ApiHubClient::listExternalApisAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\ListExternalApisRequest

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\ApiHub\V1\Client\ApiHubClient;
use Google\Cloud\ApiHub\V1\ExternalApi;
use Google\Cloud\ApiHub\V1\ListExternalApisRequest;

/**
 * @param string $formattedParent The parent, which owns this collection of External API resources.
 *                                Format: `projects/{project}/locations/{location}`
 *                                Please see {@see ApiHubClient::locationName()} for help formatting this field.
 */
function list_external_apis_sample(string $formattedParent): void
{
    // Create a client.
    $apiHubClient = new ApiHubClient();

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

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

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

    list_external_apis_sample($formattedParent);
}

listSpecs

List specs corresponding to a particular API resource.

The async variant is Google\Cloud\ApiHub\V1\Client\ApiHubClient::listSpecsAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\ListSpecsRequest

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\ApiHub\V1\Client\ApiHubClient;
use Google\Cloud\ApiHub\V1\ListSpecsRequest;
use Google\Cloud\ApiHub\V1\Spec;

/**
 * @param string $formattedParent The parent, which owns this collection of specs.
 *                                Format:
 *                                `projects/{project}/locations/{location}/apis/{api}/versions/{version}`
 *                                Please see {@see ApiHubClient::versionName()} for help formatting this field.
 */
function list_specs_sample(string $formattedParent): void
{
    // Create a client.
    $apiHubClient = new ApiHubClient();

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

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

        /** @var Spec $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 = ApiHubClient::versionName('[PROJECT]', '[LOCATION]', '[API]', '[VERSION]');

    list_specs_sample($formattedParent);
}

listVersions

List API versions of an API resource in the API hub.

The async variant is Google\Cloud\ApiHub\V1\Client\ApiHubClient::listVersionsAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\ListVersionsRequest

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\ApiHub\V1\Client\ApiHubClient;
use Google\Cloud\ApiHub\V1\ListVersionsRequest;
use Google\Cloud\ApiHub\V1\Version;

/**
 * @param string $formattedParent The parent which owns this collection of API versions i.e., the
 *                                API resource Format: `projects/{project}/locations/{location}/apis/{api}`
 *                                Please see {@see ApiHubClient::apiName()} for help formatting this field.
 */
function list_versions_sample(string $formattedParent): void
{
    // Create a client.
    $apiHubClient = new ApiHubClient();

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

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

        /** @var Version $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 = ApiHubClient::apiName('[PROJECT]', '[LOCATION]', '[API]');

    list_versions_sample($formattedParent);
}

searchResources

Search across API-Hub resources.

The async variant is Google\Cloud\ApiHub\V1\Client\ApiHubClient::searchResourcesAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\SearchResourcesRequest

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\ApiHub\V1\Client\ApiHubClient;
use Google\Cloud\ApiHub\V1\SearchResourcesRequest;
use Google\Cloud\ApiHub\V1\SearchResult;

/**
 * @param string $formattedLocation The resource name of the location which will be of the type
 *                                  `projects/{project_id}/locations/{location_id}`. This field is used to
 *                                  identify the instance of API-Hub in which resources should be searched. Please see
 *                                  {@see ApiHubClient::locationName()} for help formatting this field.
 * @param string $query             The free text search query. This query can contain keywords which
 *                                  could be related to any detail of the API-Hub resources such display names,
 *                                  descriptions, attributes etc.
 */
function search_resources_sample(string $formattedLocation, string $query): void
{
    // Create a client.
    $apiHubClient = new ApiHubClient();

    // Prepare the request message.
    $request = (new SearchResourcesRequest())
        ->setLocation($formattedLocation)
        ->setQuery($query);

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

        /** @var SearchResult $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
{
    $formattedLocation = ApiHubClient::locationName('[PROJECT]', '[LOCATION]');
    $query = '[QUERY]';

    search_resources_sample($formattedLocation, $query);
}

updateApi

Update an API resource in the API hub. The following fields in the API can be updated:

The update_mask should be used to specify the fields being updated.

Updating the owner field requires complete owner message and updates both owner and email fields.

The async variant is Google\Cloud\ApiHub\V1\Client\ApiHubClient::updateApiAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\UpdateApiRequest

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\ApiHub\V1\Api
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\Api;
use Google\Cloud\ApiHub\V1\Client\ApiHubClient;
use Google\Cloud\ApiHub\V1\UpdateApiRequest;
use Google\Protobuf\FieldMask;

/**
 * @param string $apiDisplayName The display name of the API resource.
 */
function update_api_sample(string $apiDisplayName): void
{
    // Create a client.
    $apiHubClient = new ApiHubClient();

    // Prepare the request message.
    $api = (new Api())
        ->setDisplayName($apiDisplayName);
    $updateMask = new FieldMask();
    $request = (new UpdateApiRequest())
        ->setApi($api)
        ->setUpdateMask($updateMask);

    // Call the API and handle any network failures.
    try {
        /** @var Api $response */
        $response = $apiHubClient->updateApi($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
{
    $apiDisplayName = '[DISPLAY_NAME]';

    update_api_sample($apiDisplayName);
}

updateAttribute

Update the attribute. The following fields in the Attribute resource can be updated:

  • display_name The display name can be updated for user defined attributes only.
  • description The description can be updated for user defined attributes only.
  • allowed_values To update the list of allowed values, clients need to use the fetched list of allowed values and add or remove values to or from the same list. The mutable allowed values can be updated for both user defined and System defined attributes. The immutable allowed values cannot be updated or deleted. The updated list of allowed values cannot be empty. If an allowed value that is already used by some resource's attribute is deleted, then the association between the resource and the attribute value will also be deleted.
  • cardinality The cardinality can be updated for user defined attributes only. Cardinality can only be increased during an update.

The update_mask should be used to specify the fields being updated.

The async variant is Google\Cloud\ApiHub\V1\Client\ApiHubClient::updateAttributeAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\UpdateAttributeRequest

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\ApiHub\V1\Attribute
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\Attribute;
use Google\Cloud\ApiHub\V1\Attribute\DataType;
use Google\Cloud\ApiHub\V1\Attribute\Scope;
use Google\Cloud\ApiHub\V1\Client\ApiHubClient;
use Google\Cloud\ApiHub\V1\UpdateAttributeRequest;
use Google\Protobuf\FieldMask;

/**
 * @param string $attributeDisplayName The display name of the attribute.
 * @param int    $attributeScope       The scope of the attribute. It represents the resource in the API
 *                                     Hub to which the attribute can be linked.
 * @param int    $attributeDataType    The type of the data of the attribute.
 */
function update_attribute_sample(
    string $attributeDisplayName,
    int $attributeScope,
    int $attributeDataType
): void {
    // Create a client.
    $apiHubClient = new ApiHubClient();

    // Prepare the request message.
    $attribute = (new Attribute())
        ->setDisplayName($attributeDisplayName)
        ->setScope($attributeScope)
        ->setDataType($attributeDataType);
    $updateMask = new FieldMask();
    $request = (new UpdateAttributeRequest())
        ->setAttribute($attribute)
        ->setUpdateMask($updateMask);

    // Call the API and handle any network failures.
    try {
        /** @var Attribute $response */
        $response = $apiHubClient->updateAttribute($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
{
    $attributeDisplayName = '[DISPLAY_NAME]';
    $attributeScope = Scope::SCOPE_UNSPECIFIED;
    $attributeDataType = DataType::DATA_TYPE_UNSPECIFIED;

    update_attribute_sample($attributeDisplayName, $attributeScope, $attributeDataType);
}

updateDeployment

Update a deployment resource in the API hub. The following fields in the deployment resource can be updated:

The update_mask should be used to specify the fields being updated.

The async variant is Google\Cloud\ApiHub\V1\Client\ApiHubClient::updateDeploymentAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\UpdateDeploymentRequest

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\ApiHub\V1\Deployment
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\AttributeValues;
use Google\Cloud\ApiHub\V1\Client\ApiHubClient;
use Google\Cloud\ApiHub\V1\Deployment;
use Google\Cloud\ApiHub\V1\UpdateDeploymentRequest;
use Google\Protobuf\FieldMask;

/**
 * @param string $deploymentDisplayName      The display name of the deployment.
 * @param string $deploymentResourceUri      A URI to the runtime resource. This URI can be used to manage the
 *                                           resource. For example, if the runtime resource is of type APIGEE_PROXY,
 *                                           then this field will contain the URI to the management UI of the proxy.
 * @param string $deploymentEndpointsElement The endpoints at which this deployment resource is listening for
 *                                           API requests. This could be a list of complete URIs, hostnames or an IP
 *                                           addresses.
 */
function update_deployment_sample(
    string $deploymentDisplayName,
    string $deploymentResourceUri,
    string $deploymentEndpointsElement
): void {
    // Create a client.
    $apiHubClient = new ApiHubClient();

    // Prepare the request message.
    $deploymentDeploymentType = new AttributeValues();
    $deploymentEndpoints = [$deploymentEndpointsElement,];
    $deployment = (new Deployment())
        ->setDisplayName($deploymentDisplayName)
        ->setDeploymentType($deploymentDeploymentType)
        ->setResourceUri($deploymentResourceUri)
        ->setEndpoints($deploymentEndpoints);
    $updateMask = new FieldMask();
    $request = (new UpdateDeploymentRequest())
        ->setDeployment($deployment)
        ->setUpdateMask($updateMask);

    // Call the API and handle any network failures.
    try {
        /** @var Deployment $response */
        $response = $apiHubClient->updateDeployment($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
{
    $deploymentDisplayName = '[DISPLAY_NAME]';
    $deploymentResourceUri = '[RESOURCE_URI]';
    $deploymentEndpointsElement = '[ENDPOINTS]';

    update_deployment_sample(
        $deploymentDisplayName,
        $deploymentResourceUri,
        $deploymentEndpointsElement
    );
}

updateExternalApi

Update an External API resource in the API hub. The following fields can be updated:

The update_mask should be used to specify the fields being updated.

The async variant is Google\Cloud\ApiHub\V1\Client\ApiHubClient::updateExternalApiAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\UpdateExternalApiRequest

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\ApiHub\V1\ExternalApi
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\Client\ApiHubClient;
use Google\Cloud\ApiHub\V1\ExternalApi;
use Google\Cloud\ApiHub\V1\UpdateExternalApiRequest;
use Google\Protobuf\FieldMask;

/**
 * @param string $externalApiDisplayName Display name of the external API. Max length is 63 characters
 *                                       (Unicode Code Points).
 */
function update_external_api_sample(string $externalApiDisplayName): void
{
    // Create a client.
    $apiHubClient = new ApiHubClient();

    // Prepare the request message.
    $externalApi = (new ExternalApi())
        ->setDisplayName($externalApiDisplayName);
    $updateMask = new FieldMask();
    $request = (new UpdateExternalApiRequest())
        ->setExternalApi($externalApi)
        ->setUpdateMask($updateMask);

    // Call the API and handle any network failures.
    try {
        /** @var ExternalApi $response */
        $response = $apiHubClient->updateExternalApi($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
{
    $externalApiDisplayName = '[DISPLAY_NAME]';

    update_external_api_sample($externalApiDisplayName);
}

updateSpec

Update spec. The following fields in the spec can be updated:

In case of an OAS spec, updating spec contents can lead to:

  1. Creation, deletion and update of operations.
  2. Creation, deletion and update of definitions.
  3. Update of other info parsed out from the new spec.

In case of contents or source_uri being present in update mask, spec_type must also be present. Also, spec_type can not be present in update mask if contents or source_uri is not present.

The update_mask should be used to specify the fields being updated.

The async variant is Google\Cloud\ApiHub\V1\Client\ApiHubClient::updateSpecAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\UpdateSpecRequest

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\ApiHub\V1\Spec
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\AttributeValues;
use Google\Cloud\ApiHub\V1\Client\ApiHubClient;
use Google\Cloud\ApiHub\V1\Spec;
use Google\Cloud\ApiHub\V1\UpdateSpecRequest;
use Google\Protobuf\FieldMask;

/**
 * @param string $specDisplayName The display name of the spec.
 *                                This can contain the file name of the spec.
 */
function update_spec_sample(string $specDisplayName): void
{
    // Create a client.
    $apiHubClient = new ApiHubClient();

    // Prepare the request message.
    $specSpecType = new AttributeValues();
    $spec = (new Spec())
        ->setDisplayName($specDisplayName)
        ->setSpecType($specSpecType);
    $updateMask = new FieldMask();
    $request = (new UpdateSpecRequest())
        ->setSpec($spec)
        ->setUpdateMask($updateMask);

    // Call the API and handle any network failures.
    try {
        /** @var Spec $response */
        $response = $apiHubClient->updateSpec($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
{
    $specDisplayName = '[DISPLAY_NAME]';

    update_spec_sample($specDisplayName);
}

updateVersion

Update API version. The following fields in the version can be updated currently:

The update_mask should be used to specify the fields being updated.

The async variant is Google\Cloud\ApiHub\V1\Client\ApiHubClient::updateVersionAsync() .

Parameters
Name Description
request Google\Cloud\ApiHub\V1\UpdateVersionRequest

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\ApiHub\V1\Version
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\Client\ApiHubClient;
use Google\Cloud\ApiHub\V1\UpdateVersionRequest;
use Google\Cloud\ApiHub\V1\Version;
use Google\Protobuf\FieldMask;

/**
 * @param string $versionDisplayName The display name of the version.
 */
function update_version_sample(string $versionDisplayName): void
{
    // Create a client.
    $apiHubClient = new ApiHubClient();

    // Prepare the request message.
    $version = (new Version())
        ->setDisplayName($versionDisplayName);
    $updateMask = new FieldMask();
    $request = (new UpdateVersionRequest())
        ->setVersion($version)
        ->setUpdateMask($updateMask);

    // Call the API and handle any network failures.
    try {
        /** @var Version $response */
        $response = $apiHubClient->updateVersion($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
{
    $versionDisplayName = '[DISPLAY_NAME]';

    update_version_sample($versionDisplayName);
}

getLocation

Gets information about a location.

The async variant is Google\Cloud\ApiHub\V1\Client\ApiHubClient::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\ApiHub\V1\Client\ApiHubClient;
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.
    $apiHubClient = new ApiHubClient();

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

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

The async variant is Google\Cloud\ApiHub\V1\Client\ApiHubClient::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\ApiHub\V1\Client\ApiHubClient;
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.
    $apiHubClient = new ApiHubClient();

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

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

createApiAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\CreateApiRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

createAttributeAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\CreateAttributeRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

createDeploymentAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\CreateDeploymentRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

createExternalApiAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\CreateExternalApiRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

createSpecAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\CreateSpecRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

createVersionAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\CreateVersionRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

deleteApiAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\DeleteApiRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

deleteAttributeAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\DeleteAttributeRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

deleteDeploymentAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\DeleteDeploymentRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

deleteExternalApiAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\DeleteExternalApiRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

deleteSpecAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\DeleteSpecRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

deleteVersionAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\DeleteVersionRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getApiAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\GetApiRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getApiOperationAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\GetApiOperationRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getAttributeAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\GetAttributeRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getDefinitionAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\GetDefinitionRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getDeploymentAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\GetDeploymentRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getExternalApiAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\GetExternalApiRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getSpecAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\GetSpecRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getSpecContentsAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\GetSpecContentsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getVersionAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\GetVersionRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listApiOperationsAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\ListApiOperationsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listApisAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\ListApisRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listAttributesAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\ListAttributesRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listDeploymentsAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\ListDeploymentsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listExternalApisAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\ListExternalApisRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listSpecsAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\ListSpecsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listVersionsAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\ListVersionsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

searchResourcesAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\SearchResourcesRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

updateApiAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\UpdateApiRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

updateAttributeAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\UpdateAttributeRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

updateDeploymentAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\UpdateDeploymentRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

updateExternalApiAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\UpdateExternalApiRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

updateSpecAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\UpdateSpecRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

updateVersionAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\UpdateVersionRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getLocationAsync

Parameters
Name Description
request Google\Cloud\Location\GetLocationRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listLocationsAsync

Parameters
Name Description
request Google\Cloud\Location\ListLocationsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

static::apiName

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

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

static::apiOperationName

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

Parameters
Name Description
project string
location string
api string
version string
operation string
Returns
Type Description
string The formatted api_operation resource.

static::attributeName

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

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

static::definitionName

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

Parameters
Name Description
project string
location string
api string
version string
definition string
Returns
Type Description
string The formatted definition resource.

static::deploymentName

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

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

static::externalApiName

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

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

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

Parameters
Name Description
project string
location string
api string
version string
spec string
Returns
Type Description
string The formatted spec resource.

static::versionName

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

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

  • api: projects/{project}/locations/{location}/apis/{api}
  • apiOperation: projects/{project}/locations/{location}/apis/{api}/versions/{version}/operations/{operation}
  • attribute: projects/{project}/locations/{location}/attributes/{attribute}
  • definition: projects/{project}/locations/{location}/apis/{api}/versions/{version}/definitions/{definition}
  • deployment: projects/{project}/locations/{location}/deployments/{deployment}
  • externalApi: projects/{project}/locations/{location}/externalApis/{external_api}
  • location: projects/{project}/locations/{location}
  • spec: projects/{project}/locations/{location}/apis/{api}/versions/{version}/specs/{spec}
  • version: projects/{project}/locations/{location}/apis/{api}/versions/{version}

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.