Grafeas V1 Client - Class GrafeasClient (0.9.0)

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.

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

Grafeas \ V1 \ Client

Methods

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

The async variant is Grafeas\V1\Client\GrafeasClient::batchCreateNotesAsync() .

Parameters
NameDescription
request Grafeas\V1\BatchCreateNotesRequest

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
TypeDescription
Grafeas\V1\BatchCreateNotesResponse
Example
use Google\ApiCore\ApiException;
use Grafeas\V1\BatchCreateNotesRequest;
use Grafeas\V1\BatchCreateNotesResponse;
use Grafeas\V1\Client\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 the request message.
    $notes = [];
    $request = (new BatchCreateNotesRequest())
        ->setParent($formattedParent)
        ->setNotes($notes);

    // Call the API and handle any network failures.
    try {
        /** @var BatchCreateNotesResponse $response */
        $response = $grafeasClient->batchCreateNotes($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 = GrafeasClient::projectName('[PROJECT]');

    batch_create_notes_sample($formattedParent);
}

batchCreateOccurrences

Creates new occurrences in batch.

The async variant is Grafeas\V1\Client\GrafeasClient::batchCreateOccurrencesAsync() .

Parameters
NameDescription
request Grafeas\V1\BatchCreateOccurrencesRequest

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
TypeDescription
Grafeas\V1\BatchCreateOccurrencesResponse
Example
use Google\ApiCore\ApiException;
use Grafeas\V1\BatchCreateOccurrencesRequest;
use Grafeas\V1\BatchCreateOccurrencesResponse;
use Grafeas\V1\Client\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 the request message.
    $occurrences = [new Occurrence()];
    $request = (new BatchCreateOccurrencesRequest())
        ->setParent($formattedParent)
        ->setOccurrences($occurrences);

    // Call the API and handle any network failures.
    try {
        /** @var BatchCreateOccurrencesResponse $response */
        $response = $grafeasClient->batchCreateOccurrences($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 = GrafeasClient::projectName('[PROJECT]');

    batch_create_occurrences_sample($formattedParent);
}

createNote

Creates a new note.

The async variant is Grafeas\V1\Client\GrafeasClient::createNoteAsync() .

Parameters
NameDescription
request Grafeas\V1\CreateNoteRequest

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
TypeDescription
Grafeas\V1\Note
Example
use Google\ApiCore\ApiException;
use Grafeas\V1\Client\GrafeasClient;
use Grafeas\V1\CreateNoteRequest;
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 the request message.
    $note = new Note();
    $request = (new CreateNoteRequest())
        ->setParent($formattedParent)
        ->setNoteId($noteId)
        ->setNote($note);

    // Call the API and handle any network failures.
    try {
        /** @var Note $response */
        $response = $grafeasClient->createNote($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 = GrafeasClient::projectName('[PROJECT]');
    $noteId = '[NOTE_ID]';

    create_note_sample($formattedParent, $noteId);
}

createOccurrence

Creates a new occurrence.

The async variant is Grafeas\V1\Client\GrafeasClient::createOccurrenceAsync() .

Parameters
NameDescription
request Grafeas\V1\CreateOccurrenceRequest

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
TypeDescription
Grafeas\V1\Occurrence
Example
use Google\ApiCore\ApiException;
use Grafeas\V1\Client\GrafeasClient;
use Grafeas\V1\CreateOccurrenceRequest;
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 the request message.
    $occurrence = new Occurrence();
    $request = (new CreateOccurrenceRequest())
        ->setParent($formattedParent)
        ->setOccurrence($occurrence);

    // Call the API and handle any network failures.
    try {
        /** @var Occurrence $response */
        $response = $grafeasClient->createOccurrence($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 = GrafeasClient::projectName('[PROJECT]');

    create_occurrence_sample($formattedParent);
}

deleteNote

Deletes the specified note.

The async variant is Grafeas\V1\Client\GrafeasClient::deleteNoteAsync() .

Parameters
NameDescription
request Grafeas\V1\DeleteNoteRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

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

Example
use Google\ApiCore\ApiException;
use Grafeas\V1\Client\GrafeasClient;
use Grafeas\V1\DeleteNoteRequest;

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

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

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

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = 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.

The async variant is Grafeas\V1\Client\GrafeasClient::deleteOccurrenceAsync() .

Parameters
NameDescription
request Grafeas\V1\DeleteOccurrenceRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

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

Example
use Google\ApiCore\ApiException;
use Grafeas\V1\Client\GrafeasClient;
use Grafeas\V1\DeleteOccurrenceRequest;

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

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

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

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

    delete_occurrence_sample($formattedName);
}

getNote

Gets the specified note.

The async variant is Grafeas\V1\Client\GrafeasClient::getNoteAsync() .

Parameters
NameDescription
request Grafeas\V1\GetNoteRequest

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

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

    // Call the API and handle any network failures.
    try {
        /** @var Note $response */
        $response = $grafeasClient->getNote($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 = GrafeasClient::noteName('[PROJECT]', '[NOTE]');

    get_note_sample($formattedName);
}

getOccurrence

Gets the specified occurrence.

The async variant is Grafeas\V1\Client\GrafeasClient::getOccurrenceAsync() .

Parameters
NameDescription
request Grafeas\V1\GetOccurrenceRequest

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

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

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

The async variant is Grafeas\V1\Client\GrafeasClient::getOccurrenceNoteAsync() .

Parameters
NameDescription
request Grafeas\V1\GetOccurrenceNoteRequest

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

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

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

The async variant is Grafeas\V1\Client\GrafeasClient::listNoteOccurrencesAsync() .

Parameters
NameDescription
request Grafeas\V1\ListNoteOccurrencesRequest

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
TypeDescription
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Grafeas\V1\Client\GrafeasClient;
use Grafeas\V1\ListNoteOccurrencesRequest;
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();

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

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

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

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

    list_note_occurrences_sample($formattedName);
}

listNotes

Lists notes for the specified project.

The async variant is Grafeas\V1\Client\GrafeasClient::listNotesAsync() .

Parameters
NameDescription
request Grafeas\V1\ListNotesRequest

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
TypeDescription
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Grafeas\V1\Client\GrafeasClient;
use Grafeas\V1\ListNotesRequest;
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();

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

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

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

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

    list_notes_sample($formattedParent);
}

listOccurrences

Lists occurrences for the specified project.

The async variant is Grafeas\V1\Client\GrafeasClient::listOccurrencesAsync() .

Parameters
NameDescription
request Grafeas\V1\ListOccurrencesRequest

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
TypeDescription
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Grafeas\V1\Client\GrafeasClient;
use Grafeas\V1\ListOccurrencesRequest;
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();

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

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

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

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

    list_occurrences_sample($formattedParent);
}

updateNote

Updates the specified note.

The async variant is Grafeas\V1\Client\GrafeasClient::updateNoteAsync() .

Parameters
NameDescription
request Grafeas\V1\UpdateNoteRequest

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

/**
 * @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 the request message.
    $note = new Note();
    $request = (new UpdateNoteRequest())
        ->setName($formattedName)
        ->setNote($note);

    // Call the API and handle any network failures.
    try {
        /** @var Note $response */
        $response = $grafeasClient->updateNote($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 = GrafeasClient::noteName('[PROJECT]', '[NOTE]');

    update_note_sample($formattedName);
}

updateOccurrence

Updates the specified occurrence.

The async variant is Grafeas\V1\Client\GrafeasClient::updateOccurrenceAsync() .

Parameters
NameDescription
request Grafeas\V1\UpdateOccurrenceRequest

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

/**
 * @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 the request message.
    $occurrence = new Occurrence();
    $request = (new UpdateOccurrenceRequest())
        ->setName($formattedName)
        ->setOccurrence($occurrence);

    // Call the API and handle any network failures.
    try {
        /** @var Occurrence $response */
        $response = $grafeasClient->updateOccurrence($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 = GrafeasClient::occurrenceName('[PROJECT]', '[OCCURRENCE]');

    update_occurrence_sample($formattedName);
}

batchCreateNotesAsync

Parameters
NameDescription
request Grafeas\V1\BatchCreateNotesRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

batchCreateOccurrencesAsync

Parameters
NameDescription
request Grafeas\V1\BatchCreateOccurrencesRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

createNoteAsync

Parameters
NameDescription
request Grafeas\V1\CreateNoteRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

createOccurrenceAsync

Parameters
NameDescription
request Grafeas\V1\CreateOccurrenceRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

deleteNoteAsync

Parameters
NameDescription
request Grafeas\V1\DeleteNoteRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

deleteOccurrenceAsync

Parameters
NameDescription
request Grafeas\V1\DeleteOccurrenceRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

getNoteAsync

Parameters
NameDescription
request Grafeas\V1\GetNoteRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

getOccurrenceAsync

Parameters
NameDescription
request Grafeas\V1\GetOccurrenceRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

getOccurrenceNoteAsync

Parameters
NameDescription
request Grafeas\V1\GetOccurrenceNoteRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

listNoteOccurrencesAsync

Parameters
NameDescription
request Grafeas\V1\ListNoteOccurrencesRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

listNotesAsync

Parameters
NameDescription
request Grafeas\V1\ListNotesRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

listOccurrencesAsync

Parameters
NameDescription
request Grafeas\V1\ListOccurrencesRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

updateNoteAsync

Parameters
NameDescription
request Grafeas\V1\UpdateNoteRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

updateOccurrenceAsync

Parameters
NameDescription
request Grafeas\V1\UpdateOccurrenceRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

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

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

static::projectName

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

Parameter
NameDescription
project string
Returns
TypeDescription
stringThe formatted project 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

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