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

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. At the moment, supports only rest. Advanced usage: Additionally, it is possible to pass in an already instantiated Google\ApiCore\Transport\TransportInterface object. Note that when this object is provided, any settings in $transportConfig, and any $apiEndpoint setting, will be ignored.

↳ transportConfig array

Configuration options that will be used to construct the transport. Options for each supported transport type should be passed in a key for that transport. For example: $transportConfig = [ 'rest' => [...], ]; See the Google\ApiCore\Transport\RestTransport::build() method for the supported options.

↳ clientCertSource callable

A callable which returns the client cert as a string. This can be used to provide a certificate and private key to the transport layer for mTLS.

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

Get spec contents.

The async variant is ApiHubClient::getSpecContentsAsync() .

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 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 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\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);

        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 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\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);

        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 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\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);

        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 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\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);

        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 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\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);

        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 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;

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

        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 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;

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

        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 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;

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

        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 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 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 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 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 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 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 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 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;

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

        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<Google\Cloud\ApiHub\V1\Api>

createAttributeAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\CreateAttributeRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\ApiHub\V1\Attribute>

createDeploymentAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\CreateDeploymentRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\ApiHub\V1\Deployment>

createExternalApiAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\CreateExternalApiRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\ApiHub\V1\ExternalApi>

createSpecAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\CreateSpecRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\ApiHub\V1\Spec>

createVersionAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\CreateVersionRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\ApiHub\V1\Version>

deleteApiAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\DeleteApiRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<void>

deleteAttributeAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\DeleteAttributeRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<void>

deleteDeploymentAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\DeleteDeploymentRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<void>

deleteExternalApiAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\DeleteExternalApiRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<void>

deleteSpecAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\DeleteSpecRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<void>

deleteVersionAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\DeleteVersionRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<void>

getApiAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\GetApiRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\ApiHub\V1\Api>

getApiOperationAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\GetApiOperationRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\ApiHub\V1\ApiOperation>

getAttributeAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\GetAttributeRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\ApiHub\V1\Attribute>

getDefinitionAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\GetDefinitionRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\ApiHub\V1\Definition>

getDeploymentAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\GetDeploymentRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\ApiHub\V1\Deployment>

getExternalApiAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\GetExternalApiRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\ApiHub\V1\ExternalApi>

getSpecAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\GetSpecRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\ApiHub\V1\Spec>

getSpecContentsAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\GetSpecContentsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\ApiHub\V1\SpecContents>

getVersionAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\GetVersionRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\ApiHub\V1\Version>

listApiOperationsAsync

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

listApisAsync

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

listAttributesAsync

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

listDeploymentsAsync

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

listExternalApisAsync

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

listSpecsAsync

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

listVersionsAsync

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

searchResourcesAsync

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

updateApiAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\UpdateApiRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\ApiHub\V1\Api>

updateAttributeAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\UpdateAttributeRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\ApiHub\V1\Attribute>

updateDeploymentAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\UpdateDeploymentRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\ApiHub\V1\Deployment>

updateExternalApiAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\UpdateExternalApiRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\ApiHub\V1\ExternalApi>

updateSpecAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\UpdateSpecRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\ApiHub\V1\Spec>

updateVersionAsync

Parameters
Name Description
request Google\Cloud\ApiHub\V1\UpdateVersionRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\ApiHub\V1\Version>

getLocationAsync

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

listLocationsAsync

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

static::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.