google_cloud_storage/http/notifications/
insert.rs1use std::collections::HashMap;
2
3use reqwest_middleware::{ClientWithMiddleware as Client, RequestBuilder};
4
5use crate::http::notifications::{EventType, PayloadFormat};
6use crate::http::Escape;
7
8#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Default, Debug)]
9pub struct NotificationCreationConfig {
10 pub topic: String,
13 pub event_types: Option<Vec<EventType>>,
16 pub custom_attributes: HashMap<String, String>,
19 pub object_name_prefix: Option<String>,
22 pub payload_format: PayloadFormat,
24}
25
26#[derive(Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Debug)]
28#[serde(rename_all = "camelCase")]
29pub struct InsertNotificationRequest {
30 pub bucket: String,
32 pub notification: NotificationCreationConfig,
34}
35
36pub(crate) fn build(base_url: &str, client: &Client, req: &InsertNotificationRequest) -> RequestBuilder {
37 let url = format!("{}/b/{}/notificationConfigs", base_url, req.bucket.escape());
38 client.post(url).json(&req.notification)
39}