foundation_deployment_cloudflare 0.1.3

Cloudflare API v4 client — DNS records, zones, certificates
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
//! Auto-generated API module for cloudflare analytics.
//!
//! Generated by `cargo run --bin ewe_platform gen_api`.
//! DO NOT EDIT MANUALLY.
//!
//! Feature flag: `cloudflare_analytics `

#![cfg(feature = "cloudflare_analytics")]
#![allow(clippy::too_many_arguments, clippy::type_complexity)]
#![allow(
    clippy::missing_errors_doc,
    clippy::doc_markdown,
    clippy::useless_format
)]
#![allow(unused_imports)]

use foundation_macros::JsonHash;
use foundation_netio::shared::client::http_client::HttpClient;
use foundation_netio::{DynNetClient, PreparedRequestBuilder};
use serde::{Deserialize, Serialize};

use super::shared::ApiResponse;

// =============================================================================
// TYPE DECLARATIONS
// =============================================================================

/// `RumApiResponseCommon` type.
///
/// Same shape as `super::shared::ErrorsMessagesSuccessObject`.
pub type RumApiResponseCommon = super::shared::ErrorsMessagesSuccessObject;

/// `RumAutoInstall` type.
pub type RumAutoInstall = bool;

/// `RumCreateRuleRequest` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct RumCreateRuleRequest {
    /// `host` property.
    pub host: Option<String>,
    /// `inclusive` property.
    pub inclusive: Option<bool>,
    /// `is_paused` property.
    pub is_paused: Option<bool>,
    /// `paths` property.
    pub paths: Option<Vec<String>>,
}

/// `RumCreateSiteRequest` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct RumCreateSiteRequest {
    /// `auto_install` property.
    pub auto_install: Option<bool>,
    /// `host` property.
    pub host: Option<String>,
    /// `zone_tag` property.
    pub zone_tag: Option<String>,
}

/// `RumEnabled` type.
pub type RumEnabled = bool;

/// `RumHost` type.
pub type RumHost = String;

/// `RumLite` type.
pub type RumLite = bool;

/// `RumMessages` type.
pub type RumMessages = Vec<std::collections::HashMap<String, serde_json::Value>>;

/// `RumModifyRulesRequest` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct RumModifyRulesRequest {
    /// `delete_rules` property.
    pub delete_rules: Option<Vec<String>>,
    /// `rules` property.
    pub rules: Option<Vec<std::collections::HashMap<String, serde_json::Value>>>,
}

/// `RumResultInfo` type.
///
/// Same shape as `super::shared::RumResultInfoShape`.
pub type RumResultInfo = super::shared::RumResultInfoShape;

/// `RumRule` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct RumRule {
    /// `created` property.
    pub created: Option<String>,
    /// `host` property.
    pub host: Option<String>,
    /// `id` property.
    pub id: Option<String>,
    /// `inclusive` property.
    pub inclusive: Option<bool>,
    /// `is_paused` property.
    pub is_paused: Option<bool>,
    /// `paths` property.
    pub paths: Option<Vec<String>>,
    /// `priority` property.
    pub priority: Option<f64>,
}

/// `RumRuleIdResponseSingle` type.
///
/// Same shape as `super::shared::ApiEnvelope<Option<std::collections::HashMap<String, serde_json::Value>>>`.
pub type RumRuleIdResponseSingle =
    super::shared::ApiEnvelope<Option<std::collections::HashMap<String, serde_json::Value>>>;

/// `RumRuleIdentifier` type.
pub type RumRuleIdentifier = String;

/// `RumRuleResponseSingle` type.
///
/// Same shape as `super::shared::ApiEnvelope<Option<RumRule>>`.
pub type RumRuleResponseSingle = super::shared::ApiEnvelope<Option<RumRule>>;

/// `RumRules` type.
pub type RumRules = Vec<RumRule>;

/// `RumRulesResponseCollection` type.
///
/// Same shape as `super::shared::ApiEnvelope<Option<std::collections::HashMap<String, serde_json::Value>>>`.
pub type RumRulesResponseCollection =
    super::shared::ApiEnvelope<Option<std::collections::HashMap<String, serde_json::Value>>>;

/// `RumRuleset` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct RumRuleset {
    /// `enabled` property.
    pub enabled: Option<bool>,
    /// `id` property.
    pub id: Option<String>,
    /// `zone_name` property.
    pub zone_name: Option<String>,
    /// `zone_tag` property.
    pub zone_tag: Option<String>,
}

/// `RumRulesetIdentifier` type.
pub type RumRulesetIdentifier = String;

/// `RumSite` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct RumSite {
    /// `auto_install` property.
    pub auto_install: Option<bool>,
    /// `created` property.
    pub created: Option<String>,
    /// `rules` property.
    pub rules: Option<Vec<RumRule>>,
    /// `ruleset` property.
    pub ruleset: Option<RumRuleset>,
    /// `site_tag` property.
    pub site_tag: Option<String>,
    /// `site_token` property.
    pub site_token: Option<String>,
    /// `snippet` property.
    pub snippet: Option<String>,
}

/// `RumSiteResponseSingle` type.
///
/// Same shape as `super::shared::ApiEnvelope<Option<RumSite>>`.
pub type RumSiteResponseSingle = super::shared::ApiEnvelope<Option<RumSite>>;

/// `RumSiteTag` type.
pub type RumSiteTag = String;

/// `RumSiteTagResponseSingle` type.
///
/// Same shape as `super::shared::ApiEnvelope<Option<std::collections::HashMap<String, serde_json::Value>>>`.
pub type RumSiteTagResponseSingle =
    super::shared::ApiEnvelope<Option<std::collections::HashMap<String, serde_json::Value>>>;

/// `RumSiteToken` type.
pub type RumSiteToken = String;

/// `RumSitesResponseCollection` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct RumSitesResponseCollection {
    /// `errors` property.
    pub errors: Vec<std::collections::HashMap<String, serde_json::Value>>,
    /// `messages` property.
    pub messages: Vec<std::collections::HashMap<String, serde_json::Value>>,
    /// `result` property.
    pub result: Option<Vec<RumSite>>,
    /// `result_info` property.
    pub result_info: Option<RumResultInfo>,
    /// `success` property.
    pub success: bool,
}

/// `RumSnippet` type.
pub type RumSnippet = String;

/// `RumTimestamp` type.
pub type RumTimestamp = String;

/// `RumUpdateSiteRequest` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonHash)]
pub struct RumUpdateSiteRequest {
    /// `auto_install` property.
    pub auto_install: Option<bool>,
    /// `enabled` property.
    pub enabled: Option<bool>,
    /// `host` property.
    pub host: Option<String>,
    /// `lite` property.
    pub lite: Option<bool>,
    /// `zone_tag` property.
    pub zone_tag: Option<String>,
}

/// `RumZoneTag` type.
pub type RumZoneTag = String;

// =============================================================================
// ARGS TYPES (per-endpoint)
// =============================================================================

/// Arguments for [`web-analytics-create-site_request`].
#[derive(Debug, Clone, Default, Serialize, JsonHash)]
pub struct WebAnalyticsCreateSiteArgs {
    /// Path parameter: `account_id`.
    pub account_id: String,
    /// Request body.
    pub body: RumCreateSiteRequest,
}

/// Arguments for [`web-analytics-list-sites_request`].
#[derive(Debug, Clone, Default, Serialize, JsonHash)]
pub struct WebAnalyticsListSitesArgs {
    /// Path parameter: `account_id`.
    pub account_id: String,
    /// Query parameter: `per_page`.
    pub per_page: Option<String>,
    /// Query parameter: `page`.
    pub page: Option<String>,
    /// Query parameter: `order_by`.
    pub order_by: Option<String>,
}

/// Arguments for [`web-analytics-get-site_request`].
///
/// Same shape as `super::shared::AccountIdSiteIdArgs`.
pub type WebAnalyticsGetSiteArgs = super::shared::AccountIdSiteIdArgs;

/// Arguments for [`web-analytics-update-site_request`].
#[derive(Debug, Clone, Default, Serialize, JsonHash)]
pub struct WebAnalyticsUpdateSiteArgs {
    /// Path parameter: `account_id`.
    pub account_id: String,
    /// Path parameter: `site_id`.
    pub site_id: String,
    /// Request body.
    pub body: RumUpdateSiteRequest,
}

/// Arguments for [`web-analytics-delete-site_request`].
///
/// Same shape as `super::shared::AccountIdSiteIdArgs`.
pub type WebAnalyticsDeleteSiteArgs = super::shared::AccountIdSiteIdArgs;

/// Arguments for [`web-analytics-create-rule_request`].
#[derive(Debug, Clone, Default, Serialize, JsonHash)]
pub struct WebAnalyticsCreateRuleArgs {
    /// Path parameter: `account_id`.
    pub account_id: String,
    /// Path parameter: `ruleset_id`.
    pub ruleset_id: String,
    /// Request body.
    pub body: RumCreateRuleRequest,
}

/// Arguments for [`web-analytics-update-rule_request`].
#[derive(Debug, Clone, Default, Serialize, JsonHash)]
pub struct WebAnalyticsUpdateRuleArgs {
    /// Path parameter: `account_id`.
    pub account_id: String,
    /// Path parameter: `ruleset_id`.
    pub ruleset_id: String,
    /// Path parameter: `rule_id`.
    pub rule_id: String,
    /// Request body.
    pub body: RumCreateRuleRequest,
}

/// Arguments for [`web-analytics-delete-rule_request`].
#[derive(Debug, Clone, Default, Serialize, JsonHash)]
pub struct WebAnalyticsDeleteRuleArgs {
    /// Path parameter: `account_id`.
    pub account_id: String,
    /// Path parameter: `ruleset_id`.
    pub ruleset_id: String,
    /// Path parameter: `rule_id`.
    pub rule_id: String,
}

/// Arguments for [`web-analytics-list-rules_request`].
#[derive(Debug, Clone, Default, Serialize, JsonHash)]
pub struct WebAnalyticsListRulesArgs {
    /// Path parameter: `account_id`.
    pub account_id: String,
    /// Path parameter: `ruleset_id`.
    pub ruleset_id: String,
}

/// Arguments for [`web-analytics-modify-rules_request`].
#[derive(Debug, Clone, Default, Serialize, JsonHash)]
pub struct WebAnalyticsModifyRulesArgs {
    /// Path parameter: `account_id`.
    pub account_id: String,
    /// Path parameter: `ruleset_id`.
    pub ruleset_id: String,
    /// Request body.
    pub body: RumModifyRulesRequest,
}

// =============================================================================
// CLIENT FUNCTIONS (per-endpoint)
// =============================================================================

// -----------------------------------------------------------------------------
// POST /accounts/{account_id}/rum/site_info
// -----------------------------------------------------------------------------

/// POST /accounts/{account_id}/rum/site_info.
///
/// Takes a client and args, builds the request, optionally applies
/// modifications, then sends it via `send_async().await`.
///
/// # Arguments
///
/// * `client` - HTTP client for making the request: a `DynNetClient`, or an `ApiClient` carrying the `BodyLimits` the response is read under
/// * `args` - Request arguments (path params, query params, body)
/// * `builder_mod` - Optional closure to modify the request builder (e.g., add headers)
///
/// # Example
///
/// ```ignore
/// let response = web_analytics_create_site_request(client.clone(), &args, Some(|b: &mut PreparedRequestBuilder| {
///     b.header("X-Custom-Header", "value");
/// })).await?;
/// ```
pub async fn web_analytics_create_site_request<F>(
    client: impl Into<super::shared::ApiClient>,
    args: &WebAnalyticsCreateSiteArgs,
    base_url: &str,
    builder_mod: Option<F>,
) -> Result<ApiResponse<RumSiteResponseSingle>, super::shared::ApiError>
where
    F: FnOnce(&mut PreparedRequestBuilder),
{
    let path = format!("/accounts/{}/rum/site_info", args.account_id,);
    let endpoint_url = format!("{}{}", base_url, path);

    let mut builder = PreparedRequestBuilder::post(&endpoint_url)
        .map_err(|e| super::shared::ApiError::RequestBuildFailed(e.to_string()))?;

    builder = builder
        .body_json(&args.body)
        .map_err(|e| super::shared::ApiError::RequestBuildFailed(e.to_string()))?;

    if let Some(f) = builder_mod {
        f(&mut builder);
    }

    super::shared::send_json(client.into(), builder.build()).await
}

// -----------------------------------------------------------------------------
// GET /accounts/{account_id}/rum/site_info/list
// -----------------------------------------------------------------------------

/// GET /accounts/{account_id}/rum/site_info/list.
///
/// Takes a client and args, builds the request, optionally applies
/// modifications, then sends it via `send_async().await`.
///
/// # Arguments
///
/// * `client` - HTTP client for making the request: a `DynNetClient`, or an `ApiClient` carrying the `BodyLimits` the response is read under
/// * `args` - Request arguments (path params, query params, body)
/// * `builder_mod` - Optional closure to modify the request builder (e.g., add headers)
///
/// # Example
///
/// ```ignore
/// let response = web_analytics_list_sites_request(client.clone(), &args, Some(|b: &mut PreparedRequestBuilder| {
///     b.header("X-Custom-Header", "value");
/// })).await?;
/// ```
pub async fn web_analytics_list_sites_request<F>(
    client: impl Into<super::shared::ApiClient>,
    args: &WebAnalyticsListSitesArgs,
    base_url: &str,
    builder_mod: Option<F>,
) -> Result<ApiResponse<RumSitesResponseCollection>, super::shared::ApiError>
where
    F: FnOnce(&mut PreparedRequestBuilder),
{
    let path = format!("/accounts/{}/rum/site_info/list", args.account_id,);
    let endpoint_url = format!("{}{}", base_url, path);

    let mut builder = PreparedRequestBuilder::get(&endpoint_url)
        .map_err(|e| super::shared::ApiError::RequestBuildFailed(e.to_string()))?;

    builder = builder.query("per_page", args.per_page.as_deref());
    builder = builder.query("page", args.page.as_deref());
    builder = builder.query("order_by", args.order_by.as_deref());

    if let Some(f) = builder_mod {
        f(&mut builder);
    }

    super::shared::send_json(client.into(), builder.build()).await
}

// -----------------------------------------------------------------------------
// GET /accounts/{account_id}/rum/site_info/{site_id}
// -----------------------------------------------------------------------------

/// GET /accounts/{account_id}/rum/site_info/{site_id}.
///
/// Takes a client and args, builds the request, optionally applies
/// modifications, then sends it via `send_async().await`.
///
/// # Arguments
///
/// * `client` - HTTP client for making the request: a `DynNetClient`, or an `ApiClient` carrying the `BodyLimits` the response is read under
/// * `args` - Request arguments (path params, query params, body)
/// * `builder_mod` - Optional closure to modify the request builder (e.g., add headers)
///
/// # Example
///
/// ```ignore
/// let response = web_analytics_get_site_request(client.clone(), &args, Some(|b: &mut PreparedRequestBuilder| {
///     b.header("X-Custom-Header", "value");
/// })).await?;
/// ```
pub async fn web_analytics_get_site_request<F>(
    client: impl Into<super::shared::ApiClient>,
    args: &WebAnalyticsGetSiteArgs,
    base_url: &str,
    builder_mod: Option<F>,
) -> Result<ApiResponse<RumSiteResponseSingle>, super::shared::ApiError>
where
    F: FnOnce(&mut PreparedRequestBuilder),
{
    let path = format!(
        "/accounts/{}/rum/site_info/{}",
        args.account_id, args.site_id,
    );
    let endpoint_url = format!("{}{}", base_url, path);

    let mut builder = PreparedRequestBuilder::get(&endpoint_url)
        .map_err(|e| super::shared::ApiError::RequestBuildFailed(e.to_string()))?;

    if let Some(f) = builder_mod {
        f(&mut builder);
    }

    super::shared::send_json(client.into(), builder.build()).await
}

// -----------------------------------------------------------------------------
// PUT /accounts/{account_id}/rum/site_info/{site_id}
// -----------------------------------------------------------------------------

/// PUT /accounts/{account_id}/rum/site_info/{site_id}.
///
/// Takes a client and args, builds the request, optionally applies
/// modifications, then sends it via `send_async().await`.
///
/// # Arguments
///
/// * `client` - HTTP client for making the request: a `DynNetClient`, or an `ApiClient` carrying the `BodyLimits` the response is read under
/// * `args` - Request arguments (path params, query params, body)
/// * `builder_mod` - Optional closure to modify the request builder (e.g., add headers)
///
/// # Example
///
/// ```ignore
/// let response = web_analytics_update_site_request(client.clone(), &args, Some(|b: &mut PreparedRequestBuilder| {
///     b.header("X-Custom-Header", "value");
/// })).await?;
/// ```
pub async fn web_analytics_update_site_request<F>(
    client: impl Into<super::shared::ApiClient>,
    args: &WebAnalyticsUpdateSiteArgs,
    base_url: &str,
    builder_mod: Option<F>,
) -> Result<ApiResponse<RumSiteResponseSingle>, super::shared::ApiError>
where
    F: FnOnce(&mut PreparedRequestBuilder),
{
    let path = format!(
        "/accounts/{}/rum/site_info/{}",
        args.account_id, args.site_id,
    );
    let endpoint_url = format!("{}{}", base_url, path);

    let mut builder = PreparedRequestBuilder::put(&endpoint_url)
        .map_err(|e| super::shared::ApiError::RequestBuildFailed(e.to_string()))?;

    builder = builder
        .body_json(&args.body)
        .map_err(|e| super::shared::ApiError::RequestBuildFailed(e.to_string()))?;

    if let Some(f) = builder_mod {
        f(&mut builder);
    }

    super::shared::send_json(client.into(), builder.build()).await
}

// -----------------------------------------------------------------------------
// DELETE /accounts/{account_id}/rum/site_info/{site_id}
// -----------------------------------------------------------------------------

/// DELETE /accounts/{account_id}/rum/site_info/{site_id}.
///
/// Takes a client and args, builds the request, optionally applies
/// modifications, then sends it via `send_async().await`.
///
/// # Arguments
///
/// * `client` - HTTP client for making the request: a `DynNetClient`, or an `ApiClient` carrying the `BodyLimits` the response is read under
/// * `args` - Request arguments (path params, query params, body)
/// * `builder_mod` - Optional closure to modify the request builder (e.g., add headers)
///
/// # Example
///
/// ```ignore
/// let response = web_analytics_delete_site_request(client.clone(), &args, Some(|b: &mut PreparedRequestBuilder| {
///     b.header("X-Custom-Header", "value");
/// })).await?;
/// ```
pub async fn web_analytics_delete_site_request<F>(
    client: impl Into<super::shared::ApiClient>,
    args: &WebAnalyticsDeleteSiteArgs,
    base_url: &str,
    builder_mod: Option<F>,
) -> Result<ApiResponse<RumSiteTagResponseSingle>, super::shared::ApiError>
where
    F: FnOnce(&mut PreparedRequestBuilder),
{
    let path = format!(
        "/accounts/{}/rum/site_info/{}",
        args.account_id, args.site_id,
    );
    let endpoint_url = format!("{}{}", base_url, path);

    let mut builder = PreparedRequestBuilder::delete(&endpoint_url)
        .map_err(|e| super::shared::ApiError::RequestBuildFailed(e.to_string()))?;

    if let Some(f) = builder_mod {
        f(&mut builder);
    }

    super::shared::send_json(client.into(), builder.build()).await
}

// -----------------------------------------------------------------------------
// POST /accounts/{account_id}/rum/v2/{ruleset_id}/rule
// -----------------------------------------------------------------------------

/// POST /accounts/{account_id}/rum/v2/{ruleset_id}/rule.
///
/// Takes a client and args, builds the request, optionally applies
/// modifications, then sends it via `send_async().await`.
///
/// # Arguments
///
/// * `client` - HTTP client for making the request: a `DynNetClient`, or an `ApiClient` carrying the `BodyLimits` the response is read under
/// * `args` - Request arguments (path params, query params, body)
/// * `builder_mod` - Optional closure to modify the request builder (e.g., add headers)
///
/// # Example
///
/// ```ignore
/// let response = web_analytics_create_rule_request(client.clone(), &args, Some(|b: &mut PreparedRequestBuilder| {
///     b.header("X-Custom-Header", "value");
/// })).await?;
/// ```
pub async fn web_analytics_create_rule_request<F>(
    client: impl Into<super::shared::ApiClient>,
    args: &WebAnalyticsCreateRuleArgs,
    base_url: &str,
    builder_mod: Option<F>,
) -> Result<ApiResponse<RumRuleResponseSingle>, super::shared::ApiError>
where
    F: FnOnce(&mut PreparedRequestBuilder),
{
    let path = format!(
        "/accounts/{}/rum/v2/{}/rule",
        args.account_id, args.ruleset_id,
    );
    let endpoint_url = format!("{}{}", base_url, path);

    let mut builder = PreparedRequestBuilder::post(&endpoint_url)
        .map_err(|e| super::shared::ApiError::RequestBuildFailed(e.to_string()))?;

    builder = builder
        .body_json(&args.body)
        .map_err(|e| super::shared::ApiError::RequestBuildFailed(e.to_string()))?;

    if let Some(f) = builder_mod {
        f(&mut builder);
    }

    super::shared::send_json(client.into(), builder.build()).await
}

// -----------------------------------------------------------------------------
// PUT /accounts/{account_id}/rum/v2/{ruleset_id}/rule/{rule_id}
// -----------------------------------------------------------------------------

/// PUT /accounts/{account_id}/rum/v2/{ruleset_id}/rule/{rule_id}.
///
/// Takes a client and args, builds the request, optionally applies
/// modifications, then sends it via `send_async().await`.
///
/// # Arguments
///
/// * `client` - HTTP client for making the request: a `DynNetClient`, or an `ApiClient` carrying the `BodyLimits` the response is read under
/// * `args` - Request arguments (path params, query params, body)
/// * `builder_mod` - Optional closure to modify the request builder (e.g., add headers)
///
/// # Example
///
/// ```ignore
/// let response = web_analytics_update_rule_request(client.clone(), &args, Some(|b: &mut PreparedRequestBuilder| {
///     b.header("X-Custom-Header", "value");
/// })).await?;
/// ```
pub async fn web_analytics_update_rule_request<F>(
    client: impl Into<super::shared::ApiClient>,
    args: &WebAnalyticsUpdateRuleArgs,
    base_url: &str,
    builder_mod: Option<F>,
) -> Result<ApiResponse<RumRuleResponseSingle>, super::shared::ApiError>
where
    F: FnOnce(&mut PreparedRequestBuilder),
{
    let path = format!(
        "/accounts/{}/rum/v2/{}/rule/{}",
        args.account_id, args.ruleset_id, args.rule_id,
    );
    let endpoint_url = format!("{}{}", base_url, path);

    let mut builder = PreparedRequestBuilder::put(&endpoint_url)
        .map_err(|e| super::shared::ApiError::RequestBuildFailed(e.to_string()))?;

    builder = builder
        .body_json(&args.body)
        .map_err(|e| super::shared::ApiError::RequestBuildFailed(e.to_string()))?;

    if let Some(f) = builder_mod {
        f(&mut builder);
    }

    super::shared::send_json(client.into(), builder.build()).await
}

// -----------------------------------------------------------------------------
// DELETE /accounts/{account_id}/rum/v2/{ruleset_id}/rule/{rule_id}
// -----------------------------------------------------------------------------

/// DELETE /accounts/{account_id}/rum/v2/{ruleset_id}/rule/{rule_id}.
///
/// Takes a client and args, builds the request, optionally applies
/// modifications, then sends it via `send_async().await`.
///
/// # Arguments
///
/// * `client` - HTTP client for making the request: a `DynNetClient`, or an `ApiClient` carrying the `BodyLimits` the response is read under
/// * `args` - Request arguments (path params, query params, body)
/// * `builder_mod` - Optional closure to modify the request builder (e.g., add headers)
///
/// # Example
///
/// ```ignore
/// let response = web_analytics_delete_rule_request(client.clone(), &args, Some(|b: &mut PreparedRequestBuilder| {
///     b.header("X-Custom-Header", "value");
/// })).await?;
/// ```
pub async fn web_analytics_delete_rule_request<F>(
    client: impl Into<super::shared::ApiClient>,
    args: &WebAnalyticsDeleteRuleArgs,
    base_url: &str,
    builder_mod: Option<F>,
) -> Result<ApiResponse<RumRuleIdResponseSingle>, super::shared::ApiError>
where
    F: FnOnce(&mut PreparedRequestBuilder),
{
    let path = format!(
        "/accounts/{}/rum/v2/{}/rule/{}",
        args.account_id, args.ruleset_id, args.rule_id,
    );
    let endpoint_url = format!("{}{}", base_url, path);

    let mut builder = PreparedRequestBuilder::delete(&endpoint_url)
        .map_err(|e| super::shared::ApiError::RequestBuildFailed(e.to_string()))?;

    if let Some(f) = builder_mod {
        f(&mut builder);
    }

    super::shared::send_json(client.into(), builder.build()).await
}

// -----------------------------------------------------------------------------
// GET /accounts/{account_id}/rum/v2/{ruleset_id}/rules
// -----------------------------------------------------------------------------

/// GET /accounts/{account_id}/rum/v2/{ruleset_id}/rules.
///
/// Takes a client and args, builds the request, optionally applies
/// modifications, then sends it via `send_async().await`.
///
/// # Arguments
///
/// * `client` - HTTP client for making the request: a `DynNetClient`, or an `ApiClient` carrying the `BodyLimits` the response is read under
/// * `args` - Request arguments (path params, query params, body)
/// * `builder_mod` - Optional closure to modify the request builder (e.g., add headers)
///
/// # Example
///
/// ```ignore
/// let response = web_analytics_list_rules_request(client.clone(), &args, Some(|b: &mut PreparedRequestBuilder| {
///     b.header("X-Custom-Header", "value");
/// })).await?;
/// ```
pub async fn web_analytics_list_rules_request<F>(
    client: impl Into<super::shared::ApiClient>,
    args: &WebAnalyticsListRulesArgs,
    base_url: &str,
    builder_mod: Option<F>,
) -> Result<ApiResponse<RumRulesResponseCollection>, super::shared::ApiError>
where
    F: FnOnce(&mut PreparedRequestBuilder),
{
    let path = format!(
        "/accounts/{}/rum/v2/{}/rules",
        args.account_id, args.ruleset_id,
    );
    let endpoint_url = format!("{}{}", base_url, path);

    let mut builder = PreparedRequestBuilder::get(&endpoint_url)
        .map_err(|e| super::shared::ApiError::RequestBuildFailed(e.to_string()))?;

    if let Some(f) = builder_mod {
        f(&mut builder);
    }

    super::shared::send_json(client.into(), builder.build()).await
}

// -----------------------------------------------------------------------------
// POST /accounts/{account_id}/rum/v2/{ruleset_id}/rules
// -----------------------------------------------------------------------------

/// POST /accounts/{account_id}/rum/v2/{ruleset_id}/rules.
///
/// Takes a client and args, builds the request, optionally applies
/// modifications, then sends it via `send_async().await`.
///
/// # Arguments
///
/// * `client` - HTTP client for making the request: a `DynNetClient`, or an `ApiClient` carrying the `BodyLimits` the response is read under
/// * `args` - Request arguments (path params, query params, body)
/// * `builder_mod` - Optional closure to modify the request builder (e.g., add headers)
///
/// # Example
///
/// ```ignore
/// let response = web_analytics_modify_rules_request(client.clone(), &args, Some(|b: &mut PreparedRequestBuilder| {
///     b.header("X-Custom-Header", "value");
/// })).await?;
/// ```
pub async fn web_analytics_modify_rules_request<F>(
    client: impl Into<super::shared::ApiClient>,
    args: &WebAnalyticsModifyRulesArgs,
    base_url: &str,
    builder_mod: Option<F>,
) -> Result<ApiResponse<RumRulesResponseCollection>, super::shared::ApiError>
where
    F: FnOnce(&mut PreparedRequestBuilder),
{
    let path = format!(
        "/accounts/{}/rum/v2/{}/rules",
        args.account_id, args.ruleset_id,
    );
    let endpoint_url = format!("{}{}", base_url, path);

    let mut builder = PreparedRequestBuilder::post(&endpoint_url)
        .map_err(|e| super::shared::ApiError::RequestBuildFailed(e.to_string()))?;

    builder = builder
        .body_json(&args.body)
        .map_err(|e| super::shared::ApiError::RequestBuildFailed(e.to_string()))?;

    if let Some(f) = builder_mod {
        f(&mut builder);
    }

    super::shared::send_json(client.into(), builder.build()).await
}