crate.operator.webhooks module¶
- class crate.operator.webhooks.WebhookAction(value)¶
-
An enumeration.
- ALLOWED_CIDR_UPDATE = 'allowed_cidr_update'¶
- BACKUP_SCHEDULE_UPDATE = 'backup_schedule_update'¶
- CHANGE_COMPUTE = 'change_compute'¶
- CREATE = 'create'¶
- EXPAND_STORAGE = 'expand_storage'¶
- PASSWORD_UPDATE = 'password_update'¶
- RESTORE_SNAPSHOT = 'restore_snapshot'¶
- SCALE = 'scale'¶
- SUSPEND = 'suspend'¶
- UNKNOWN = 'unknown'¶
- UPGRADE = 'upgrade'¶
- class crate.operator.webhooks.WebhookClient¶
Bases:
object
A client to send HTTP POST requests to an API endpoint if configured.
The
WebhookClient
is a wrapper aroundaiohttp
, providing a specific API that allows sending webhook notifications to an external service.By default, an instance is not configured. One needs to call
configure()
to enable notification sending. otherwise, sending will be ignored and a log message written instead.The webhooks section in the cepepts part of the documentation elaborates on the payload.
- configure(url, username, password)¶
Configure and enable the client.
- Parameters
- Return type
- property configured: bool¶
Return if the client is configured. If not, all notification sending should be skipped.
- async send_notification(namespace, name, event, sub_payload, status, logger, *, unsafe=False)¶
Send a webhook notification to the configured webhook URL. Will do nothing if no webhooks are configured.
Webhooks are normally fire-and-forget FYI information that must not block kopf from continuing with the handler chain. In some cases however, the webhook is the whole point (i.e. IP address acquired), so we want to fail if an error happens so that the operation could be retried.
- Parameters
name (
str
) – Name of the cluster this notification is aboutnamespace (
str
) – Namespaces where this event happenedevent (
WebhookEvent
) – The event typesub_payload (
WebhookSubPayload
) – The specific payload for the event typestatus (
WebhookStatus
) – The status of the eventlogger (
Logger
) – The logger to useunsafe (
Optional
[bool
]) – Whether to throw exceptions if any happen. Defaults to False - exceptions will be logged but not propagated.
- class crate.operator.webhooks.WebhookEvent(value)¶
-
An enumeration.
- ADMIN_USERNAME_CHANGED = 'admin_username_changed'¶
- BACKUP_SCHEDULE_UPDATE = 'backup_schedule_update'¶
- COMPUTE_CHANGED = 'compute_changed'¶
- DELAY = 'delay'¶
- FEEDBACK = 'feedback'¶
- HEALTH = 'health'¶
- INFO_CHANGED = 'info_changed'¶
- SCALE = 'scale'¶
- SNAPSHOT = 'snapshot'¶
- UPGRADE = 'upgrade'¶
- class crate.operator.webhooks.WebhookFeedbackPayload¶
Bases:
dict
-
action:
WebhookAction
¶
-
operation:
WebhookOperation
¶
-
action:
- class crate.operator.webhooks.WebhookOperation(value)¶
-
An enumeration.
- CREATE = 'create'¶
- UPDATE = 'update'¶
- class crate.operator.webhooks.WebhookPayload¶
Bases:
TypedDict
-
admin_username_changed_data:
Optional
[WebhookAdminUsernameChangedPayload
]¶
-
backup_schedule_data:
Optional
[WebhookBackupScheduleUpdatePayload
]¶
-
compute_changed_data:
Optional
[WebhookChangeComputePayload
]¶
-
event:
WebhookEvent
¶
-
feedback_data:
Optional
[WebhookFeedbackPayload
]¶
-
health_data:
Optional
[WebhookClusterHealthPayload
]¶
-
info_data:
Optional
[WebhookInfoChangedPayload
]¶
-
scale_data:
Optional
[WebhookScalePayload
]¶
-
status:
WebhookStatus
¶
-
temporary_failure_data:
Optional
[WebhookTemporaryFailurePayload
]¶
-
upgrade_data:
Optional
[WebhookUpgradePayload
]¶
-
admin_username_changed_data:
- class crate.operator.webhooks.WebhookScalePayload¶
Bases:
dict
-
new_data_replicas:
List
[WebhookScaleNodePayload
]¶
-
old_data_replicas:
List
[WebhookScaleNodePayload
]¶
-
new_data_replicas: