airflow.providers.google.cloud.hooks.stackdriver
¶
This module contains Google Cloud Stackdriver operators.
Module Contents¶
Classes¶
Stackdriver Hook for connecting with Google Cloud Stackdriver. |
- class airflow.providers.google.cloud.hooks.stackdriver.StackdriverHook(gcp_conn_id='google_cloud_default', impersonation_chain=None, **kwargs)[source]¶
Bases:
airflow.providers.google.common.hooks.base_google.GoogleBaseHook
Stackdriver Hook for connecting with Google Cloud Stackdriver.
- list_alert_policies(project_id=PROVIDE_PROJECT_ID, format_=None, filter_=None, order_by=None, page_size=None, retry=DEFAULT, timeout=None, metadata=())[source]¶
Fetches all the Alert Policies identified by the filter passed as filter parameter.
The desired return type can be specified by the format parameter, the supported formats are “dict”, “json” and None which returns python dictionary, stringified JSON and protobuf respectively.
- Parameters
format – (Optional) Desired output format of the result. The supported formats are “dict”, “json” and None which returns python dictionary, stringified JSON and protobuf respectively.
filter – If provided, this field specifies the criteria that must be met by alert policies to be included in the response. For more details, see https://cloud.google.com/monitoring/api/v3/sorting-and-filtering.
order_by (str | None) – A comma-separated list of fields by which to sort the result. Supports the same set of field references as the
filter
field. Entries can be prefixed with a minus sign to sort by the field in descending order. For more details, see https://cloud.google.com/monitoring/api/v3/sorting-and-filtering.page_size (int | None) – 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.
retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – A retry object used to retry requests. If
None
is specified, requests will be retried using a default configuration.timeout (float | None) – 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 (Sequence[tuple[str, str]]) – Additional metadata that is provided to the method.
project_id (str) – The project to fetch alerts from.
- enable_alert_policies(project_id=PROVIDE_PROJECT_ID, filter_=None, retry=DEFAULT, timeout=None, metadata=())[source]¶
Enables one or more disabled alerting policies identified by filter parameter.
Inoperative in case the policy is already enabled.
- Parameters
project_id (str) – The project in which alert needs to be enabled.
filter – If provided, this field specifies the criteria that must be met by alert policies to be enabled. For more details, see https://cloud.google.com/monitoring/api/v3/sorting-and-filtering.
retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – A retry object used to retry requests. If
None
is specified, requests will be retried using a default configuration.timeout (float | None) – 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 (Sequence[tuple[str, str]]) – Additional metadata that is provided to the method.
- disable_alert_policies(project_id=PROVIDE_PROJECT_ID, filter_=None, retry=DEFAULT, timeout=None, metadata=())[source]¶
Disables one or more enabled alerting policies identified by filter parameter.
Inoperative in case the policy is already disabled.
- Parameters
project_id (str) – The project in which alert needs to be disabled.
filter – If provided, this field specifies the criteria that must be met by alert policies to be disabled. For more details, see https://cloud.google.com/monitoring/api/v3/sorting-and-filtering.
retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – A retry object used to retry requests. If
None
is specified, requests will be retried using a default configuration.timeout (float | None) – 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 (Sequence[tuple[str, str]]) – Additional metadata that is provided to the method.
- upsert_alert(alerts, project_id=PROVIDE_PROJECT_ID, retry=DEFAULT, timeout=None, metadata=())[source]¶
Creates a new alert or updates an existing policy identified the name field in the alerts parameter.
- Parameters
project_id (str) – The project in which alert needs to be created/updated.
alerts (str) – A JSON string or file that specifies all the alerts that needs to be either created or updated. For more details, see https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.alertPolicies#AlertPolicy. (templated)
retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – A retry object used to retry requests. If
None
is specified, requests will be retried using a default configuration.timeout (float | None) – 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 (Sequence[tuple[str, str]]) – Additional metadata that is provided to the method.
- delete_alert_policy(name, retry=DEFAULT, timeout=None, metadata=())[source]¶
Deletes an alerting policy.
- Parameters
name (str) – The alerting policy to delete. The format is:
projects/[PROJECT_ID]/alertPolicies/[ALERT_POLICY_ID]
.retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – A retry object used to retry requests. If
None
is specified, requests will be retried using a default configuration.timeout (float | None) – 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 (Sequence[tuple[str, str]]) – Additional metadata that is provided to the method.
- list_notification_channels(project_id=PROVIDE_PROJECT_ID, format_=None, filter_=None, order_by=None, page_size=None, retry=DEFAULT, timeout=None, metadata=())[source]¶
Fetches all the Notification Channels identified by the filter passed as filter parameter.
The desired return type can be specified by the format parameter, the supported formats are “dict”, “json” and None which returns python dictionary, stringified JSON and protobuf respectively.
- Parameters
format – (Optional) Desired output format of the result. The supported formats are “dict”, “json” and None which returns python dictionary, stringified JSON and protobuf respectively.
filter – If provided, this field specifies the criteria that must be met by notification channels to be included in the response. For more details, see https://cloud.google.com/monitoring/api/v3/sorting-and-filtering.
order_by (str | None) – A comma-separated list of fields by which to sort the result. Supports the same set of field references as the
filter
field. Entries can be prefixed with a minus sign to sort by the field in descending order. For more details, see https://cloud.google.com/monitoring/api/v3/sorting-and-filtering.page_size (int | None) – 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.
retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – A retry object used to retry requests. If
None
is specified, requests will be retried using a default configuration.timeout (float | None) – 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 (Sequence[tuple[str, str]]) – Additional metadata that is provided to the method.
project_id (str) – The project to fetch notification channels from.
- enable_notification_channels(project_id=PROVIDE_PROJECT_ID, filter_=None, retry=DEFAULT, timeout=None, metadata=())[source]¶
Enables one or more disabled alerting policies identified by filter parameter.
Inoperative in case the policy is already enabled.
- Parameters
project_id (str) – The project in which notification channels needs to be enabled.
filter – If provided, this field specifies the criteria that must be met by notification channels to be enabled. For more details, see https://cloud.google.com/monitoring/api/v3/sorting-and-filtering.
retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – A retry object used to retry requests. If
None
is specified, requests will be retried using a default configuration.timeout (float | None) – 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 (Sequence[tuple[str, str]]) – Additional metadata that is provided to the method.
- disable_notification_channels(project_id, filter_=None, retry=DEFAULT, timeout=None, metadata=())[source]¶
Disables one or more enabled notification channels identified by filter parameter.
Inoperative in case the policy is already disabled.
- Parameters
project_id (str) – The project in which notification channels needs to be enabled.
filter – If provided, this field specifies the criteria that must be met by alert policies to be disabled. For more details, see https://cloud.google.com/monitoring/api/v3/sorting-and-filtering.
retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – A retry object used to retry requests. If
None
is specified, requests will be retried using a default configuration.timeout (float | None) – 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 (Sequence[tuple[str, str]]) – Additional metadata that is provided to the method.
- upsert_channel(channels, project_id, retry=DEFAULT, timeout=None, metadata=())[source]¶
Create a new notification or updates an existing notification channel.
Channel is identified by the name field in the alerts parameter.
- Parameters
channels (str) – A JSON string or file that specifies all the alerts that needs to be either created or updated. For more details, see https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.notificationChannels. (templated)
project_id (str) – The project in which notification channels needs to be created/updated.
retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – A retry object used to retry requests. If
None
is specified, requests will be retried using a default configuration.timeout (float | None) – 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 (Sequence[tuple[str, str]]) – Additional metadata that is provided to the method.
- delete_notification_channel(name, retry=DEFAULT, timeout=None, metadata=())[source]¶
Deletes a notification channel.
- Parameters
name (str) – The alerting policy to delete. The format is:
projects/[PROJECT_ID]/notificationChannels/[CHANNEL_ID]
.retry (google.api_core.retry.Retry | google.api_core.gapic_v1.method._MethodDefault) – A retry object used to retry requests. If
None
is specified, requests will be retried using a default configuration.timeout (float | None) – 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 (Sequence[tuple[str, str]]) – Additional metadata that is provided to the method.