| 1 | import type * as WAFV2 from "@distilled.cloud/aws/wafv2"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { WebACL } from "./WebACL.ts"; |
| 5 | |
| 6 | export interface GetTopPathStatisticsByTrafficRequest extends Omit< |
| 7 | WAFV2.GetTopPathStatisticsByTrafficRequest, |
| 8 | "WebAclArn" | "Scope" |
| 9 | > {} |
| 10 | |
| 11 | /** |
| 12 | * Runtime binding for `wafv2:GetTopPathStatisticsByTraffic` — read |
| 13 | * aggregated statistics about the URI paths receiving the most bot traffic |
| 14 | * on the bound {@link WebACL}; the web ACL ARN and scope are injected |
| 15 | * automatically. |
| 16 | * |
| 17 | * Requires a pricing plan that includes bot statistics — accounts without |
| 18 | * it receive the typed `WAFFeatureNotIncludedInPricingPlanException`. |
| 19 | * |
| 20 | * Provide `WAFv2.GetTopPathStatisticsByTrafficHttp` on the hosting Lambda |
| 21 | * Function to satisfy the requirement. |
| 22 | * ### Inspecting Traffic |
| 23 | * **Example:** Read Top Bot-Trafficked Paths |
| 24 | * ```typescript |
| 25 | * // init — grants wafv2:GetTopPathStatisticsByTraffic on the web ACL |
| 26 | * const getTopPaths = yield* AWS.WAFv2.GetTopPathStatisticsByTraffic(acl); |
| 27 | * |
| 28 | * // runtime |
| 29 | * const now = yield* Effect.sync(() => new Date()); |
| 30 | * const { PathStatistics } = yield* getTopPaths({ |
| 31 | * TimeWindow: { |
| 32 | * StartTime: new Date(now.getTime() - 60 * 60 * 1000), |
| 33 | * EndTime: now, |
| 34 | * }, |
| 35 | * Limit: 10, |
| 36 | * NumberOfTopTrafficBotsPerPath: 3, |
| 37 | * }); |
| 38 | * ``` |
| 39 | * |
| 40 | * @binding |
| 41 | */ |
| 42 | export interface GetTopPathStatisticsByTraffic extends Binding.Service< |
| 43 | GetTopPathStatisticsByTraffic, |
| 44 | "AWS.WAFv2.GetTopPathStatisticsByTraffic", |
| 45 | ( |
| 46 | webAcl: WebACL, |
| 47 | ) => Effect.Effect< |
| 48 | ( |
| 49 | request: GetTopPathStatisticsByTrafficRequest, |
| 50 | ) => Effect.Effect< |
| 51 | WAFV2.GetTopPathStatisticsByTrafficResponse, |
| 52 | WAFV2.GetTopPathStatisticsByTrafficError |
| 53 | > |
| 54 | > |
| 55 | > {} |
| 56 | |
| 57 | export const GetTopPathStatisticsByTraffic = |
| 58 | Binding.Service<GetTopPathStatisticsByTraffic>( |
| 59 | "AWS.WAFv2.GetTopPathStatisticsByTraffic", |
| 60 | ); |