| 1 | import type * as xray from "@distilled.cloud/aws/xray"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | |
| 5 | export interface GetSamplingRulesRequest extends xray.GetSamplingRulesRequest {} |
| 6 | |
| 7 | /** |
| 8 | * Retrieve all X-Ray sampling rules — the first half of the sampling |
| 9 | * protocol used by custom samplers (poll rules, then report statistics |
| 10 | * via `GetSamplingTargets`). |
| 11 | * |
| 12 | * Bind the operation in the function's init phase to get a runtime callable; |
| 13 | * provide the implementation with `Effect.provide(XRay.GetSamplingRulesHttp)`. |
| 14 | * The action is account-scoped: X-Ray does not support resource-level |
| 15 | * permissions for `xray:GetSamplingRules`, so the binding grants it on `*`. |
| 16 | * ### Sampling |
| 17 | * **Example:** Poll the active sampling rules |
| 18 | * ```typescript |
| 19 | * import * as XRay from "alchemy/AWS/XRay"; |
| 20 | * |
| 21 | * // init — grants xray:GetSamplingRules |
| 22 | * const getSamplingRules = yield* XRay.GetSamplingRules(); |
| 23 | * |
| 24 | * // runtime |
| 25 | * const rules = yield* getSamplingRules(); |
| 26 | * const names = (rules.SamplingRuleRecords ?? []).map( |
| 27 | * (record) => record.SamplingRule?.RuleName, |
| 28 | * ); |
| 29 | * ``` |
| 30 | * |
| 31 | * @binding |
| 32 | */ |
| 33 | export interface GetSamplingRules extends Binding.Service< |
| 34 | GetSamplingRules, |
| 35 | "AWS.XRay.GetSamplingRules", |
| 36 | () => Effect.Effect< |
| 37 | ( |
| 38 | request?: GetSamplingRulesRequest, |
| 39 | ) => Effect.Effect<xray.GetSamplingRulesResult, xray.GetSamplingRulesError> |
| 40 | > |
| 41 | > {} |
| 42 | export const GetSamplingRules = Binding.Service<GetSamplingRules>( |
| 43 | "AWS.XRay.GetSamplingRules", |
| 44 | ); |