// ── SDK v2 — ResourcesClient ─────────────────────────────────────────────────── // // Covers: // POST /v2/resources // GET /v2/resources // GET /v2/resources/:id // PATCH /v2/resources/:id // DELETE /v2/resources/:id import type { Fetcher } from "../http/fetcher"; import type { RequestOptions } from "../http/types"; import type { Resource, ResourceCreate, ResourceUpdate, ListParams, Paginated, } from "../types/index"; export class ResourcesClient { constructor(private readonly fetcher: Fetcher) {} /** * Lists resources with cursor pagination and optional DSL filtering. * * @example * ```ts * const page = await client.resources.list({ q: "agent_id.eq:'agent-abc'" }); * ``` */ list(params?: ListParams, opts?: RequestOptions): Promise> { return this.fetcher.list("/resources", params, opts); } /** * Creates a new resource. * * @example * ```ts * const resource = await client.resources.create({ * team_id: "team-abc", * agent_id: "agent-xyz", * name: "Flight Policy Document", * type: "document", * }); * ``` */ create(data: ResourceCreate, opts?: RequestOptions): Promise { return this.fetcher.post("/resources", data, opts); } /** * Gets a single resource by ID. * * @throws {NotFoundError} when no resource with `id` exists. */ get(id: string, opts?: RequestOptions): Promise { return this.fetcher.get(`/resources/${id}`, undefined, opts); } /** * Partially updates a resource. * * @throws {NotFoundError} when no resource with `id` exists. */ update(id: string, data: ResourceUpdate, opts?: RequestOptions): Promise { return this.fetcher.patch(`/resources/${id}`, data, opts); } /** * Deletes a resource. * * @throws {NotFoundError} when no resource with `id` exists. */ delete(id: string, opts?: RequestOptions): Promise { return this.fetcher.delete(`/resources/${id}`, opts); } }