File size: 3,248 Bytes
1477a90 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | // 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<ListPlansResponse> {
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<Plan> {
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<CreatePlanResponse> {
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<UpdatePlanResponse> {
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<GetPlanResponse> {
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<DeletePlanResponse> {
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<ArchivePlanResponse> {
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<PublishPlanResponse> {
return unwrap(await publishPlan(this._client, request, options))
}
}
|