Reference documentation and code samples for the Recommender V1 Client class RecommenderClient.
Service Description: Provides insights and recommendations for cloud customers for various categories like performance optimization, cost savings, reliability, feature discovery, etc. Insights and recommendations are generated automatically based on analysis of user resources, configuration and monitoring metrics.
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:
$recommenderClient = new RecommenderClient();
try {
$formattedName = $recommenderClient->insightName('[PROJECT]', '[LOCATION]', '[INSIGHT_TYPE]', '[INSIGHT]');
$response = $recommenderClient->getInsight($formattedName);
} finally {
$recommenderClient->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.
This service has a new (beta) implementation. See Google\Cloud\Recommender\V1\Client\RecommenderClient to use the new surface.
Namespace
Google \ Cloud \ Recommender \ V1Methods
__construct
Constructor.
Parameters | |
---|---|
Name | Description |
options |
array
Optional. Options for configuring the service API wrapper. |
↳ apiEndpoint |
string
The address of the API remote host. May optionally include the port, formatted as "
|
↳ credentials |
string|array|FetchAuthTokenInterface|CredentialsWrapper
The credentials to be used by the client to authorize API calls. This option accepts either a path to a credentials file, or a decoded credentials file as a PHP array. Advanced usage: In addition, this option can also accept a pre-constructed Google\Auth\FetchAuthTokenInterface object or Google\ApiCore\CredentialsWrapper object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored. |
↳ credentialsConfig |
array
Options used to configure credentials, including auth token caching, for the client. For a full list of supporting configuration options, see Google\ApiCore\CredentialsWrapper::build() . |
↳ disableRetries |
bool
Determines whether or not retries defined by the client configuration should be disabled. Defaults to |
↳ 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. |
getInsight
Gets the requested insight. Requires the recommender.*.get IAM permission for the specified insight type.
Parameters | |
---|---|
Name | Description |
name |
string
Required. Name of the insight. |
optionalArgs |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\Recommender\V1\Insight |
use Google\ApiCore\ApiException;
use Google\Cloud\Recommender\V1\Insight;
use Google\Cloud\Recommender\V1\RecommenderClient;
/**
* @param string $formattedName Name of the insight. Please see
* {@see RecommenderClient::insightName()} for help formatting this field.
*/
function get_insight_sample(string $formattedName): void
{
// Create a client.
$recommenderClient = new RecommenderClient();
// Call the API and handle any network failures.
try {
/** @var Insight $response */
$response = $recommenderClient->getInsight($formattedName);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = RecommenderClient::insightName(
'[PROJECT]',
'[LOCATION]',
'[INSIGHT_TYPE]',
'[INSIGHT]'
);
get_insight_sample($formattedName);
}
getInsightTypeConfig
Gets the requested InsightTypeConfig. There is only one instance of the config for each InsightType.
Parameters | |
---|---|
Name | Description |
name |
string
Required. Name of the InsightTypeConfig to get. Acceptable formats:
|
optionalArgs |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\Recommender\V1\InsightTypeConfig |
use Google\ApiCore\ApiException;
use Google\Cloud\Recommender\V1\InsightTypeConfig;
use Google\Cloud\Recommender\V1\RecommenderClient;
/**
* @param string $formattedName Name of the InsightTypeConfig to get.
*
* Acceptable formats:
*
* * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config`
*
* * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config`
*
* * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config`
*
* * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config`
* Please see {@see RecommenderClient::insightTypeConfigName()} for help formatting this field.
*/
function get_insight_type_config_sample(string $formattedName): void
{
// Create a client.
$recommenderClient = new RecommenderClient();
// Call the API and handle any network failures.
try {
/** @var InsightTypeConfig $response */
$response = $recommenderClient->getInsightTypeConfig($formattedName);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = RecommenderClient::insightTypeConfigName(
'[PROJECT]',
'[LOCATION]',
'[INSIGHT_TYPE]'
);
get_insight_type_config_sample($formattedName);
}
getRecommendation
Gets the requested recommendation. Requires the recommender.*.get IAM permission for the specified recommender.
Parameters | |
---|---|
Name | Description |
name |
string
Required. Name of the recommendation. |
optionalArgs |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\Recommender\V1\Recommendation |
use Google\ApiCore\ApiException;
use Google\Cloud\Recommender\V1\Recommendation;
use Google\Cloud\Recommender\V1\RecommenderClient;
/**
* @param string $formattedName Name of the recommendation. Please see
* {@see RecommenderClient::recommendationName()} for help formatting this field.
*/
function get_recommendation_sample(string $formattedName): void
{
// Create a client.
$recommenderClient = new RecommenderClient();
// Call the API and handle any network failures.
try {
/** @var Recommendation $response */
$response = $recommenderClient->getRecommendation($formattedName);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = RecommenderClient::recommendationName(
'[PROJECT]',
'[LOCATION]',
'[RECOMMENDER]',
'[RECOMMENDATION]'
);
get_recommendation_sample($formattedName);
}
getRecommenderConfig
Gets the requested Recommender Config. There is only one instance of the config for each Recommender.
Parameters | |
---|---|
Name | Description |
name |
string
Required. Name of the Recommendation Config to get. Acceptable formats:
|
optionalArgs |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\Recommender\V1\RecommenderConfig |
use Google\ApiCore\ApiException;
use Google\Cloud\Recommender\V1\RecommenderClient;
use Google\Cloud\Recommender\V1\RecommenderConfig;
/**
* @param string $formattedName Name of the Recommendation Config to get.
*
* Acceptable formats:
*
* * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config`
*
* * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config`
*
* * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config`
*
* * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config`
* Please see {@see RecommenderClient::recommenderConfigName()} for help formatting this field.
*/
function get_recommender_config_sample(string $formattedName): void
{
// Create a client.
$recommenderClient = new RecommenderClient();
// Call the API and handle any network failures.
try {
/** @var RecommenderConfig $response */
$response = $recommenderClient->getRecommenderConfig($formattedName);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = RecommenderClient::recommenderConfigName(
'[PROJECT]',
'[LOCATION]',
'[RECOMMENDER]'
);
get_recommender_config_sample($formattedName);
}
listInsights
Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified insight type.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. The container resource on which to execute the request. Acceptable formats:
LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ INSIGHT_TYPE_ID refers to supported insight types: https://cloud.google.com/recommender/docs/insights/insight-types. |
optionalArgs |
array
Optional. |
↳ 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. |
↳ filter |
string
Optional. Filter expression to restrict the insights returned. Supported filter fields: * |
↳ 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\Recommender\V1\Insight;
use Google\Cloud\Recommender\V1\RecommenderClient;
/**
* @param string $formattedParent The container resource on which to execute the request.
* Acceptable formats:
*
* * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]`
*
* * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]`
*
* * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]`
*
* * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]`
*
* * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]`
*
* LOCATION here refers to GCP Locations:
* https://cloud.google.com/about/locations/
* INSIGHT_TYPE_ID refers to supported insight types:
* https://cloud.google.com/recommender/docs/insights/insight-types. Please see
* {@see RecommenderClient::insightTypeName()} for help formatting this field.
*/
function list_insights_sample(string $formattedParent): void
{
// Create a client.
$recommenderClient = new RecommenderClient();
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $recommenderClient->listInsights($formattedParent);
/** @var Insight $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 = RecommenderClient::insightTypeName('[PROJECT]', '[LOCATION]', '[INSIGHT_TYPE]');
list_insights_sample($formattedParent);
}
listRecommendations
Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified recommender.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. The container resource on which to execute the request. Acceptable formats:
LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/ RECOMMENDER_ID refers to supported recommenders: https://cloud.google.com/recommender/docs/recommenders. |
optionalArgs |
array
Optional. |
↳ 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. |
↳ filter |
string
Filter expression to restrict the recommendations returned. Supported filter fields: * |
↳ 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\Recommender\V1\Recommendation;
use Google\Cloud\Recommender\V1\RecommenderClient;
/**
* @param string $formattedParent The container resource on which to execute the request.
* Acceptable formats:
*
* * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]`
*
* * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]`
*
* * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]`
*
* * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]`
*
* * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]`
*
* LOCATION here refers to GCP Locations:
* https://cloud.google.com/about/locations/
* RECOMMENDER_ID refers to supported recommenders:
* https://cloud.google.com/recommender/docs/recommenders. Please see
* {@see RecommenderClient::recommenderName()} for help formatting this field.
*/
function list_recommendations_sample(string $formattedParent): void
{
// Create a client.
$recommenderClient = new RecommenderClient();
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $recommenderClient->listRecommendations($formattedParent);
/** @var Recommendation $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 = RecommenderClient::recommenderName('[PROJECT]', '[LOCATION]', '[RECOMMENDER]');
list_recommendations_sample($formattedParent);
}
markInsightAccepted
Marks the Insight State as Accepted. Users can use this method to indicate to the Recommender API that they have applied some action based on the insight. This stops the insight content from being updated.
MarkInsightAccepted can be applied to insights in ACTIVE state. Requires the recommender.*.update IAM permission for the specified insight.
Parameters | |
---|---|
Name | Description |
name |
string
Required. Name of the insight. |
etag |
string
Required. Fingerprint of the Insight. Provides optimistic locking. |
optionalArgs |
array
Optional. |
↳ stateMetadata |
array
Optional. State properties user wish to include with this state. Full replace of the current state_metadata. |
↳ 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\Recommender\V1\Insight |
use Google\ApiCore\ApiException;
use Google\Cloud\Recommender\V1\Insight;
use Google\Cloud\Recommender\V1\RecommenderClient;
/**
* @param string $formattedName Name of the insight. Please see
* {@see RecommenderClient::insightName()} for help formatting this field.
* @param string $etag Fingerprint of the Insight. Provides optimistic locking.
*/
function mark_insight_accepted_sample(string $formattedName, string $etag): void
{
// Create a client.
$recommenderClient = new RecommenderClient();
// Call the API and handle any network failures.
try {
/** @var Insight $response */
$response = $recommenderClient->markInsightAccepted($formattedName, $etag);
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 = RecommenderClient::insightName(
'[PROJECT]',
'[LOCATION]',
'[INSIGHT_TYPE]',
'[INSIGHT]'
);
$etag = '[ETAG]';
mark_insight_accepted_sample($formattedName, $etag);
}
markRecommendationClaimed
Marks the Recommendation State as Claimed. Users can use this method to indicate to the Recommender API that they are starting to apply the recommendation themselves. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state.
MarkRecommendationClaimed can be applied to recommendations in CLAIMED, SUCCEEDED, FAILED, or ACTIVE state.
Requires the recommender.*.update IAM permission for the specified recommender.
Parameters | |
---|---|
Name | Description |
name |
string
Required. Name of the recommendation. |
etag |
string
Required. Fingerprint of the Recommendation. Provides optimistic locking. |
optionalArgs |
array
Optional. |
↳ stateMetadata |
array
State properties to include with this state. Overwrites any existing |
↳ 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\Recommender\V1\Recommendation |
use Google\ApiCore\ApiException;
use Google\Cloud\Recommender\V1\Recommendation;
use Google\Cloud\Recommender\V1\RecommenderClient;
/**
* @param string $formattedName Name of the recommendation. Please see
* {@see RecommenderClient::recommendationName()} for help formatting this field.
* @param string $etag Fingerprint of the Recommendation. Provides optimistic locking.
*/
function mark_recommendation_claimed_sample(string $formattedName, string $etag): void
{
// Create a client.
$recommenderClient = new RecommenderClient();
// Call the API and handle any network failures.
try {
/** @var Recommendation $response */
$response = $recommenderClient->markRecommendationClaimed($formattedName, $etag);
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 = RecommenderClient::recommendationName(
'[PROJECT]',
'[LOCATION]',
'[RECOMMENDER]',
'[RECOMMENDATION]'
);
$etag = '[ETAG]';
mark_recommendation_claimed_sample($formattedName, $etag);
}
markRecommendationDismissed
Mark the Recommendation State as Dismissed. Users can use this method to indicate to the Recommender API that an ACTIVE recommendation has to be marked back as DISMISSED.
MarkRecommendationDismissed can be applied to recommendations in ACTIVE state.
Requires the recommender.*.update IAM permission for the specified recommender.
Parameters | |
---|---|
Name | Description |
name |
string
Required. Name of the recommendation. |
optionalArgs |
array
Optional. |
↳ etag |
string
Fingerprint of the Recommendation. Provides optimistic locking. |
↳ 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\Recommender\V1\Recommendation |
use Google\ApiCore\ApiException;
use Google\Cloud\Recommender\V1\Recommendation;
use Google\Cloud\Recommender\V1\RecommenderClient;
/**
* @param string $formattedName Name of the recommendation. Please see
* {@see RecommenderClient::recommendationName()} for help formatting this field.
*/
function mark_recommendation_dismissed_sample(string $formattedName): void
{
// Create a client.
$recommenderClient = new RecommenderClient();
// Call the API and handle any network failures.
try {
/** @var Recommendation $response */
$response = $recommenderClient->markRecommendationDismissed($formattedName);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = RecommenderClient::recommendationName(
'[PROJECT]',
'[LOCATION]',
'[RECOMMENDER]',
'[RECOMMENDATION]'
);
mark_recommendation_dismissed_sample($formattedName);
}
markRecommendationFailed
Marks the Recommendation State as Failed. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation failed. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state.
MarkRecommendationFailed can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state.
Requires the recommender.*.update IAM permission for the specified recommender.
Parameters | |
---|---|
Name | Description |
name |
string
Required. Name of the recommendation. |
etag |
string
Required. Fingerprint of the Recommendation. Provides optimistic locking. |
optionalArgs |
array
Optional. |
↳ stateMetadata |
array
State properties to include with this state. Overwrites any existing |
↳ 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\Recommender\V1\Recommendation |
use Google\ApiCore\ApiException;
use Google\Cloud\Recommender\V1\Recommendation;
use Google\Cloud\Recommender\V1\RecommenderClient;
/**
* @param string $formattedName Name of the recommendation. Please see
* {@see RecommenderClient::recommendationName()} for help formatting this field.
* @param string $etag Fingerprint of the Recommendation. Provides optimistic locking.
*/
function mark_recommendation_failed_sample(string $formattedName, string $etag): void
{
// Create a client.
$recommenderClient = new RecommenderClient();
// Call the API and handle any network failures.
try {
/** @var Recommendation $response */
$response = $recommenderClient->markRecommendationFailed($formattedName, $etag);
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 = RecommenderClient::recommendationName(
'[PROJECT]',
'[LOCATION]',
'[RECOMMENDER]',
'[RECOMMENDATION]'
);
$etag = '[ETAG]';
mark_recommendation_failed_sample($formattedName, $etag);
}
markRecommendationSucceeded
Marks the Recommendation State as Succeeded. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation was successful. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state.
MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state.
Requires the recommender.*.update IAM permission for the specified recommender.
Parameters | |
---|---|
Name | Description |
name |
string
Required. Name of the recommendation. |
etag |
string
Required. Fingerprint of the Recommendation. Provides optimistic locking. |
optionalArgs |
array
Optional. |
↳ stateMetadata |
array
State properties to include with this state. Overwrites any existing |
↳ 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\Recommender\V1\Recommendation |
use Google\ApiCore\ApiException;
use Google\Cloud\Recommender\V1\Recommendation;
use Google\Cloud\Recommender\V1\RecommenderClient;
/**
* @param string $formattedName Name of the recommendation. Please see
* {@see RecommenderClient::recommendationName()} for help formatting this field.
* @param string $etag Fingerprint of the Recommendation. Provides optimistic locking.
*/
function mark_recommendation_succeeded_sample(string $formattedName, string $etag): void
{
// Create a client.
$recommenderClient = new RecommenderClient();
// Call the API and handle any network failures.
try {
/** @var Recommendation $response */
$response = $recommenderClient->markRecommendationSucceeded($formattedName, $etag);
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 = RecommenderClient::recommendationName(
'[PROJECT]',
'[LOCATION]',
'[RECOMMENDER]',
'[RECOMMENDATION]'
);
$etag = '[ETAG]';
mark_recommendation_succeeded_sample($formattedName, $etag);
}
updateInsightTypeConfig
Updates an InsightTypeConfig change. This will create a new revision of the config.
Parameters | |
---|---|
Name | Description |
insightTypeConfig |
Google\Cloud\Recommender\V1\InsightTypeConfig
Required. The InsightTypeConfig to update. |
optionalArgs |
array
Optional. |
↳ updateMask |
FieldMask
The list of fields to be updated. |
↳ validateOnly |
bool
If true, validate the request and preview the change, but do not actually update it. |
↳ 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\Recommender\V1\InsightTypeConfig |
use Google\ApiCore\ApiException;
use Google\Cloud\Recommender\V1\InsightTypeConfig;
use Google\Cloud\Recommender\V1\RecommenderClient;
/**
* 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 update_insight_type_config_sample(): void
{
// Create a client.
$recommenderClient = new RecommenderClient();
// Prepare any non-scalar elements to be passed along with the request.
$insightTypeConfig = new InsightTypeConfig();
// Call the API and handle any network failures.
try {
/** @var InsightTypeConfig $response */
$response = $recommenderClient->updateInsightTypeConfig($insightTypeConfig);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
updateRecommenderConfig
Updates a Recommender Config. This will create a new revision of the config.
Parameters | |
---|---|
Name | Description |
recommenderConfig |
Google\Cloud\Recommender\V1\RecommenderConfig
Required. The RecommenderConfig to update. |
optionalArgs |
array
Optional. |
↳ updateMask |
FieldMask
The list of fields to be updated. |
↳ validateOnly |
bool
If true, validate the request and preview the change, but do not actually update it. |
↳ 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\Recommender\V1\RecommenderConfig |
use Google\ApiCore\ApiException;
use Google\Cloud\Recommender\V1\RecommenderClient;
use Google\Cloud\Recommender\V1\RecommenderConfig;
/**
* 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 update_recommender_config_sample(): void
{
// Create a client.
$recommenderClient = new RecommenderClient();
// Prepare any non-scalar elements to be passed along with the request.
$recommenderConfig = new RecommenderConfig();
// Call the API and handle any network failures.
try {
/** @var RecommenderConfig $response */
$response = $recommenderClient->updateRecommenderConfig($recommenderConfig);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
static::billingAccountLocationInsightTypeName
Formats a string containing the fully-qualified path to represent a billing_account_location_insight_type resource.
Parameters | |
---|---|
Name | Description |
billingAccount |
string
|
location |
string
|
insightType |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted billing_account_location_insight_type resource. |
static::billingAccountLocationInsightTypeConfigName
Formats a string containing the fully-qualified path to represent a billing_account_location_insight_type_config resource.
Parameters | |
---|---|
Name | Description |
billingAccount |
string
|
location |
string
|
insightType |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted billing_account_location_insight_type_config resource. |
static::billingAccountLocationInsightTypeInsightName
Formats a string containing the fully-qualified path to represent a billing_account_location_insight_type_insight resource.
Parameters | |
---|---|
Name | Description |
billingAccount |
string
|
location |
string
|
insightType |
string
|
insight |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted billing_account_location_insight_type_insight resource. |
static::billingAccountLocationRecommenderName
Formats a string containing the fully-qualified path to represent a billing_account_location_recommender resource.
Parameters | |
---|---|
Name | Description |
billingAccount |
string
|
location |
string
|
recommender |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted billing_account_location_recommender resource. |
static::billingAccountLocationRecommenderConfigName
Formats a string containing the fully-qualified path to represent a billing_account_location_recommender_config resource.
Parameters | |
---|---|
Name | Description |
billingAccount |
string
|
location |
string
|
recommender |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted billing_account_location_recommender_config resource. |
static::billingAccountLocationRecommenderRecommendationName
Formats a string containing the fully-qualified path to represent a billing_account_location_recommender_recommendation resource.
Parameters | |
---|---|
Name | Description |
billingAccount |
string
|
location |
string
|
recommender |
string
|
recommendation |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted billing_account_location_recommender_recommendation resource. |
static::folderLocationInsightTypeName
Formats a string containing the fully-qualified path to represent a folder_location_insight_type resource.
Parameters | |
---|---|
Name | Description |
folder |
string
|
location |
string
|
insightType |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted folder_location_insight_type resource. |
static::folderLocationInsightTypeInsightName
Formats a string containing the fully-qualified path to represent a folder_location_insight_type_insight resource.
Parameters | |
---|---|
Name | Description |
folder |
string
|
location |
string
|
insightType |
string
|
insight |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted folder_location_insight_type_insight resource. |
static::folderLocationRecommenderName
Formats a string containing the fully-qualified path to represent a folder_location_recommender resource.
Parameters | |
---|---|
Name | Description |
folder |
string
|
location |
string
|
recommender |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted folder_location_recommender resource. |
static::folderLocationRecommenderRecommendationName
Formats a string containing the fully-qualified path to represent a folder_location_recommender_recommendation resource.
Parameters | |
---|---|
Name | Description |
folder |
string
|
location |
string
|
recommender |
string
|
recommendation |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted folder_location_recommender_recommendation resource. |
static::insightName
Formats a string containing the fully-qualified path to represent a insight resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
location |
string
|
insightType |
string
|
insight |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted insight resource. |
static::insightTypeName
Formats a string containing the fully-qualified path to represent a insight_type resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
location |
string
|
insightType |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted insight_type resource. |
static::insightTypeConfigName
Formats a string containing the fully-qualified path to represent a insight_type_config resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
location |
string
|
insightType |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted insight_type_config resource. |
static::organizationLocationInsightTypeName
Formats a string containing the fully-qualified path to represent a organization_location_insight_type resource.
Parameters | |
---|---|
Name | Description |
organization |
string
|
location |
string
|
insightType |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted organization_location_insight_type resource. |
static::organizationLocationInsightTypeConfigName
Formats a string containing the fully-qualified path to represent a organization_location_insight_type_config resource.
Parameters | |
---|---|
Name | Description |
organization |
string
|
location |
string
|
insightType |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted organization_location_insight_type_config resource. |
static::organizationLocationInsightTypeInsightName
Formats a string containing the fully-qualified path to represent a organization_location_insight_type_insight resource.
Parameters | |
---|---|
Name | Description |
organization |
string
|
location |
string
|
insightType |
string
|
insight |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted organization_location_insight_type_insight resource. |
static::organizationLocationRecommenderName
Formats a string containing the fully-qualified path to represent a organization_location_recommender resource.
Parameters | |
---|---|
Name | Description |
organization |
string
|
location |
string
|
recommender |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted organization_location_recommender resource. |
static::organizationLocationRecommenderConfigName
Formats a string containing the fully-qualified path to represent a organization_location_recommender_config resource.
Parameters | |
---|---|
Name | Description |
organization |
string
|
location |
string
|
recommender |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted organization_location_recommender_config resource. |
static::organizationLocationRecommenderRecommendationName
Formats a string containing the fully-qualified path to represent a organization_location_recommender_recommendation resource.
Parameters | |
---|---|
Name | Description |
organization |
string
|
location |
string
|
recommender |
string
|
recommendation |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted organization_location_recommender_recommendation resource. |
static::projectLocationInsightTypeName
Formats a string containing the fully-qualified path to represent a project_location_insight_type resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
location |
string
|
insightType |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted project_location_insight_type resource. |
static::projectLocationInsightTypeConfigName
Formats a string containing the fully-qualified path to represent a project_location_insight_type_config resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
location |
string
|
insightType |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted project_location_insight_type_config resource. |
static::projectLocationInsightTypeInsightName
Formats a string containing the fully-qualified path to represent a project_location_insight_type_insight resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
location |
string
|
insightType |
string
|
insight |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted project_location_insight_type_insight resource. |
static::projectLocationRecommenderName
Formats a string containing the fully-qualified path to represent a project_location_recommender resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
location |
string
|
recommender |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted project_location_recommender resource. |
static::projectLocationRecommenderConfigName
Formats a string containing the fully-qualified path to represent a project_location_recommender_config resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
location |
string
|
recommender |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted project_location_recommender_config resource. |
static::projectLocationRecommenderRecommendationName
Formats a string containing the fully-qualified path to represent a project_location_recommender_recommendation resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
location |
string
|
recommender |
string
|
recommendation |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted project_location_recommender_recommendation resource. |
static::recommendationName
Formats a string containing the fully-qualified path to represent a recommendation resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
location |
string
|
recommender |
string
|
recommendation |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted recommendation resource. |
static::recommenderName
Formats a string containing the fully-qualified path to represent a recommender resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
location |
string
|
recommender |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted recommender resource. |
static::recommenderConfigName
Formats a string containing the fully-qualified path to represent a recommender_config resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
location |
string
|
recommender |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted recommender_config 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
- billingAccountLocationInsightType: billingAccounts/{billing_account}/locations/{location}/insightTypes/{insight_type}
- billingAccountLocationInsightTypeConfig: billingAccounts/{billing_account}/locations/{location}/insightTypes/{insight_type}/config
- billingAccountLocationInsightTypeInsight: billingAccounts/{billing_account}/locations/{location}/insightTypes/{insight_type}/insights/{insight}
- billingAccountLocationRecommender: billingAccounts/{billing_account}/locations/{location}/recommenders/{recommender}
- billingAccountLocationRecommenderConfig: billingAccounts/{billing_account}/locations/{location}/recommenders/{recommender}/config
- billingAccountLocationRecommenderRecommendation: billingAccounts/{billing_account}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}
- folderLocationInsightType: folders/{folder}/locations/{location}/insightTypes/{insight_type}
- folderLocationInsightTypeInsight: folders/{folder}/locations/{location}/insightTypes/{insight_type}/insights/{insight}
- folderLocationRecommender: folders/{folder}/locations/{location}/recommenders/{recommender}
- folderLocationRecommenderRecommendation: folders/{folder}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}
- insight: projects/{project}/locations/{location}/insightTypes/{insight_type}/insights/{insight}
- insightType: projects/{project}/locations/{location}/insightTypes/{insight_type}
- insightTypeConfig: projects/{project}/locations/{location}/insightTypes/{insight_type}/config
- organizationLocationInsightType: organizations/{organization}/locations/{location}/insightTypes/{insight_type}
- organizationLocationInsightTypeConfig: organizations/{organization}/locations/{location}/insightTypes/{insight_type}/config
- organizationLocationInsightTypeInsight: organizations/{organization}/locations/{location}/insightTypes/{insight_type}/insights/{insight}
- organizationLocationRecommender: organizations/{organization}/locations/{location}/recommenders/{recommender}
- organizationLocationRecommenderConfig: organizations/{organization}/locations/{location}/recommenders/{recommender}/config
- organizationLocationRecommenderRecommendation: organizations/{organization}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}
- projectLocationInsightType: projects/{project}/locations/{location}/insightTypes/{insight_type}
- projectLocationInsightTypeConfig: projects/{project}/locations/{location}/insightTypes/{insight_type}/config
- projectLocationInsightTypeInsight: projects/{project}/locations/{location}/insightTypes/{insight_type}/insights/{insight}
- projectLocationRecommender: projects/{project}/locations/{location}/recommenders/{recommender}
- projectLocationRecommenderConfig: projects/{project}/locations/{location}/recommenders/{recommender}/config
- projectLocationRecommenderRecommendation: projects/{project}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}
- recommendation: projects/{project}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}
- recommender: projects/{project}/locations/{location}/recommenders/{recommender}
- recommenderConfig: projects/{project}/locations/{location}/recommenders/{recommender}/config
The optional $template argument can be supplied to specify a particular pattern, and must match one of the templates listed above. If no $template argument is provided, or if the $template argument does not match one of the templates listed, then parseName will check each of the supported templates, and return the first match.
Parameters | |
---|---|
Name | Description |
formattedName |
string
The formatted name string |
template |
string
Optional name of template to match |
Returns | |
---|---|
Type | Description |
array | An associative array from name component IDs to component values. |
Constants
SERVICE_NAME
Value: 'google.cloud.recommender.v1.Recommender'
The name of the service.
SERVICE_ADDRESS
Value: 'recommender.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.