Grafeas V1 Client - Class GrafeasClient (0.7.1)

Reference documentation and code samples for the Grafeas V1 Client class GrafeasClient.

Service Description: Grafeas API.

Retrieves analysis results of Cloud components such as Docker container images.

Analysis results are stored as a series of occurrences. An Occurrence contains information about a specific analysis instance on a resource. An occurrence refers to a Note. A note contains details describing the analysis and is generally stored in a separate project, called a Provider. Multiple occurrences can refer to the same note.

For example, an SSL vulnerability could affect multiple images. In this case, there would be one note for the vulnerability and an occurrence for each image with the vulnerability referring to that note.

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:

$grafeasClient = new GrafeasClient();
try {
    $formattedParent = $grafeasClient->projectName('[PROJECT]');
    $notes = [];
    $response = $grafeasClient->batchCreateNotes($formattedParent, $notes);
} finally {
    $grafeasClient->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.

Methods

noteName

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

Parameters
NameDescription
project string
note string
Returns
TypeDescription
stringThe formatted note resource.

occurrenceName

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

Parameters
NameDescription
project string
occurrence string
Returns
TypeDescription
stringThe formatted occurrence resource.

projectName

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

Parameter
NameDescription
project string
Returns
TypeDescription
stringThe formatted project resource.

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

  • note: projects/{project}/notes/{note}
  • occurrence: projects/{project}/occurrences/{occurrence}
  • project: projects/{project}

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
NameDescription
formattedName string

The formatted name string

template string

Optional name of template to match

Returns
TypeDescription
arrayAn associative array from name component IDs to component values.

__construct

Constructor.

Parameters
NameDescription
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.

batchCreateNotes

Creates new notes in batch.

Parameters
NameDescription
parent string

The name of the project in the form of projects/[PROJECT_ID], under which the notes are to be created.

notes array

The notes to create. Max allowed length is 1000.

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
TypeDescription
Grafeas\V1\BatchCreateNotesResponse
Example
use Google\ApiCore\ApiException;
use Grafeas\V1\BatchCreateNotesResponse;
use Grafeas\V1\GrafeasClient;

/**
 * @param string $formattedParent The name of the project in the form of `projects/[PROJECT_ID]`, under which
 *                                the notes are to be created. Please see
 *                                {@see GrafeasClient::projectName()} for help formatting this field.
 */
function batch_create_notes_sample(string $formattedParent): void
{
    // Create a client.
    $grafeasClient = new GrafeasClient();

    // Prepare any non-scalar elements to be passed along with the request.
    $notes = [];

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

/**
 * 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 = GrafeasClient::projectName('[PROJECT]');

    batch_create_notes_sample($formattedParent);
}

batchCreateOccurrences

Creates new occurrences in batch.

Parameters
NameDescription
parent string

The name of the project in the form of projects/[PROJECT_ID], under which the occurrences are to be created.

occurrences array<Grafeas\V1\Occurrence>

The occurrences to create. Max allowed length is 1000.

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
TypeDescription
Grafeas\V1\BatchCreateOccurrencesResponse
Example
use Google\ApiCore\ApiException;
use Grafeas\V1\BatchCreateOccurrencesResponse;
use Grafeas\V1\GrafeasClient;
use Grafeas\V1\Occurrence;

/**
 * @param string $formattedParent The name of the project in the form of `projects/[PROJECT_ID]`, under which
 *                                the occurrences are to be created. Please see
 *                                {@see GrafeasClient::projectName()} for help formatting this field.
 */
function batch_create_occurrences_sample(string $formattedParent): void
{
    // Create a client.
    $grafeasClient = new GrafeasClient();

    // Prepare any non-scalar elements to be passed along with the request.
    $occurrences = [new Occurrence()];

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

/**
 * 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 = GrafeasClient::projectName('[PROJECT]');

    batch_create_occurrences_sample($formattedParent);
}

createNote

Creates a new note.

Parameters
NameDescription
parent string

The name of the project in the form of projects/[PROJECT_ID], under which the note is to be created.

noteId string

The ID to use for this note.

note Grafeas\V1\Note

The note to create.

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
TypeDescription
Grafeas\V1\Note
Example
use Google\ApiCore\ApiException;
use Grafeas\V1\GrafeasClient;
use Grafeas\V1\Note;

/**
 * @param string $formattedParent The name of the project in the form of `projects/[PROJECT_ID]`, under which
 *                                the note is to be created. Please see
 *                                {@see GrafeasClient::projectName()} for help formatting this field.
 * @param string $noteId          The ID to use for this note.
 */
function create_note_sample(string $formattedParent, string $noteId): void
{
    // Create a client.
    $grafeasClient = new GrafeasClient();

    // Prepare any non-scalar elements to be passed along with the request.
    $note = new Note();

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

/**
 * 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 = GrafeasClient::projectName('[PROJECT]');
    $noteId = '[NOTE_ID]';

    create_note_sample($formattedParent, $noteId);
}

createOccurrence

Creates a new occurrence.

Parameters
NameDescription
parent string

The name of the project in the form of projects/[PROJECT_ID], under which the occurrence is to be created.

occurrence Grafeas\V1\Occurrence

The occurrence to create.

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
TypeDescription
Grafeas\V1\Occurrence
Example
use Google\ApiCore\ApiException;
use Grafeas\V1\GrafeasClient;
use Grafeas\V1\Occurrence;

/**
 * @param string $formattedParent The name of the project in the form of `projects/[PROJECT_ID]`, under which
 *                                the occurrence is to be created. Please see
 *                                {@see GrafeasClient::projectName()} for help formatting this field.
 */
function create_occurrence_sample(string $formattedParent): void
{
    // Create a client.
    $grafeasClient = new GrafeasClient();

    // Prepare any non-scalar elements to be passed along with the request.
    $occurrence = new Occurrence();

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

/**
 * 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 = GrafeasClient::projectName('[PROJECT]');

    create_occurrence_sample($formattedParent);
}

deleteNote

Deletes the specified note.

Parameters
NameDescription
name string

The name of the note in the form of projects/[PROVIDER_ID]/notes/[NOTE_ID].

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 Grafeas\V1\GrafeasClient;

/**
 * @param string $formattedName The name of the note in the form of
 *                              `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. Please see
 *                              {@see GrafeasClient::noteName()} for help formatting this field.
 */
function delete_note_sample(string $formattedName): void
{
    // Create a client.
    $grafeasClient = new GrafeasClient();

    // Call the API and handle any network failures.
    try {
        $grafeasClient->deleteNote($formattedName);
        printf('Call completed successfully.' . PHP_EOL);
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * 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 = GrafeasClient::noteName('[PROJECT]', '[NOTE]');

    delete_note_sample($formattedName);
}

deleteOccurrence

Deletes the specified occurrence. For example, use this method to delete an occurrence when the occurrence is no longer applicable for the given resource.

Parameters
NameDescription
name string

The name of the occurrence in the form of projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID].

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 Grafeas\V1\GrafeasClient;

/**
 * @param string $formattedName The name of the occurrence in the form of
 *                              `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. Please see
 *                              {@see GrafeasClient::occurrenceName()} for help formatting this field.
 */
function delete_occurrence_sample(string $formattedName): void
{
    // Create a client.
    $grafeasClient = new GrafeasClient();

    // Call the API and handle any network failures.
    try {
        $grafeasClient->deleteOccurrence($formattedName);
        printf('Call completed successfully.' . PHP_EOL);
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * 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 = GrafeasClient::occurrenceName('[PROJECT]', '[OCCURRENCE]');

    delete_occurrence_sample($formattedName);
}

getNote

Gets the specified note.

Parameters
NameDescription
name string

The name of the note in the form of projects/[PROVIDER_ID]/notes/[NOTE_ID].

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
TypeDescription
Grafeas\V1\Note
Example
use Google\ApiCore\ApiException;
use Grafeas\V1\GrafeasClient;
use Grafeas\V1\Note;

/**
 * @param string $formattedName The name of the note in the form of
 *                              `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. Please see
 *                              {@see GrafeasClient::noteName()} for help formatting this field.
 */
function get_note_sample(string $formattedName): void
{
    // Create a client.
    $grafeasClient = new GrafeasClient();

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

/**
 * 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 = GrafeasClient::noteName('[PROJECT]', '[NOTE]');

    get_note_sample($formattedName);
}

getOccurrence

Gets the specified occurrence.

Parameters
NameDescription
name string

The name of the occurrence in the form of projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID].

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
TypeDescription
Grafeas\V1\Occurrence
Example
use Google\ApiCore\ApiException;
use Grafeas\V1\GrafeasClient;
use Grafeas\V1\Occurrence;

/**
 * @param string $formattedName The name of the occurrence in the form of
 *                              `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. Please see
 *                              {@see GrafeasClient::occurrenceName()} for help formatting this field.
 */
function get_occurrence_sample(string $formattedName): void
{
    // Create a client.
    $grafeasClient = new GrafeasClient();

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

/**
 * 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 = GrafeasClient::occurrenceName('[PROJECT]', '[OCCURRENCE]');

    get_occurrence_sample($formattedName);
}

getOccurrenceNote

Gets the note attached to the specified occurrence. Consumer projects can use this method to get a note that belongs to a provider project.

Parameters
NameDescription
name string

The name of the occurrence in the form of projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID].

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
TypeDescription
Grafeas\V1\Note
Example
use Google\ApiCore\ApiException;
use Grafeas\V1\GrafeasClient;
use Grafeas\V1\Note;

/**
 * @param string $formattedName The name of the occurrence in the form of
 *                              `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. Please see
 *                              {@see GrafeasClient::occurrenceName()} for help formatting this field.
 */
function get_occurrence_note_sample(string $formattedName): void
{
    // Create a client.
    $grafeasClient = new GrafeasClient();

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

/**
 * 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 = GrafeasClient::occurrenceName('[PROJECT]', '[OCCURRENCE]');

    get_occurrence_note_sample($formattedName);
}

listNoteOccurrences

Lists occurrences referencing the specified note. Provider projects can use this method to get all occurrences across consumer projects referencing the specified note.

Parameters
NameDescription
name string

The name of the note to list occurrences for in the form of projects/[PROVIDER_ID]/notes/[NOTE_ID].

optionalArgs array

Optional.

↳ filter string

The filter expression.

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

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

↳ 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
TypeDescription
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Grafeas\V1\GrafeasClient;
use Grafeas\V1\Occurrence;

/**
 * @param string $formattedName The name of the note to list occurrences for in the form of
 *                              `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. Please see
 *                              {@see GrafeasClient::noteName()} for help formatting this field.
 */
function list_note_occurrences_sample(string $formattedName): void
{
    // Create a client.
    $grafeasClient = new GrafeasClient();

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

        /** @var Occurrence $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());
    }
}

/**
 * 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 = GrafeasClient::noteName('[PROJECT]', '[NOTE]');

    list_note_occurrences_sample($formattedName);
}

listNotes

Lists notes for the specified project.

Parameters
NameDescription
parent string

The name of the project to list notes for in the form of projects/[PROJECT_ID].

optionalArgs array

Optional.

↳ filter string

The filter expression.

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

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

↳ 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
TypeDescription
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Grafeas\V1\GrafeasClient;
use Grafeas\V1\Note;

/**
 * @param string $formattedParent The name of the project to list notes for in the form of
 *                                `projects/[PROJECT_ID]`. Please see
 *                                {@see GrafeasClient::projectName()} for help formatting this field.
 */
function list_notes_sample(string $formattedParent): void
{
    // Create a client.
    $grafeasClient = new GrafeasClient();

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

        /** @var Note $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());
    }
}

/**
 * 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 = GrafeasClient::projectName('[PROJECT]');

    list_notes_sample($formattedParent);
}

listOccurrences

Lists occurrences for the specified project.

Parameters
NameDescription
parent string

The name of the project to list occurrences for in the form of projects/[PROJECT_ID].

optionalArgs array

Optional.

↳ filter string

The filter expression.

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

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

↳ 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
TypeDescription
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Grafeas\V1\GrafeasClient;
use Grafeas\V1\Occurrence;

/**
 * @param string $formattedParent The name of the project to list occurrences for in the form of
 *                                `projects/[PROJECT_ID]`. Please see
 *                                {@see GrafeasClient::projectName()} for help formatting this field.
 */
function list_occurrences_sample(string $formattedParent): void
{
    // Create a client.
    $grafeasClient = new GrafeasClient();

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

        /** @var Occurrence $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());
    }
}

/**
 * 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 = GrafeasClient::projectName('[PROJECT]');

    list_occurrences_sample($formattedParent);
}

updateNote

Updates the specified note.

Parameters
NameDescription
name string

The name of the note in the form of projects/[PROVIDER_ID]/notes/[NOTE_ID].

note Grafeas\V1\Note

The updated note.

optionalArgs array

Optional.

↳ updateMask FieldMask

The fields to update.

↳ 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
TypeDescription
Grafeas\V1\Note
Example
use Google\ApiCore\ApiException;
use Grafeas\V1\GrafeasClient;
use Grafeas\V1\Note;

/**
 * @param string $formattedName The name of the note in the form of
 *                              `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. Please see
 *                              {@see GrafeasClient::noteName()} for help formatting this field.
 */
function update_note_sample(string $formattedName): void
{
    // Create a client.
    $grafeasClient = new GrafeasClient();

    // Prepare any non-scalar elements to be passed along with the request.
    $note = new Note();

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

/**
 * 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 = GrafeasClient::noteName('[PROJECT]', '[NOTE]');

    update_note_sample($formattedName);
}

updateOccurrence

Updates the specified occurrence.

Parameters
NameDescription
name string

The name of the occurrence in the form of projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID].

occurrence Grafeas\V1\Occurrence

The updated occurrence.

optionalArgs array

Optional.

↳ updateMask FieldMask

The fields to update.

↳ 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
TypeDescription
Grafeas\V1\Occurrence
Example
use Google\ApiCore\ApiException;
use Grafeas\V1\GrafeasClient;
use Grafeas\V1\Occurrence;

/**
 * @param string $formattedName The name of the occurrence in the form of
 *                              `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`. Please see
 *                              {@see GrafeasClient::occurrenceName()} for help formatting this field.
 */
function update_occurrence_sample(string $formattedName): void
{
    // Create a client.
    $grafeasClient = new GrafeasClient();

    // Prepare any non-scalar elements to be passed along with the request.
    $occurrence = new Occurrence();

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

/**
 * 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 = GrafeasClient::occurrenceName('[PROJECT]', '[OCCURRENCE]');

    update_occurrence_sample($formattedName);
}

Constants

SERVICE_NAME

Value: 'grafeas.v1.Grafeas'

The name of the service.

SERVICE_ADDRESS

Value: 'containeranalysis.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.