Class RecommenderClient (1.0.0)

RecommenderClient(
    transport=None,
    channel=None,
    credentials=None,
    client_config=None,
    client_info=None,
    client_options=None,
)

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.

Methods

RecommenderClient

RecommenderClient(
    transport=None,
    channel=None,
    credentials=None,
    client_config=None,
    client_info=None,
    client_options=None,
)

Constructor.

Parameters
NameDescription
channel grpc.Channel

DEPRECATED. A Channel instance through which to make calls. This argument is mutually exclusive with credentials; providing both will raise an exception.

credentials google.auth.credentials.Credentials

The authorization credentials to attach to requests. These credentials identify this application to the service. If none are specified, the client will attempt to ascertain the credentials from the environment. This argument is mutually exclusive with providing a transport instance to transport; doing so will raise an exception.

client_config dict

DEPRECATED. A dictionary of call options for each method. If not specified, the default configuration is used.

client_info google.api_core.gapic_v1.client_info.ClientInfo

The client info used to send a user-agent string along with API requests. If None, then default info will be used. Generally, you only need to set this if you're developing your own client library.

client_options Union[dict, google.api_core.client_options.ClientOptions]

Client options used to set user options on the client. API Endpoint should be set through client_options.

from_service_account_file

from_service_account_file(filename, *args, **kwargs)

Creates an instance of this client using the provided credentials file.

Parameter
NameDescription
filename str

The path to the service account private key json file.

Returns
TypeDescription
RecommenderClientThe constructed client.

from_service_account_json

from_service_account_json(filename, *args, **kwargs)

Creates an instance of this client using the provided credentials file.

Parameter
NameDescription
filename str

The path to the service account private key json file.

Returns
TypeDescription
RecommenderClientThe constructed client.

get_insight

get_insight(name, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

Gets the requested insight. Requires the recommender.*.get IAM permission for the specified insight type.

.. rubric:: Example

from google.cloud import recommender_v1beta1

client = recommender_v1beta1.RecommenderClient()

name = client.insight_path('[PROJECT]', '[LOCATION]', '[INSIGHT_TYPE]', '[INSIGHT]')

response = client.get_insight(name)

Parameters
NameDescription
name str

Required. Name of the insight.

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

get_recommendation

get_recommendation(name, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

Gets the requested recommendation. Requires the recommender.*.get IAM permission for the specified recommender.

.. rubric:: Example

from google.cloud import recommender_v1beta1

client = recommender_v1beta1.RecommenderClient()

name = client.recommendation_path('[PROJECT]', '[LOCATION]', '[RECOMMENDER]', '[RECOMMENDATION]')

response = client.get_recommendation(name)

Parameters
NameDescription
name str

Required. Name of the recommendation.

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

insight_path

insight_path(project, location, insight_type, insight)

Return a fully-qualified insight string.

insight_type_path

insight_type_path(project, location, insight_type)

Return a fully-qualified insight_type string.

list_insights

list_insights(parent, page_size=None, filter_=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

Lists insights for a Cloud project. Requires the recommender.*.list IAM permission for the specified insight type.

.. rubric:: Example

from google.cloud import recommender_v1beta1

client = recommender_v1beta1.RecommenderClient()

parent = client.insight_type_path('[PROJECT]', '[LOCATION]', '[INSIGHT_TYPE]')

Iterate over all results

for element in client.list_insights(parent): ... # process element ... pass

Alternatively:

Iterate over results one page at a time

for page in client.list_insights(parent).pages: ... for element in page: ... # process element ... pass

Parameters
NameDescription
parent str

Required. The container resource on which to execute the request. Acceptable formats: 1. "projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]", LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/

page_size int

The maximum number of resources contained in the underlying API response. If page streaming is performed per- resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

filter_ str

Optional. Filter expression to restrict the insights returned. Supported filter fields: state Eg: `state:"DISMISSED" or state:"ACTIVE"

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

list_recommendations

list_recommendations(parent, page_size=None, filter_=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

Lists recommendations for a Cloud project. Requires the recommender.*.list IAM permission for the specified recommender.

.. rubric:: Example

from google.cloud import recommender_v1beta1

client = recommender_v1beta1.RecommenderClient()

parent = client.recommender_path('[PROJECT]', '[LOCATION]', '[RECOMMENDER]')

Iterate over all results

for element in client.list_recommendations(parent): ... # process element ... pass

Alternatively:

Iterate over results one page at a time

for page in client.list_recommendations(parent).pages: ... for element in page: ... # process element ... pass

Parameters
NameDescription
parent str

Required. The container resource on which to execute the request. Acceptable formats: 1. "projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]", LOCATION here refers to GCP Locations: https://cloud.google.com/about/locations/

page_size int

The maximum number of resources contained in the underlying API response. If page streaming is performed per- resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

filter_ str

Filter expression to restrict the recommendations returned. Supported filter fields: state_info.state Eg: `state_info.state:"DISMISSED" or state_info.state:"FAILED"

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

mark_insight_accepted

mark_insight_accepted(name, etag, state_metadata=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

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.

.. rubric:: Example

from google.cloud import recommender_v1beta1

client = recommender_v1beta1.RecommenderClient()

name = client.insight_path('[PROJECT]', '[LOCATION]', '[INSIGHT_TYPE]', '[INSIGHT]')

TODO: Initialize etag:

etag = ''

response = client.mark_insight_accepted(name, etag)

Parameters
NameDescription
name str

Required. Name of the insight.

etag str

Required. Fingerprint of the Insight. Provides optimistic locking.

state_metadata dict[str -> str]

Optional. State properties user wish to include with this state. Full replace of the current state_metadata.

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

mark_recommendation_claimed

mark_recommendation_claimed(name, etag, state_metadata=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

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 or ACTIVE state.

Requires the recommender.*.update IAM permission for the specified recommender.

.. rubric:: Example

from google.cloud import recommender_v1beta1

client = recommender_v1beta1.RecommenderClient()

name = client.recommendation_path('[PROJECT]', '[LOCATION]', '[RECOMMENDER]', '[RECOMMENDATION]')

TODO: Initialize etag:

etag = ''

response = client.mark_recommendation_claimed(name, etag)

Parameters
NameDescription
name str

Required. Name of the recommendation.

etag str

Required. Fingerprint of the Recommendation. Provides optimistic locking.

state_metadata dict[str -> str]

State properties to include with this state. Overwrites any existing state_metadata. Keys must match the regex /^a-z0-9][a-z0-9_.-]{0,62}$/. Values must match the regex /^[a-zA-Z0-9_./-]{0,255}$/.

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

mark_recommendation_failed

mark_recommendation_failed(name, etag, state_metadata=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

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.

.. rubric:: Example

from google.cloud import recommender_v1beta1

client = recommender_v1beta1.RecommenderClient()

name = client.recommendation_path('[PROJECT]', '[LOCATION]', '[RECOMMENDER]', '[RECOMMENDATION]')

TODO: Initialize etag:

etag = ''

response = client.mark_recommendation_failed(name, etag)

Parameters
NameDescription
name str

Required. Name of the recommendation.

etag str

Required. Fingerprint of the Recommendation. Provides optimistic locking.

state_metadata dict[str -> str]

State properties to include with this state. Overwrites any existing state_metadata. Keys must match the regex /^a-z0-9][a-z0-9_.-]{0,62}$/. Values must match the regex /^[a-zA-Z0-9_./-]{0,255}$/.

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

mark_recommendation_succeeded

mark_recommendation_succeeded(name, etag, state_metadata=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

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.

.. rubric:: Example

from google.cloud import recommender_v1beta1

client = recommender_v1beta1.RecommenderClient()

name = client.recommendation_path('[PROJECT]', '[LOCATION]', '[RECOMMENDER]', '[RECOMMENDATION]')

TODO: Initialize etag:

etag = ''

response = client.mark_recommendation_succeeded(name, etag)

Parameters
NameDescription
name str

Required. Name of the recommendation.

etag str

Required. Fingerprint of the Recommendation. Provides optimistic locking.

state_metadata dict[str -> str]

State properties to include with this state. Overwrites any existing state_metadata. Keys must match the regex /^a-z0-9][a-z0-9_.-]{0,62}$/. Values must match the regex /^[a-zA-Z0-9_./-]{0,255}$/.

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

recommendation_path

recommendation_path(project, location, recommender, recommendation)

Return a fully-qualified recommendation string.

recommender_path

recommender_path(project, location, recommender)

Return a fully-qualified recommender string.