Leon4gr45's picture
Upload folder using huggingface_hub (part 2)
1477a90 verified
Raw
History Blame Contribute Delete
12 kB
// 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 { createSubscriptionAddon } from '../funcs/subscriptions.js'
import {
listInvoices,
getInvoice,
updateInvoice,
deleteInvoice,
advanceInvoice,
approveInvoice,
retryInvoice,
snapshotQuantitiesInvoice,
} from '../funcs/invoices.js'
import {
listCurrencies,
createCustomCurrency,
listCostBases,
createCostBasis,
} from '../funcs/currencies.js'
import { queryGovernanceAccess } from '../funcs/governance.js'
import type {
CreateSubscriptionAddonRequest,
CreateSubscriptionAddonResponse,
} from '../models/operations/subscriptions.js'
import type {
ListInvoicesRequest,
ListInvoicesResponse,
GetInvoiceRequest,
GetInvoiceResponse,
UpdateInvoiceRequest,
UpdateInvoiceResponse,
DeleteInvoiceRequest,
DeleteInvoiceResponse,
AdvanceInvoiceRequest,
AdvanceInvoiceResponse,
ApproveInvoiceRequest,
ApproveInvoiceResponse,
RetryInvoiceRequest,
RetryInvoiceResponse,
SnapshotQuantitiesInvoiceRequest,
SnapshotQuantitiesInvoiceResponse,
} from '../models/operations/invoices.js'
import type {
ListCurrenciesRequest,
ListCurrenciesResponse,
CreateCustomCurrencyRequest,
CreateCustomCurrencyResponse,
ListCostBasesRequest,
ListCostBasesResponse,
CreateCostBasisRequest,
CreateCostBasisResponse,
} from '../models/operations/currencies.js'
import type {
QueryGovernanceAccessRequest,
QueryGovernanceAccessResponse,
} from '../models/operations/governance.js'
import type { CostBasis, Currency, Invoice } from '../models/types.js'
/**
* Operations marked internal in the API definition. They are not part of
* the customer surface: they may require additional permissions, and they
* can change or be removed without notice or semver consideration.
*/
export class Internal {
constructor(private readonly _client: Client) {}
private _subscriptions?: InternalSubscriptions
get subscriptions(): InternalSubscriptions {
return (this._subscriptions ??= new InternalSubscriptions(this._client))
}
private _invoices?: InternalInvoices
get invoices(): InternalInvoices {
return (this._invoices ??= new InternalInvoices(this._client))
}
private _currencies?: InternalCurrencies
get currencies(): InternalCurrencies {
return (this._currencies ??= new InternalCurrencies(this._client))
}
private _governance?: InternalGovernance
get governance(): InternalGovernance {
return (this._governance ??= new InternalGovernance(this._client))
}
}
export class InternalSubscriptions {
constructor(private readonly _client: Client) {}
/**
* Create a new subscription add-on
*
* Add add-on to a subscription.
*
* POST /openmeter/subscriptions/{subscriptionId}/addons
*/
async createAddon(
request: CreateSubscriptionAddonRequest,
options?: RequestOptions,
): Promise<CreateSubscriptionAddonResponse> {
return unwrap(await createSubscriptionAddon(this._client, request, options))
}
}
export class InternalInvoices {
constructor(private readonly _client: Client) {}
/**
* List billing invoices
*
* List billing invoices.
*
* Returns a page of invoices. Gathering invoices are never included. Use `filter`
* to narrow by status, customer, dates, or service period start. Use `sort` to
* control ordering.
*
* GET /openmeter/billing/invoices
*/
async list(
request?: ListInvoicesRequest,
options?: RequestOptions,
): Promise<ListInvoicesResponse> {
return unwrap(await listInvoices(this._client, request, options))
}
/**
* List billing invoices
*
* List billing invoices.
*
* Returns a page of invoices. Gathering invoices are never included. Use `filter`
* to narrow by status, customer, dates, or service period start. Use `sort` to
* control ordering.
*
* Iterates every item across all pages, fetching more as the returned iterable is consumed.
*
* GET /openmeter/billing/invoices
*/
listAll(
request?: ListInvoicesRequest,
options?: RequestOptions,
): AsyncIterable<Invoice> {
return paginatePages(
(req, opts) => listInvoices(this._client, req, opts),
request ?? {},
options,
)
}
/**
* Get a billing invoice
*
* Get a billing invoice by ID.
*
* Returns the full invoice resource including line items, status details, totals,
* and workflow configuration snapshot.
*
* GET /openmeter/billing/invoices/{invoiceId}
*/
async get(
request: GetInvoiceRequest,
options?: RequestOptions,
): Promise<GetInvoiceResponse> {
return unwrap(await getInvoice(this._client, request, options))
}
/**
* Update a billing invoice
*
* Update a billing invoice.
*
* Only the mutable fields of the invoice can be edited: description, labels,
* supplier, customer, workflow settings, and top-level lines. Top-level lines are
* matched by `id`; lines without an `id` are created, and existing lines omitted
* from `lines` are deleted. Detailed (child) lines are always computed and cannot
* be edited directly. Only invoices in draft status can be updated.
*
* PUT /openmeter/billing/invoices/{invoiceId}
*/
async update(
request: UpdateInvoiceRequest,
options?: RequestOptions,
): Promise<UpdateInvoiceResponse> {
return unwrap(await updateInvoice(this._client, request, options))
}
/**
* Delete a billing invoice
*
* Delete a billing invoice.
*
* Only standard invoices in draft status can be deleted. Deleting an invoice will
* also delete all associated line items and workflow configuration.
*
* DELETE /openmeter/billing/invoices/{invoiceId}
*/
async delete(
request: DeleteInvoiceRequest,
options?: RequestOptions,
): Promise<DeleteInvoiceResponse> {
return unwrap(await deleteInvoice(this._client, request, options))
}
/**
* Advance billing invoice's next status
*
* Advance a billing invoice.
*
* Advances the invoice to the next workflow state. The next state is determined by
* the invoice's current status and workflow configuration. Only invoices in draft
* or issued status can be advanced.
*
* POST /openmeter/billing/invoices/{invoiceId}/advance
*/
async advance(
request: AdvanceInvoiceRequest,
options?: RequestOptions,
): Promise<AdvanceInvoiceResponse> {
return unwrap(await advanceInvoice(this._client, request, options))
}
/**
* Send the invoice to the customer
*
* Approve a billing invoice.
*
* This call instantly sends the invoice to the customer using the configured
* billing profile app.
*
* This call is valid in two invoice statuses:
*
* - draft: the invoice will be sent to the customer, the invoice state becomes
* issued
* - manual_approval_needed: the invoice will be sent to the customer, the invoice
* state becomes issued
*
* POST /openmeter/billing/invoices/{invoiceId}/approve
*/
async approve(
request: ApproveInvoiceRequest,
options?: RequestOptions,
): Promise<ApproveInvoiceResponse> {
return unwrap(await approveInvoice(this._client, request, options))
}
/**
* Retry advancing the invoice after a failed attempt
*
* Retry sending a billing invoice.
*
* Retry advancing the invoice after a failed attempt.
*
* The action can be called when the invoice's statusDetails' actions field contain
* the "retry" action.
*
* POST /openmeter/billing/invoices/{invoiceId}/retry
*/
async retry(
request: RetryInvoiceRequest,
options?: RequestOptions,
): Promise<RetryInvoiceResponse> {
return unwrap(await retryInvoice(this._client, request, options))
}
/**
* Snapshot quantities for usage based line items
*
* Snapshot quantities for usage-based line items.
*
* This call will snapshot the quantities for all usage based line items in the
* invoice.
*
* This call is only valid in draft.waiting_for_collection status, where the
* collection period can be skipped using this action.
*
* POST /openmeter/billing/invoices/{invoiceId}/snapshot-quantities
*/
async snapshotQuantities(
request: SnapshotQuantitiesInvoiceRequest,
options?: RequestOptions,
): Promise<SnapshotQuantitiesInvoiceResponse> {
return unwrap(
await snapshotQuantitiesInvoice(this._client, request, options),
)
}
}
export class InternalCurrencies {
constructor(private readonly _client: Client) {}
/**
* List currencies
*
* List currencies supported by the billing system.
*
* GET /openmeter/currencies
*/
async list(
request?: ListCurrenciesRequest,
options?: RequestOptions,
): Promise<ListCurrenciesResponse> {
return unwrap(await listCurrencies(this._client, request, options))
}
/**
* List currencies
*
* List currencies supported by the billing system.
*
* Iterates every item across all pages, fetching more as the returned iterable is consumed.
*
* GET /openmeter/currencies
*/
listAll(
request?: ListCurrenciesRequest,
options?: RequestOptions,
): AsyncIterable<Currency> {
return paginatePages(
(req, opts) => listCurrencies(this._client, req, opts),
request ?? {},
options,
)
}
/**
* Create custom currency
*
* Create a custom currency. This operation allows defining your own custom
* currency for billing purposes.
*
* POST /openmeter/currencies/custom
*/
async createCustomCurrency(
request: CreateCustomCurrencyRequest,
options?: RequestOptions,
): Promise<CreateCustomCurrencyResponse> {
return unwrap(await createCustomCurrency(this._client, request, options))
}
/**
* List cost bases
*
* List cost bases for a currency. For custom currencies, there can be multiple
* cost bases with different `effective_from` dates.
*
* GET /openmeter/currencies/custom/{currencyId}/cost-bases
*/
async listCostBases(
request: ListCostBasesRequest,
options?: RequestOptions,
): Promise<ListCostBasesResponse> {
return unwrap(await listCostBases(this._client, request, options))
}
/**
* List cost bases
*
* List cost bases for a currency. For custom currencies, there can be multiple
* cost bases with different `effective_from` dates.
*
* Iterates every item across all pages, fetching more as the returned iterable is consumed.
*
* GET /openmeter/currencies/custom/{currencyId}/cost-bases
*/
listCostBasesAll(
request: ListCostBasesRequest,
options?: RequestOptions,
): AsyncIterable<CostBasis> {
return paginatePages(
(req, opts) => listCostBases(this._client, req, opts),
request,
options,
)
}
/**
* Create cost basis
*
* Create a cost basis for a currency.
*
* POST /openmeter/currencies/custom/{currencyId}/cost-bases
*/
async createCostBasis(
request: CreateCostBasisRequest,
options?: RequestOptions,
): Promise<CreateCostBasisResponse> {
return unwrap(await createCostBasis(this._client, request, options))
}
}
export class InternalGovernance {
constructor(private readonly _client: Client) {}
/**
* Query governance access
*
* Query feature access for a list of customers.
*
* The endpoint resolves each provided identifier to a customer and returns the
* access status for the requested features, plus optional credit balance
* availability.
*
* _Designed to be called on a fixed refresh interval and the query response is
* intended to be cached._
*
* POST /openmeter/governance/query
*/
async queryAccess(
request: QueryGovernanceAccessRequest,
options?: RequestOptions,
): Promise<QueryGovernanceAccessResponse> {
return unwrap(await queryGovernanceAccess(this._client, request, options))
}
}