Google Cloud Web Security Scanner V1beta Client - Class WebSecurityScannerClient (0.8.5)

Reference documentation and code samples for the Google Cloud Web Security Scanner V1beta Client class WebSecurityScannerClient.

Service Description: Cloud Web Security Scanner Service identifies security vulnerabilities in web applications hosted on Google Cloud Platform. It crawls your application, and attempts to exercise as many user inputs and event handlers as possible.

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

$webSecurityScannerClient = new WebSecurityScannerClient();
try {
    $formattedParent = $webSecurityScannerClient->projectName('[PROJECT]');
    $scanConfig = new ScanConfig();
    $response = $webSecurityScannerClient->createScanConfig($formattedParent, $scanConfig);
} finally {
    $webSecurityScannerClient->close();
}

Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parseName method to extract the individual identifiers contained within formatted names that are returned by the API.

Namespace

Google \ Cloud \ WebSecurityScanner \ V1beta

Methods

__construct

Constructor.

Parameters
Name Description
options array

Optional. Options for configuring the service API wrapper.

↳ apiEndpoint string

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

↳ credentials string|array|FetchAuthTokenInterface|CredentialsWrapper

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

↳ credentialsConfig array

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

↳ disableRetries bool

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

↳ clientConfig string|array

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

↳ transport string|TransportInterface

The transport used for executing network requests. May be either the string rest or grpc. Defaults to grpc if gRPC support is detected on the system. Advanced usage: Additionally, it is possible to pass in an already instantiated Google\ApiCore\Transport\TransportInterface object. Note that when this object is provided, any settings in $transportConfig, and any $apiEndpoint setting, will be ignored.

↳ transportConfig array

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

↳ clientCertSource callable

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

createScanConfig

Creates a new ScanConfig.

Parameters
Name Description
parent string

Required. The parent resource name where the scan is created, which should be a project resource name in the format 'projects/{projectId}'.

scanConfig Google\Cloud\WebSecurityScanner\V1beta\ScanConfig

Required. The ScanConfig to be created.

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

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

Returns
Type Description
Google\Cloud\WebSecurityScanner\V1beta\ScanConfig
Example
use Google\ApiCore\ApiException;
use Google\Cloud\WebSecurityScanner\V1beta\ScanConfig;
use Google\Cloud\WebSecurityScanner\V1beta\WebSecurityScannerClient;

/**
 * @param string $formattedParent               The parent resource name where the scan is created, which should be a
 *                                              project resource name in the format 'projects/{projectId}'. Please see
 *                                              {@see WebSecurityScannerClient::projectName()} for help formatting this field.
 * @param string $scanConfigDisplayName         The user provided display name of the ScanConfig.
 * @param string $scanConfigStartingUrlsElement The starting URLs from which the scanner finds site pages.
 */
function create_scan_config_sample(
    string $formattedParent,
    string $scanConfigDisplayName,
    string $scanConfigStartingUrlsElement
): void {
    // Create a client.
    $webSecurityScannerClient = new WebSecurityScannerClient();

    // Prepare any non-scalar elements to be passed along with the request.
    $scanConfigStartingUrls = [$scanConfigStartingUrlsElement,];
    $scanConfig = (new ScanConfig())
        ->setDisplayName($scanConfigDisplayName)
        ->setStartingUrls($scanConfigStartingUrls);

    // Call the API and handle any network failures.
    try {
        /** @var ScanConfig $response */
        $response = $webSecurityScannerClient->createScanConfig($formattedParent, $scanConfig);
        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 = WebSecurityScannerClient::projectName('[PROJECT]');
    $scanConfigDisplayName = '[DISPLAY_NAME]';
    $scanConfigStartingUrlsElement = '[STARTING_URLS]';

    create_scan_config_sample($formattedParent, $scanConfigDisplayName, $scanConfigStartingUrlsElement);
}

deleteScanConfig

Deletes an existing ScanConfig and its child resources.

Parameters
Name Description
name string

Required. The resource name of the ScanConfig to be deleted. The name follows the format of 'projects/{projectId}/scanConfigs/{scanConfigId}'.

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

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

Example
use Google\ApiCore\ApiException;
use Google\Cloud\WebSecurityScanner\V1beta\WebSecurityScannerClient;

/**
 * @param string $formattedName The resource name of the ScanConfig to be deleted. The name follows the
 *                              format of 'projects/{projectId}/scanConfigs/{scanConfigId}'. Please see
 *                              {@see WebSecurityScannerClient::scanConfigName()} for help formatting this field.
 */
function delete_scan_config_sample(string $formattedName): void
{
    // Create a client.
    $webSecurityScannerClient = new WebSecurityScannerClient();

    // Call the API and handle any network failures.
    try {
        $webSecurityScannerClient->deleteScanConfig($formattedName);
        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 = WebSecurityScannerClient::scanConfigName('[PROJECT]', '[SCAN_CONFIG]');

    delete_scan_config_sample($formattedName);
}

getFinding

Gets a Finding.

Parameters
Name Description
name string

Required. The resource name of the Finding to be returned. The name follows the format of 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}/findings/{findingId}'.

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

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

Returns
Type Description
Google\Cloud\WebSecurityScanner\V1beta\Finding
Example
use Google\ApiCore\ApiException;
use Google\Cloud\WebSecurityScanner\V1beta\Finding;
use Google\Cloud\WebSecurityScanner\V1beta\WebSecurityScannerClient;

/**
 * @param string $formattedName The resource name of the Finding to be returned. The name follows the
 *                              format of
 *                              'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}/findings/{findingId}'. Please see
 *                              {@see WebSecurityScannerClient::findingName()} for help formatting this field.
 */
function get_finding_sample(string $formattedName): void
{
    // Create a client.
    $webSecurityScannerClient = new WebSecurityScannerClient();

    // Call the API and handle any network failures.
    try {
        /** @var Finding $response */
        $response = $webSecurityScannerClient->getFinding($formattedName);
        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 = WebSecurityScannerClient::findingName(
        '[PROJECT]',
        '[SCAN_CONFIG]',
        '[SCAN_RUN]',
        '[FINDING]'
    );

    get_finding_sample($formattedName);
}

getScanConfig

Gets a ScanConfig.

Parameters
Name Description
name string

Required. The resource name of the ScanConfig to be returned. The name follows the format of 'projects/{projectId}/scanConfigs/{scanConfigId}'.

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

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

Returns
Type Description
Google\Cloud\WebSecurityScanner\V1beta\ScanConfig
Example
use Google\ApiCore\ApiException;
use Google\Cloud\WebSecurityScanner\V1beta\ScanConfig;
use Google\Cloud\WebSecurityScanner\V1beta\WebSecurityScannerClient;

/**
 * @param string $formattedName The resource name of the ScanConfig to be returned. The name follows the
 *                              format of 'projects/{projectId}/scanConfigs/{scanConfigId}'. Please see
 *                              {@see WebSecurityScannerClient::scanConfigName()} for help formatting this field.
 */
function get_scan_config_sample(string $formattedName): void
{
    // Create a client.
    $webSecurityScannerClient = new WebSecurityScannerClient();

    // Call the API and handle any network failures.
    try {
        /** @var ScanConfig $response */
        $response = $webSecurityScannerClient->getScanConfig($formattedName);
        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 = WebSecurityScannerClient::scanConfigName('[PROJECT]', '[SCAN_CONFIG]');

    get_scan_config_sample($formattedName);
}

getScanRun

Gets a ScanRun.

Parameters
Name Description
name string

Required. The resource name of the ScanRun to be returned. The name follows the format of 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'.

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

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

Returns
Type Description
Google\Cloud\WebSecurityScanner\V1beta\ScanRun
Example
use Google\ApiCore\ApiException;
use Google\Cloud\WebSecurityScanner\V1beta\ScanRun;
use Google\Cloud\WebSecurityScanner\V1beta\WebSecurityScannerClient;

/**
 * @param string $formattedName The resource name of the ScanRun to be returned. The name follows the
 *                              format of
 *                              'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. Please see
 *                              {@see WebSecurityScannerClient::scanRunName()} for help formatting this field.
 */
function get_scan_run_sample(string $formattedName): void
{
    // Create a client.
    $webSecurityScannerClient = new WebSecurityScannerClient();

    // Call the API and handle any network failures.
    try {
        /** @var ScanRun $response */
        $response = $webSecurityScannerClient->getScanRun($formattedName);
        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 = WebSecurityScannerClient::scanRunName('[PROJECT]', '[SCAN_CONFIG]', '[SCAN_RUN]');

    get_scan_run_sample($formattedName);
}

listCrawledUrls

List CrawledUrls under a given ScanRun.

Parameters
Name Description
parent string

Required. The parent resource name, which should be a scan run resource name in the format 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'.

optionalArgs array

Optional.

↳ pageToken string

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

↳ pageSize int

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

↳ 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\WebSecurityScanner\V1beta\CrawledUrl;
use Google\Cloud\WebSecurityScanner\V1beta\WebSecurityScannerClient;

/**
 * @param string $formattedParent The parent resource name, which should be a scan run resource name in the
 *                                format
 *                                'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. Please see
 *                                {@see WebSecurityScannerClient::scanRunName()} for help formatting this field.
 */
function list_crawled_urls_sample(string $formattedParent): void
{
    // Create a client.
    $webSecurityScannerClient = new WebSecurityScannerClient();

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

        /** @var CrawledUrl $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

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

    list_crawled_urls_sample($formattedParent);
}

listFindingTypeStats

List all FindingTypeStats under a given ScanRun.

Parameters
Name Description
parent string

Required. The parent resource name, which should be a scan run resource name in the format 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'.

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

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

Returns
Type Description
Google\Cloud\WebSecurityScanner\V1beta\ListFindingTypeStatsResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\WebSecurityScanner\V1beta\ListFindingTypeStatsResponse;
use Google\Cloud\WebSecurityScanner\V1beta\WebSecurityScannerClient;

/**
 * @param string $formattedParent The parent resource name, which should be a scan run resource name in the
 *                                format
 *                                'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. Please see
 *                                {@see WebSecurityScannerClient::scanRunName()} for help formatting this field.
 */
function list_finding_type_stats_sample(string $formattedParent): void
{
    // Create a client.
    $webSecurityScannerClient = new WebSecurityScannerClient();

    // Call the API and handle any network failures.
    try {
        /** @var ListFindingTypeStatsResponse $response */
        $response = $webSecurityScannerClient->listFindingTypeStats($formattedParent);
        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 = WebSecurityScannerClient::scanRunName(
        '[PROJECT]',
        '[SCAN_CONFIG]',
        '[SCAN_RUN]'
    );

    list_finding_type_stats_sample($formattedParent);
}

listFindings

List Findings under a given ScanRun.

Parameters
Name Description
parent string

Required. The parent resource name, which should be a scan run resource name in the format 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'.

filter string

Required. The filter expression. The expression must be in the format:

optionalArgs array

Optional.

↳ pageToken string

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

↳ pageSize int

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

↳ 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\WebSecurityScanner\V1beta\Finding;
use Google\Cloud\WebSecurityScanner\V1beta\WebSecurityScannerClient;

/**
 * @param string $formattedParent The parent resource name, which should be a scan run resource name in the
 *                                format
 *                                'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. Please see
 *                                {@see WebSecurityScannerClient::scanRunName()} for help formatting this field.
 * @param string $filter          The filter expression. The expression must be in the format: <field>
 *                                <operator> <value>.
 *                                Supported field: 'finding_type'.
 *                                Supported operator: '='.
 */
function list_findings_sample(string $formattedParent, string $filter): void
{
    // Create a client.
    $webSecurityScannerClient = new WebSecurityScannerClient();

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

        /** @var Finding $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

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

    list_findings_sample($formattedParent, $filter);
}

listScanConfigs

Lists ScanConfigs under a given project.

Parameters
Name Description
parent string

Required. The parent resource name, which should be a project resource name in the format 'projects/{projectId}'.

optionalArgs array

Optional.

↳ pageToken string

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

↳ pageSize int

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

↳ 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\WebSecurityScanner\V1beta\ScanConfig;
use Google\Cloud\WebSecurityScanner\V1beta\WebSecurityScannerClient;

/**
 * @param string $formattedParent The parent resource name, which should be a project resource name in the
 *                                format 'projects/{projectId}'. Please see
 *                                {@see WebSecurityScannerClient::projectName()} for help formatting this field.
 */
function list_scan_configs_sample(string $formattedParent): void
{
    // Create a client.
    $webSecurityScannerClient = new WebSecurityScannerClient();

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

        /** @var ScanConfig $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

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

    list_scan_configs_sample($formattedParent);
}

listScanRuns

Lists ScanRuns under a given ScanConfig, in descending order of ScanRun stop time.

Parameters
Name Description
parent string

Required. The parent resource name, which should be a scan resource name in the format 'projects/{projectId}/scanConfigs/{scanConfigId}'.

optionalArgs array

Optional.

↳ pageToken string

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

↳ pageSize int

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

↳ 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\WebSecurityScanner\V1beta\ScanRun;
use Google\Cloud\WebSecurityScanner\V1beta\WebSecurityScannerClient;

/**
 * @param string $formattedParent The parent resource name, which should be a scan resource name in the
 *                                format 'projects/{projectId}/scanConfigs/{scanConfigId}'. Please see
 *                                {@see WebSecurityScannerClient::scanConfigName()} for help formatting this field.
 */
function list_scan_runs_sample(string $formattedParent): void
{
    // Create a client.
    $webSecurityScannerClient = new WebSecurityScannerClient();

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

        /** @var ScanRun $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

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

    list_scan_runs_sample($formattedParent);
}

startScanRun

Start a ScanRun according to the given ScanConfig.

Parameters
Name Description
name string

Required. The resource name of the ScanConfig to be used. The name follows the format of 'projects/{projectId}/scanConfigs/{scanConfigId}'.

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

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

Returns
Type Description
Google\Cloud\WebSecurityScanner\V1beta\ScanRun
Example
use Google\ApiCore\ApiException;
use Google\Cloud\WebSecurityScanner\V1beta\ScanRun;
use Google\Cloud\WebSecurityScanner\V1beta\WebSecurityScannerClient;

/**
 * @param string $formattedName The resource name of the ScanConfig to be used. The name follows the
 *                              format of 'projects/{projectId}/scanConfigs/{scanConfigId}'. Please see
 *                              {@see WebSecurityScannerClient::scanConfigName()} for help formatting this field.
 */
function start_scan_run_sample(string $formattedName): void
{
    // Create a client.
    $webSecurityScannerClient = new WebSecurityScannerClient();

    // Call the API and handle any network failures.
    try {
        /** @var ScanRun $response */
        $response = $webSecurityScannerClient->startScanRun($formattedName);
        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 = WebSecurityScannerClient::scanConfigName('[PROJECT]', '[SCAN_CONFIG]');

    start_scan_run_sample($formattedName);
}

stopScanRun

Stops a ScanRun. The stopped ScanRun is returned.

Parameters
Name Description
name string

Required. The resource name of the ScanRun to be stopped. The name follows the format of 'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'.

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

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

Returns
Type Description
Google\Cloud\WebSecurityScanner\V1beta\ScanRun
Example
use Google\ApiCore\ApiException;
use Google\Cloud\WebSecurityScanner\V1beta\ScanRun;
use Google\Cloud\WebSecurityScanner\V1beta\WebSecurityScannerClient;

/**
 * @param string $formattedName The resource name of the ScanRun to be stopped. The name follows the
 *                              format of
 *                              'projects/{projectId}/scanConfigs/{scanConfigId}/scanRuns/{scanRunId}'. Please see
 *                              {@see WebSecurityScannerClient::scanRunName()} for help formatting this field.
 */
function stop_scan_run_sample(string $formattedName): void
{
    // Create a client.
    $webSecurityScannerClient = new WebSecurityScannerClient();

    // Call the API and handle any network failures.
    try {
        /** @var ScanRun $response */
        $response = $webSecurityScannerClient->stopScanRun($formattedName);
        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 = WebSecurityScannerClient::scanRunName('[PROJECT]', '[SCAN_CONFIG]', '[SCAN_RUN]');

    stop_scan_run_sample($formattedName);
}

updateScanConfig

Updates a ScanConfig. This method support partial update of a ScanConfig.

Parameters
Name Description
scanConfig Google\Cloud\WebSecurityScanner\V1beta\ScanConfig

Required. The ScanConfig to be updated. The name field must be set to identify the resource to be updated. The values of fields not covered by the mask will be ignored.

updateMask Google\Protobuf\FieldMask

Required. The update mask applies to the resource. For the FieldMask definition, see https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask

optionalArgs array

Optional.

↳ retrySettings RetrySettings|array

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

Returns
Type Description
Google\Cloud\WebSecurityScanner\V1beta\ScanConfig
Example
use Google\ApiCore\ApiException;
use Google\Cloud\WebSecurityScanner\V1beta\ScanConfig;
use Google\Cloud\WebSecurityScanner\V1beta\WebSecurityScannerClient;
use Google\Protobuf\FieldMask;

/**
 * @param string $scanConfigDisplayName         The user provided display name of the ScanConfig.
 * @param string $scanConfigStartingUrlsElement The starting URLs from which the scanner finds site pages.
 */
function update_scan_config_sample(
    string $scanConfigDisplayName,
    string $scanConfigStartingUrlsElement
): void {
    // Create a client.
    $webSecurityScannerClient = new WebSecurityScannerClient();

    // Prepare any non-scalar elements to be passed along with the request.
    $scanConfigStartingUrls = [$scanConfigStartingUrlsElement,];
    $scanConfig = (new ScanConfig())
        ->setDisplayName($scanConfigDisplayName)
        ->setStartingUrls($scanConfigStartingUrls);
    $updateMask = new FieldMask();

    // Call the API and handle any network failures.
    try {
        /** @var ScanConfig $response */
        $response = $webSecurityScannerClient->updateScanConfig($scanConfig, $updateMask);
        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
{
    $scanConfigDisplayName = '[DISPLAY_NAME]';
    $scanConfigStartingUrlsElement = '[STARTING_URLS]';

    update_scan_config_sample($scanConfigDisplayName, $scanConfigStartingUrlsElement);
}

static::findingName

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

Parameters
Name Description
project string
scanConfig string
scanRun string
finding string
Returns
Type Description
string The formatted finding resource.

static::projectName

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

Parameter
Name Description
project string
Returns
Type Description
string The formatted project resource.

static::scanConfigName

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

Parameters
Name Description
project string
scanConfig string
Returns
Type Description
string The formatted scan_config resource.

static::scanRunName

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

Parameters
Name Description
project string
scanConfig string
scanRun string
Returns
Type Description
string The formatted scan_run 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

  • finding: projects/{project}/scanConfigs/{scan_config}/scanRuns/{scan_run}/findings/{finding}
  • project: projects/{project}
  • scanConfig: projects/{project}/scanConfigs/{scan_config}
  • scanRun: projects/{project}/scanConfigs/{scan_config}/scanRuns/{scan_run}

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.

Constants

SERVICE_NAME

Value: 'google.cloud.websecurityscanner.v1beta.WebSecurityScanner'

The name of the service.

SERVICE_ADDRESS

Value: 'websecurityscanner.googleapis.com'

The default address of the service.

DEFAULT_SERVICE_PORT

Value: 443

The default port of the service.

CODEGEN_NAME

Value: 'gapic'

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