Google Cloud Api Hub V1 Client - Class ApiHubPluginClient (0.3.0)

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

Service Description: This service is used for managing plugins inside 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. Important: If you accept a credential configuration (credential JSON/File/Stream) from an external source for authentication to Google Cloud Platform, you must validate it before providing it to any Google API or library. Providing an unvalidated credential configuration to Google APIs can compromise the security of your systems and data. For more information https://cloud.google.com/docs/authentication/external/externally-sourced-credentials

↳ credentialsConfig array

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

↳ disableRetries bool

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

↳ clientConfig string|array

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

↳ transport string|TransportInterface

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

↳ logger false|LoggerInterface

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

createPlugin

Create an API Hub plugin resource in the API hub.

Once a plugin is created, it can be used to create plugin instances.

The async variant is ApiHubPluginClient::createPluginAsync() .

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

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\Plugin
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\Client\ApiHubPluginClient;
use Google\Cloud\ApiHub\V1\CreatePluginRequest;
use Google\Cloud\ApiHub\V1\Plugin;

/**
 * @param string $formattedParent   The parent resource where this plugin will be created.
 *                                  Format: `projects/{project}/locations/{location}`. Please see
 *                                  {@see ApiHubPluginClient::locationName()} for help formatting this field.
 * @param string $pluginDisplayName The display name of the plugin. Max length is 50 characters
 *                                  (Unicode code points).
 */
function create_plugin_sample(string $formattedParent, string $pluginDisplayName): void
{
    // Create a client.
    $apiHubPluginClient = new ApiHubPluginClient();

    // Prepare the request message.
    $plugin = (new Plugin())
        ->setDisplayName($pluginDisplayName);
    $request = (new CreatePluginRequest())
        ->setParent($formattedParent)
        ->setPlugin($plugin);

    // Call the API and handle any network failures.
    try {
        /** @var Plugin $response */
        $response = $apiHubPluginClient->createPlugin($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 = ApiHubPluginClient::locationName('[PROJECT]', '[LOCATION]');
    $pluginDisplayName = '[DISPLAY_NAME]';

    create_plugin_sample($formattedParent, $pluginDisplayName);
}

createPluginInstance

Creates a Plugin instance in the API hub.

The async variant is ApiHubPluginClient::createPluginInstanceAsync() .

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

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

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

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\ApiHub\V1\Client\ApiHubPluginClient;
use Google\Cloud\ApiHub\V1\CreatePluginInstanceRequest;
use Google\Cloud\ApiHub\V1\PluginInstance;
use Google\Cloud\ApiHub\V1\PluginInstanceAction;
use Google\Rpc\Status;

/**
 * @param string $formattedParent               The parent of the plugin instance resource.
 *                                              Format: `projects/{project}/locations/{location}/plugins/{plugin}`
 *                                              Please see {@see ApiHubPluginClient::pluginName()} for help formatting this field.
 * @param string $pluginInstanceDisplayName     The display name for this plugin instance. Max length is 255
 *                                              characters.
 * @param string $pluginInstanceActionsActionId This should map to one of the [action
 *                                              id][google.cloud.apihub.v1.PluginActionConfig.id] specified in
 *                                              [actions_config][google.cloud.apihub.v1.Plugin.actions_config] in the
 *                                              plugin.
 */
function create_plugin_instance_sample(
    string $formattedParent,
    string $pluginInstanceDisplayName,
    string $pluginInstanceActionsActionId
): void {
    // Create a client.
    $apiHubPluginClient = new ApiHubPluginClient();

    // Prepare the request message.
    $pluginInstanceAction = (new PluginInstanceAction())
        ->setActionId($pluginInstanceActionsActionId);
    $pluginInstanceActions = [$pluginInstanceAction,];
    $pluginInstance = (new PluginInstance())
        ->setDisplayName($pluginInstanceDisplayName)
        ->setActions($pluginInstanceActions);
    $request = (new CreatePluginInstanceRequest())
        ->setParent($formattedParent)
        ->setPluginInstance($pluginInstance);

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

        if ($response->operationSucceeded()) {
            /** @var PluginInstance $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

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

    create_plugin_instance_sample(
        $formattedParent,
        $pluginInstanceDisplayName,
        $pluginInstanceActionsActionId
    );
}

deletePlugin

Delete a Plugin in API hub.

Note, only user owned plugins can be deleted via this method.

The async variant is ApiHubPluginClient::deletePluginAsync() .

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

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

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

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\ApiHub\V1\Client\ApiHubPluginClient;
use Google\Cloud\ApiHub\V1\DeletePluginRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName The name of the Plugin resource to delete.
 *                              Format: `projects/{project}/locations/{location}/plugins/{plugin}`
 *                              Please see {@see ApiHubPluginClient::pluginName()} for help formatting this field.
 */
function delete_plugin_sample(string $formattedName): void
{
    // Create a client.
    $apiHubPluginClient = new ApiHubPluginClient();

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

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

        if ($response->operationSucceeded()) {
            printf('Operation completed successfully.' . PHP_EOL);
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

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

    delete_plugin_sample($formattedName);
}

deletePluginInstance

Deletes a plugin instance in the API hub.

The async variant is ApiHubPluginClient::deletePluginInstanceAsync() .

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

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

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

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\ApiHub\V1\Client\ApiHubPluginClient;
use Google\Cloud\ApiHub\V1\DeletePluginInstanceRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName The name of the plugin instance to delete.
 *                              Format:
 *                              `projects/{project}/locations/{location}/plugins/{plugin}/instances/{instance}`. Please see
 *                              {@see ApiHubPluginClient::pluginInstanceName()} for help formatting this field.
 */
function delete_plugin_instance_sample(string $formattedName): void
{
    // Create a client.
    $apiHubPluginClient = new ApiHubPluginClient();

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

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

        if ($response->operationSucceeded()) {
            printf('Operation completed successfully.' . PHP_EOL);
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

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

    delete_plugin_instance_sample($formattedName);
}

disablePlugin

Disables a plugin.

The state of the plugin after disabling is DISABLED

The async variant is ApiHubPluginClient::disablePluginAsync() .

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

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\Plugin
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\Client\ApiHubPluginClient;
use Google\Cloud\ApiHub\V1\DisablePluginRequest;
use Google\Cloud\ApiHub\V1\Plugin;

/**
 * @param string $formattedName The name of the plugin to disable.
 *                              Format: `projects/{project}/locations/{location}/plugins/{plugin}`. Please see
 *                              {@see ApiHubPluginClient::pluginName()} for help formatting this field.
 */
function disable_plugin_sample(string $formattedName): void
{
    // Create a client.
    $apiHubPluginClient = new ApiHubPluginClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Plugin $response */
        $response = $apiHubPluginClient->disablePlugin($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 = ApiHubPluginClient::pluginName('[PROJECT]', '[LOCATION]', '[PLUGIN]');

    disable_plugin_sample($formattedName);
}

disablePluginInstanceAction

Disables a plugin instance in the API hub.

The async variant is ApiHubPluginClient::disablePluginInstanceActionAsync() .

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

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

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

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\ApiHub\V1\Client\ApiHubPluginClient;
use Google\Cloud\ApiHub\V1\DisablePluginInstanceActionRequest;
use Google\Cloud\ApiHub\V1\DisablePluginInstanceActionResponse;
use Google\Rpc\Status;

/**
 * @param string $formattedName The name of the plugin instance to disable.
 *                              Format:
 *                              `projects/{project}/locations/{location}/plugins/{plugin}/instances/{instance}`
 *                              Please see {@see ApiHubPluginClient::pluginInstanceName()} for help formatting this field.
 * @param string $actionId      The action id to disable.
 */
function disable_plugin_instance_action_sample(string $formattedName, string $actionId): void
{
    // Create a client.
    $apiHubPluginClient = new ApiHubPluginClient();

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

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

        if ($response->operationSucceeded()) {
            /** @var DisablePluginInstanceActionResponse $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

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

    disable_plugin_instance_action_sample($formattedName, $actionId);
}

enablePlugin

Enables a plugin.

The state of the plugin after enabling is ENABLED

The async variant is ApiHubPluginClient::enablePluginAsync() .

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

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\Plugin
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\Client\ApiHubPluginClient;
use Google\Cloud\ApiHub\V1\EnablePluginRequest;
use Google\Cloud\ApiHub\V1\Plugin;

/**
 * @param string $formattedName The name of the plugin to enable.
 *                              Format: `projects/{project}/locations/{location}/plugins/{plugin}`. Please see
 *                              {@see ApiHubPluginClient::pluginName()} for help formatting this field.
 */
function enable_plugin_sample(string $formattedName): void
{
    // Create a client.
    $apiHubPluginClient = new ApiHubPluginClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Plugin $response */
        $response = $apiHubPluginClient->enablePlugin($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 = ApiHubPluginClient::pluginName('[PROJECT]', '[LOCATION]', '[PLUGIN]');

    enable_plugin_sample($formattedName);
}

enablePluginInstanceAction

Enables a plugin instance in the API hub.

The async variant is ApiHubPluginClient::enablePluginInstanceActionAsync() .

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

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

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

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\ApiHub\V1\Client\ApiHubPluginClient;
use Google\Cloud\ApiHub\V1\EnablePluginInstanceActionRequest;
use Google\Cloud\ApiHub\V1\EnablePluginInstanceActionResponse;
use Google\Rpc\Status;

/**
 * @param string $formattedName The name of the plugin instance to enable.
 *                              Format:
 *                              `projects/{project}/locations/{location}/plugins/{plugin}/instances/{instance}`
 *                              Please see {@see ApiHubPluginClient::pluginInstanceName()} for help formatting this field.
 * @param string $actionId      The action id to enable.
 */
function enable_plugin_instance_action_sample(string $formattedName, string $actionId): void
{
    // Create a client.
    $apiHubPluginClient = new ApiHubPluginClient();

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

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

        if ($response->operationSucceeded()) {
            /** @var EnablePluginInstanceActionResponse $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

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

    enable_plugin_instance_action_sample($formattedName, $actionId);
}

executePluginInstanceAction

Executes a plugin instance in the API hub.

The async variant is ApiHubPluginClient::executePluginInstanceActionAsync() .

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

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

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

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\ApiHub\V1\ActionExecutionDetail;
use Google\Cloud\ApiHub\V1\Client\ApiHubPluginClient;
use Google\Cloud\ApiHub\V1\ExecutePluginInstanceActionRequest;
use Google\Cloud\ApiHub\V1\ExecutePluginInstanceActionResponse;
use Google\Rpc\Status;

/**
 * @param string $formattedName                 The name of the plugin instance to execute.
 *                                              Format:
 *                                              `projects/{project}/locations/{location}/plugins/{plugin}/instances/{instance}`
 *                                              Please see {@see ApiHubPluginClient::pluginInstanceName()} for help formatting this field.
 * @param string $actionExecutionDetailActionId The action id of the plugin to execute.
 */
function execute_plugin_instance_action_sample(
    string $formattedName,
    string $actionExecutionDetailActionId
): void {
    // Create a client.
    $apiHubPluginClient = new ApiHubPluginClient();

    // Prepare the request message.
    $actionExecutionDetail = (new ActionExecutionDetail())
        ->setActionId($actionExecutionDetailActionId);
    $request = (new ExecutePluginInstanceActionRequest())
        ->setName($formattedName)
        ->setActionExecutionDetail($actionExecutionDetail);

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

        if ($response->operationSucceeded()) {
            /** @var ExecutePluginInstanceActionResponse $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

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

    execute_plugin_instance_action_sample($formattedName, $actionExecutionDetailActionId);
}

getPlugin

Get an API Hub plugin.

The async variant is ApiHubPluginClient::getPluginAsync() .

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

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\Plugin
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\Client\ApiHubPluginClient;
use Google\Cloud\ApiHub\V1\GetPluginRequest;
use Google\Cloud\ApiHub\V1\Plugin;

/**
 * @param string $formattedName The name of the plugin to retrieve.
 *                              Format: `projects/{project}/locations/{location}/plugins/{plugin}`. Please see
 *                              {@see ApiHubPluginClient::pluginName()} for help formatting this field.
 */
function get_plugin_sample(string $formattedName): void
{
    // Create a client.
    $apiHubPluginClient = new ApiHubPluginClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Plugin $response */
        $response = $apiHubPluginClient->getPlugin($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 = ApiHubPluginClient::pluginName('[PROJECT]', '[LOCATION]', '[PLUGIN]');

    get_plugin_sample($formattedName);
}

getPluginInstance

Get an API Hub plugin instance.

The async variant is ApiHubPluginClient::getPluginInstanceAsync() .

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

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\PluginInstance
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\Client\ApiHubPluginClient;
use Google\Cloud\ApiHub\V1\GetPluginInstanceRequest;
use Google\Cloud\ApiHub\V1\PluginInstance;

/**
 * @param string $formattedName The name of the plugin instance to retrieve.
 *                              Format:
 *                              `projects/{project}/locations/{location}/plugins/{plugin}/instances/{instance}`
 *                              Please see {@see ApiHubPluginClient::pluginInstanceName()} for help formatting this field.
 */
function get_plugin_instance_sample(string $formattedName): void
{
    // Create a client.
    $apiHubPluginClient = new ApiHubPluginClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var PluginInstance $response */
        $response = $apiHubPluginClient->getPluginInstance($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 = ApiHubPluginClient::pluginInstanceName(
        '[PROJECT]',
        '[LOCATION]',
        '[PLUGIN]',
        '[INSTANCE]'
    );

    get_plugin_instance_sample($formattedName);
}

listPluginInstances

List all the plugins in a given project and location.

- can be used as wildcard value for {plugin_id}

The async variant is ApiHubPluginClient::listPluginInstancesAsync() .

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

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\ApiHubPluginClient;
use Google\Cloud\ApiHub\V1\ListPluginInstancesRequest;

/**
 * @param string $formattedParent The parent resource where this plugin will be created.
 *                                Format: `projects/{project}/locations/{location}/plugins/{plugin}`.
 *                                To list plugin instances for multiple plugins,
 *                                use the - character instead of the plugin ID. Please see
 *                                {@see ApiHubPluginClient::pluginName()} for help formatting this field.
 */
function list_plugin_instances_sample(string $formattedParent): void
{
    // Create a client.
    $apiHubPluginClient = new ApiHubPluginClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $apiHubPluginClient->listPluginInstances($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 = ApiHubPluginClient::pluginName('[PROJECT]', '[LOCATION]', '[PLUGIN]');

    list_plugin_instances_sample($formattedParent);
}

listPlugins

List all the plugins in a given project and location.

The async variant is ApiHubPluginClient::listPluginsAsync() .

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

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\ApiHubPluginClient;
use Google\Cloud\ApiHub\V1\ListPluginsRequest;

/**
 * @param string $formattedParent The parent resource where this plugin will be created.
 *                                Format: `projects/{project}/locations/{location}`. Please see
 *                                {@see ApiHubPluginClient::locationName()} for help formatting this field.
 */
function list_plugins_sample(string $formattedParent): void
{
    // Create a client.
    $apiHubPluginClient = new ApiHubPluginClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $apiHubPluginClient->listPlugins($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 = ApiHubPluginClient::locationName('[PROJECT]', '[LOCATION]');

    list_plugins_sample($formattedParent);
}

updatePluginInstance

Updates a plugin instance in the API hub.

The following fields in the plugin_instance can be updated currently:

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

To update the auth_config and additional_config of the plugin instance, use the ApplyPluginInstanceConfig method.

The async variant is ApiHubPluginClient::updatePluginInstanceAsync() .

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

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\PluginInstance
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\Client\ApiHubPluginClient;
use Google\Cloud\ApiHub\V1\PluginInstance;
use Google\Cloud\ApiHub\V1\PluginInstanceAction;
use Google\Cloud\ApiHub\V1\UpdatePluginInstanceRequest;

/**
 * @param string $pluginInstanceDisplayName     The display name for this plugin instance. Max length is 255
 *                                              characters.
 * @param string $pluginInstanceActionsActionId This should map to one of the [action
 *                                              id][google.cloud.apihub.v1.PluginActionConfig.id] specified in
 *                                              [actions_config][google.cloud.apihub.v1.Plugin.actions_config] in the
 *                                              plugin.
 */
function update_plugin_instance_sample(
    string $pluginInstanceDisplayName,
    string $pluginInstanceActionsActionId
): void {
    // Create a client.
    $apiHubPluginClient = new ApiHubPluginClient();

    // Prepare the request message.
    $pluginInstanceAction = (new PluginInstanceAction())
        ->setActionId($pluginInstanceActionsActionId);
    $pluginInstanceActions = [$pluginInstanceAction,];
    $pluginInstance = (new PluginInstance())
        ->setDisplayName($pluginInstanceDisplayName)
        ->setActions($pluginInstanceActions);
    $request = (new UpdatePluginInstanceRequest())
        ->setPluginInstance($pluginInstance);

    // Call the API and handle any network failures.
    try {
        /** @var PluginInstance $response */
        $response = $apiHubPluginClient->updatePluginInstance($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
{
    $pluginInstanceDisplayName = '[DISPLAY_NAME]';
    $pluginInstanceActionsActionId = '[ACTION_ID]';

    update_plugin_instance_sample($pluginInstanceDisplayName, $pluginInstanceActionsActionId);
}

getLocation

Gets information about a location.

The async variant is ApiHubPluginClient::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\ApiHubPluginClient;
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.
    $apiHubPluginClient = new ApiHubPluginClient();

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

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

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

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

createPluginAsync

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

createPluginInstanceAsync

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

deletePluginAsync

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

deletePluginInstanceAsync

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

disablePluginAsync

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

disablePluginInstanceActionAsync

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

enablePluginAsync

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

enablePluginInstanceActionAsync

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

executePluginInstanceActionAsync

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

getPluginAsync

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

getPluginInstanceAsync

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

listPluginInstancesAsync

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

listPluginsAsync

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

updatePluginInstanceAsync

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

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>

getOperationsClient

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

Returns
Type Description
Google\LongRunning\Client\OperationsClient

resumeOperation

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

Parameters
Name Description
operationName string

The name of the long running operation

methodName string

The name of the method used to start the operation

Returns
Type Description
Google\ApiCore\OperationResponse

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

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

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

static::pluginInstanceName

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

Parameters
Name Description
project string
location string
plugin string
instance string
Returns
Type Description
string The formatted plugin_instance resource.

static::serviceAccountName

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

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

  • attribute: projects/{project}/locations/{location}/attributes/{attribute}
  • location: projects/{project}/locations/{location}
  • plugin: projects/{project}/locations/{location}/plugins/{plugin}
  • pluginInstance: projects/{project}/locations/{location}/plugins/{plugin}/instances/{instance}
  • serviceAccount: projects/{project}/serviceAccounts/{service_account}

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.