ExStorageService.Notifications (ex_storage_service v0.6.2)

Copy Markdown View Source

Webhook-based bucket event notifications.

On object create/delete events, POSTs event JSON to configured webhook endpoints. Notifications are delivered asynchronously via Task.Supervisor.

Configuration stored in Concord: "notification:{bucket}"

Notification config format: %{

id: "notification-id",
events: ["s3:ObjectCreated:*", "s3:ObjectRemoved:*"],
endpoint: "https://example.com/webhook",
enabled: true

}

Summary

Functions

Build an S3-style event notification payload.

Delete notification configuration for a bucket.

Get notification configuration for a bucket.

Notify about an object event. Sends webhooks asynchronously.

Configure notifications for a bucket.

Functions

build_event(bucket, key, event_type, extra \\ %{})

@spec build_event(String.t(), String.t(), String.t(), map()) :: map()

Build an S3-style event notification payload.

delete_config(bucket)

@spec delete_config(String.t()) :: :ok

Delete notification configuration for a bucket.

get_config(bucket)

@spec get_config(String.t()) :: {:ok, [map()]} | {:error, :not_found}

Get notification configuration for a bucket.

notify(bucket, key, event_type, extra \\ %{})

@spec notify(String.t(), String.t(), String.t(), map()) :: :ok

Notify about an object event. Sends webhooks asynchronously.

Event types:

  • "s3:ObjectCreated:Put"
  • "s3:ObjectCreated:Copy"
  • "s3:ObjectCreated:CompleteMultipartUpload"
  • "s3:ObjectRemoved:Delete"
  • "s3:ObjectRemoved:DeleteMarkerCreated"

put_config(bucket, configs)

@spec put_config(String.t(), [map()]) :: :ok | {:error, term()}

Configure notifications for a bucket.