Reference documentation and code samples for the Google Cloud Chronicle V1 Client class EntityServiceClient.
Service Description: EntityService contains apis for finding entities.
This class provides the ability to make remote calls to the backing service through method calls that map to API methods.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parseName method to extract the individual identifiers contained within formatted names that are returned by the API.
Namespace
Google \ Cloud \ Chronicle \ V1 \ ClientMethods
__construct
Constructor.
Parameters | |
---|---|
Name | Description |
options |
array
Optional. Options for configuring the service API wrapper. |
↳ apiEndpoint |
string
The address of the API remote host. May optionally include the port, formatted as "
|
↳ credentials |
string|array|FetchAuthTokenInterface|CredentialsWrapper
The credentials to be used by the client to authorize API calls. This option accepts either a path to a credentials file, or a decoded credentials file as a PHP array. Advanced usage: In addition, this option can also accept a pre-constructed Google\Auth\FetchAuthTokenInterface object or Google\ApiCore\CredentialsWrapper object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored. Important: If you accept a credential configuration (credential JSON/File/Stream) from an external source for authentication to Google Cloud Platform, you must validate it before providing it to any Google API or library. Providing an unvalidated credential configuration to Google APIs can compromise the security of your systems and data. For more information https://cloud.google.com/docs/authentication/external/externally-sourced-credentials |
↳ credentialsConfig |
array
Options used to configure credentials, including auth token caching, for the client. For a full list of supporting configuration options, see Google\ApiCore\CredentialsWrapper::build() . |
↳ disableRetries |
bool
Determines whether or not retries defined by the client configuration should be disabled. Defaults to |
↳ 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 |
↳ 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. |
↳ logger |
false|LoggerInterface
A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the 'GOOGLE_SDK_PHP_LOGGING' environment flag |
createWatchlist
Creates a watchlist for the given instance.
Note that there can be at most 200 watchlists per instance.
The async variant is EntityServiceClient::createWatchlistAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Chronicle\V1\CreateWatchlistRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\Chronicle\V1\Watchlist |
use Google\ApiCore\ApiException;
use Google\Cloud\Chronicle\V1\Client\EntityServiceClient;
use Google\Cloud\Chronicle\V1\CreateWatchlistRequest;
use Google\Cloud\Chronicle\V1\Watchlist;
use Google\Cloud\Chronicle\V1\Watchlist\EntityPopulationMechanism;
/**
* @param string $formattedParent The parent resource where this watchlist will be created.
* Format: `projects/{project}/locations/{location}/instances/{instance}`
* Please see {@see EntityServiceClient::instanceName()} for help formatting this field.
* @param string $watchlistDisplayName Display name of the watchlist.
* Note that it must be at least one character and less than 63 characters
* (https://google.aip.dev/148).
*/
function create_watchlist_sample(string $formattedParent, string $watchlistDisplayName): void
{
// Create a client.
$entityServiceClient = new EntityServiceClient();
// Prepare the request message.
$watchlistEntityPopulationMechanism = new EntityPopulationMechanism();
$watchlist = (new Watchlist())
->setDisplayName($watchlistDisplayName)
->setEntityPopulationMechanism($watchlistEntityPopulationMechanism);
$request = (new CreateWatchlistRequest())
->setParent($formattedParent)
->setWatchlist($watchlist);
// Call the API and handle any network failures.
try {
/** @var Watchlist $response */
$response = $entityServiceClient->createWatchlist($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 = EntityServiceClient::instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]');
$watchlistDisplayName = '[DISPLAY_NAME]';
create_watchlist_sample($formattedParent, $watchlistDisplayName);
}
deleteWatchlist
Deletes the watchlist for the given instance.
The async variant is EntityServiceClient::deleteWatchlistAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Chronicle\V1\DeleteWatchlistRequest
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. |
use Google\ApiCore\ApiException;
use Google\Cloud\Chronicle\V1\Client\EntityServiceClient;
use Google\Cloud\Chronicle\V1\DeleteWatchlistRequest;
/**
* @param string $formattedName The name of the watchlist to delete.
* Format:
* `projects/{project}/locations/{location}/instances/{instance}/watchlists/{watchlist}`
* Please see {@see EntityServiceClient::watchlistName()} for help formatting this field.
*/
function delete_watchlist_sample(string $formattedName): void
{
// Create a client.
$entityServiceClient = new EntityServiceClient();
// Prepare the request message.
$request = (new DeleteWatchlistRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
$entityServiceClient->deleteWatchlist($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 = EntityServiceClient::watchlistName(
'[PROJECT]',
'[LOCATION]',
'[INSTANCE]',
'[WATCHLIST]'
);
delete_watchlist_sample($formattedName);
}
getWatchlist
Gets watchlist details for the given watchlist ID.
The async variant is EntityServiceClient::getWatchlistAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Chronicle\V1\GetWatchlistRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\Chronicle\V1\Watchlist |
use Google\ApiCore\ApiException;
use Google\Cloud\Chronicle\V1\Client\EntityServiceClient;
use Google\Cloud\Chronicle\V1\GetWatchlistRequest;
use Google\Cloud\Chronicle\V1\Watchlist;
/**
* @param string $formattedName The parent, which owns this collection of watchlists.
* The name of the watchlist to retrieve.
* Format:
* `projects/{project}/locations/{location}/instances/{instance}/watchlists/{watchlist}`
* Please see {@see EntityServiceClient::watchlistName()} for help formatting this field.
*/
function get_watchlist_sample(string $formattedName): void
{
// Create a client.
$entityServiceClient = new EntityServiceClient();
// Prepare the request message.
$request = (new GetWatchlistRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var Watchlist $response */
$response = $entityServiceClient->getWatchlist($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 = EntityServiceClient::watchlistName(
'[PROJECT]',
'[LOCATION]',
'[INSTANCE]',
'[WATCHLIST]'
);
get_watchlist_sample($formattedName);
}
listWatchlists
Lists all watchlists for the given instance.
The async variant is EntityServiceClient::listWatchlistsAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Chronicle\V1\ListWatchlistsRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\PagedListResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Chronicle\V1\Client\EntityServiceClient;
use Google\Cloud\Chronicle\V1\ListWatchlistsRequest;
use Google\Cloud\Chronicle\V1\Watchlist;
/**
* @param string $formattedParent The parent, which owns this collection of watchlists.
* Format: `projects/{project}/locations/{location}/instances/{instance}`
* Please see {@see EntityServiceClient::instanceName()} for help formatting this field.
*/
function list_watchlists_sample(string $formattedParent): void
{
// Create a client.
$entityServiceClient = new EntityServiceClient();
// Prepare the request message.
$request = (new ListWatchlistsRequest())
->setParent($formattedParent);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $entityServiceClient->listWatchlists($request);
/** @var Watchlist $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 = EntityServiceClient::instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]');
list_watchlists_sample($formattedParent);
}
updateWatchlist
Updates the watchlist for the given instance.
The async variant is EntityServiceClient::updateWatchlistAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Chronicle\V1\UpdateWatchlistRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\Chronicle\V1\Watchlist |
use Google\ApiCore\ApiException;
use Google\Cloud\Chronicle\V1\Client\EntityServiceClient;
use Google\Cloud\Chronicle\V1\UpdateWatchlistRequest;
use Google\Cloud\Chronicle\V1\Watchlist;
use Google\Cloud\Chronicle\V1\Watchlist\EntityPopulationMechanism;
/**
* @param string $watchlistDisplayName Display name of the watchlist.
* Note that it must be at least one character and less than 63 characters
* (https://google.aip.dev/148).
*/
function update_watchlist_sample(string $watchlistDisplayName): void
{
// Create a client.
$entityServiceClient = new EntityServiceClient();
// Prepare the request message.
$watchlistEntityPopulationMechanism = new EntityPopulationMechanism();
$watchlist = (new Watchlist())
->setDisplayName($watchlistDisplayName)
->setEntityPopulationMechanism($watchlistEntityPopulationMechanism);
$request = (new UpdateWatchlistRequest())
->setWatchlist($watchlist);
// Call the API and handle any network failures.
try {
/** @var Watchlist $response */
$response = $entityServiceClient->updateWatchlist($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
{
$watchlistDisplayName = '[DISPLAY_NAME]';
update_watchlist_sample($watchlistDisplayName);
}
createWatchlistAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Chronicle\V1\CreateWatchlistRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Chronicle\V1\Watchlist> |
deleteWatchlistAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Chronicle\V1\DeleteWatchlistRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<void> |
getWatchlistAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Chronicle\V1\GetWatchlistRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Chronicle\V1\Watchlist> |
listWatchlistsAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Chronicle\V1\ListWatchlistsRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse> |
updateWatchlistAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Chronicle\V1\UpdateWatchlistRequest
|
optionalArgs |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Chronicle\V1\Watchlist> |
static::instanceName
Formats a string containing the fully-qualified path to represent a instance resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
location |
string
|
instance |
string
|
Returns | |
---|---|
Type | Description |
string |
The formatted instance resource. |
static::watchlistName
Formats a string containing the fully-qualified path to represent a watchlist resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
location |
string
|
instance |
string
|
watchlist |
string
|
Returns | |
---|---|
Type | Description |
string |
The formatted watchlist 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
- instance: projects/{project}/locations/{location}/instances/{instance}
- watchlist: projects/{project}/locations/{location}/instances/{instance}/watchlists/{watchlist}
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. |