sailfork / t3code-github / .repos/ alchemy-effect/ packages/ aws/ src/ XRay/ GetSamplingRules.ts

import type * as xray from "@distilled.cloud/aws/xray";
import * as Binding from "alchemy/Binding";
import type * as Effect from "effect/Effect";

export interface GetSamplingRulesRequest extends xray.GetSamplingRulesRequest {}

/**
 * Retrieve all X-Ray sampling rules — the first half of the sampling
 * protocol used by custom samplers (poll rules, then report statistics
 * via `GetSamplingTargets`).
 *
 * Bind the operation in the function's init phase to get a runtime callable;
 * provide the implementation with `Effect.provide(XRay.GetSamplingRulesHttp)`.
 * The action is account-scoped: X-Ray does not support resource-level
 * permissions for `xray:GetSamplingRules`, so the binding grants it on `*`.
 * ### Sampling
 * **Example:** Poll the active sampling rules
 * ```typescript
 * import * as XRay from "@alchemy.run/aws/XRay";
 *
 * // init — grants xray:GetSamplingRules
 * const getSamplingRules = yield* XRay.GetSamplingRules();
 *
 * // runtime
 * const rules = yield* getSamplingRules();
 * const names = (rules.SamplingRuleRecords ?? []).map(
 *   (record) => record.SamplingRule?.RuleName,
 * );
 * ```
 *
 * @binding
 */
export interface GetSamplingRules extends Binding.Service<
  GetSamplingRules,
  "AWS.XRay.GetSamplingRules",
  () => Effect.Effect<
    (
      request?: GetSamplingRulesRequest,
    ) => Effect.Effect<xray.GetSamplingRulesResult, xray.GetSamplingRulesError>
  >
> {}
export const GetSamplingRules = Binding.Service<GetSamplingRules>("AWS.XRay.GetSamplingRules");