// Code generated by @openmeter/typespec-typescript. DO NOT EDIT. import { type Client } from '../core.js' import { unwrap, type RequestOptions } from '../lib/types.js' import { paginatePages } from '../lib/paginate.js' import { listPlans, createPlan, updatePlan, getPlan, deletePlan, archivePlan, publishPlan, } from '../funcs/plans.js' import type { ListPlansRequest, ListPlansResponse, CreatePlanRequest, CreatePlanResponse, UpdatePlanRequest, UpdatePlanResponse, GetPlanRequest, GetPlanResponse, DeletePlanRequest, DeletePlanResponse, ArchivePlanRequest, ArchivePlanResponse, PublishPlanRequest, PublishPlanResponse, } from '../models/operations/plans.js' import type { Plan } from '../models/types.js' export class Plans { constructor(private readonly _client: Client) {} /** * List plans * * List all plans. * * GET /openmeter/plans */ async list( request?: ListPlansRequest, options?: RequestOptions, ): Promise { return unwrap(await listPlans(this._client, request, options)) } /** * List plans * * List all plans. * * Iterates every item across all pages, fetching more as the returned iterable is consumed. * * GET /openmeter/plans */ listAll( request?: ListPlansRequest, options?: RequestOptions, ): AsyncIterable { return paginatePages( (req, opts) => listPlans(this._client, req, opts), request ?? {}, options, ) } /** * Create plan * * Create a new plan. * * POST /openmeter/plans */ async create( request: CreatePlanRequest, options?: RequestOptions, ): Promise { return unwrap(await createPlan(this._client, request, options)) } /** * Update plan * * Update a plan by id. * * PUT /openmeter/plans/{planId} */ async update( request: UpdatePlanRequest, options?: RequestOptions, ): Promise { return unwrap(await updatePlan(this._client, request, options)) } /** * Get plan * * Get a plan by id. * * GET /openmeter/plans/{planId} */ async get( request: GetPlanRequest, options?: RequestOptions, ): Promise { return unwrap(await getPlan(this._client, request, options)) } /** * Delete plan * * Delete a plan by id. * * DELETE /openmeter/plans/{planId} */ async delete( request: DeletePlanRequest, options?: RequestOptions, ): Promise { return unwrap(await deletePlan(this._client, request, options)) } /** * Archive plan version * * Archive a plan version. * * POST /openmeter/plans/{planId}/archive */ async archive( request: ArchivePlanRequest, options?: RequestOptions, ): Promise { return unwrap(await archivePlan(this._client, request, options)) } /** * Publish plan version * * Publish a plan version. * * POST /openmeter/plans/{planId}/publish */ async publish( request: PublishPlanRequest, options?: RequestOptions, ): Promise { return unwrap(await publishPlan(this._client, request, options)) } }