Skip to content

Commit

Permalink
fix: rename node client arguments (#1186)
Browse files Browse the repository at this point in the history
  • Loading branch information
GAlexIHU authored Jul 12, 2024
1 parent cf47f73 commit 024b40c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 35 deletions.
18 changes: 6 additions & 12 deletions api/client/node/clients/feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,14 @@ export class FeatureClient extends BaseClient {
}

/**
* Get Feature by ID or Key
* Get Feature
*
* @example
* const feature = await openmeter.features.get('ai_tokens')
*/
public async get(
idOrKey: string,
options?: RequestOptions
): Promise<Feature> {
public async get(id: string, options?: RequestOptions): Promise<Feature> {
return await this.request({
path: `/api/v1/features/${idOrKey}`,
path: `/api/v1/features/${id}`,
method: 'GET',
options,
})
Expand All @@ -79,18 +76,15 @@ export class FeatureClient extends BaseClient {
}

/**
* Archive a feature by ID or Key.
* Archive a feature
* @description
* Once a feature is archived it cannot be unarchived. If a feature is archived, new entitlements cannot be created for it, but archiving the feature does not affect existing entitlements.
* @example
* await openmeter.delete('ai_tokens')
*/
public async delete(
idOrKey: string,
options?: RequestOptions
): Promise<void> {
public async delete(id: string, options?: RequestOptions): Promise<void> {
return await this.request({
path: `/api/v1/features/${idOrKey}`,
path: `/api/v1/features/${id}`,
method: 'DELETE',
options,
})
Expand Down
46 changes: 23 additions & 23 deletions api/client/node/clients/subject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,42 +140,42 @@ export class SubjectClient extends BaseClient {
}

/**
* Get entitlement by ID by Feature ID or by Feature Key
* Get entitlement
*
* @example
* const entitlement = await openmeter.subjects.getEntitlement('customer-1', 'ai_tokens')
* const entitlement = await openmeter.subjects.getEntitlement('customer-1', '01J1SD3QDV86GP77TQ4PZZ4EXE')
*/
public async getEntitlement(
subjectIdOrKey: string,
entitlementIdOrFeatureIdOrFeatureKey: string,
entitlementId: string,
options?: RequestOptions
): Promise<Entitlement> {
return await this.request({
path: `/api/v1/subjects/${subjectIdOrKey}/entitlements/${entitlementIdOrFeatureIdOrFeatureKey}`,
path: `/api/v1/subjects/${subjectIdOrKey}/entitlements/${entitlementId}`,
method: 'GET',
options,
})
}

/**
* Delete entitlement by ID by Feature ID or by Feature Key
* Delete entitlement
* @example
* await openmeter.deleteEntitlement('customer-1', 'ai_tokens')
* await openmeter.deleteEntitlement('customer-1', '01J1SD3QDV86GP77TQ4PZZ4EXE')
*/
public async deleteEntitlement(
subjectIdOrKey: string,
entitlementIdOrFeatureIdOrFeatureKey: string,
entitlementId: string,
options?: RequestOptions
): Promise<void> {
return await this.request({
path: `/api/v1/subjects/${subjectIdOrKey}/entitlements/${entitlementIdOrFeatureIdOrFeatureKey}`,
path: `/api/v1/subjects/${subjectIdOrKey}/entitlements/${entitlementId}`,
method: 'DELETE',
options,
})
}

/**
* Get entitlement value by ID by Feature Key
* Get entitlement value by ID or Feature Key
*
* @example
* const value = await openmeter.subjects.getEntitlementValue('customer-1', 'ai_tokens')
Expand All @@ -196,7 +196,7 @@ export class SubjectClient extends BaseClient {
* Get entitlement value at a specific time.
*
* @example
* const value = await openmeter.subjects.getEntitlementValueAt('customer-1', 'ai_tokens')
* const value = await openmeter.subjects.getEntitlementValueAt('customer-1', 'ai_tokens', new Date('2024-01-01'))
*/
public async getEntitlementValueAt(
subjectIdOrKey: string,
Expand All @@ -214,21 +214,21 @@ export class SubjectClient extends BaseClient {
}

/**
* Get entitlement history by ID by Feature ID or by Feature Key
* Get entitlement history
* @example
* const entitlement = await openmeter.subjects.getEntitlementHistory('customer-1', 'ai_tokens')
* const entitlement = await openmeter.subjects.getEntitlementHistory('customer-1', '01J1SD3QDV86GP77TQ4PZZ4EXE')
*/
public async getEntitlementHistory(
subjectIdOrKey: string,
entitlementIdOrFeatureIdOrFeatureKey: string,
entitlementId: string,
params?: GetEntitlementHistoryQueryParams,
options?: RequestOptions
): Promise<WindowedBalanceHistory[]> {
const searchParams = params
? BaseClient.toURLSearchParams(params)
: undefined
return await this.request({
path: `/api/v1/subjects/${subjectIdOrKey}/entitlements/${entitlementIdOrFeatureIdOrFeatureKey}/history`,
path: `/api/v1/subjects/${subjectIdOrKey}/entitlements/${entitlementId}/history`,
method: 'GET',
searchParams,
options,
Expand All @@ -240,18 +240,18 @@ export class SubjectClient extends BaseClient {
* Reset the entitlement usage and start a new period. Eligible grants will be rolled over
*
* @example
* const entitlement = await openmeter.subjects.resetEntitlementUsage('customer-1', 'ai_tokens', {
* const entitlement = await openmeter.subjects.resetEntitlementUsage('customer-1', '01J1SD3QDV86GP77TQ4PZZ4EXE', {
* retainAnchor: true
* })
*/
public async resetEntitlementUsage(
subjectIdOrKey: string,
entitlementIdOrFeatureIdOrFeatureKey: string,
entitlementId: string,
input: EntitlementResetInputs,
options?: RequestOptions
): Promise<Entitlement> {
return await this.request({
path: `/api/v1/subjects/${subjectIdOrKey}/entitlements/${entitlementIdOrFeatureIdOrFeatureKey}/reset`,
path: `/api/v1/subjects/${subjectIdOrKey}/entitlements/${entitlementId}/reset`,
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand All @@ -268,7 +268,7 @@ export class SubjectClient extends BaseClient {
* Create a grant for an entitlement.
*
* @example
* const grant = await openmeter.subjects.createEntitlementGrant('customer-1', 'ai_tokens', {
* const grant = await openmeter.subjects.createEntitlementGrant('customer-1', '01J1SD3QDV86GP77TQ4PZZ4EXE', {
* amount: 100,
* priority: 1,
* effectiveAt: '2023-01-01T00:00:00Z',
Expand All @@ -286,12 +286,12 @@ export class SubjectClient extends BaseClient {
*/
public async createEntitlementGrant(
subjectIdOrKey: string,
entitlementIdOrFeatureIdOrFeatureKey: string,
entitlementId: string,
input: EntitlementGrantCreateInput,
options?: RequestOptions
): Promise<EntitlementGrant> {
return await this.request({
path: `/api/v1/subjects/${subjectIdOrKey}/entitlements/${entitlementIdOrFeatureIdOrFeatureKey}/grants`,
path: `/api/v1/subjects/${subjectIdOrKey}/entitlements/${entitlementId}/grants`,
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand All @@ -304,19 +304,19 @@ export class SubjectClient extends BaseClient {
/**
* List entitlement grants
* @example
* const entitlement = await openmeter.subjects.listEntitlementGrants('customer-1', 'ai_tokens)
* const entitlement = await openmeter.subjects.listEntitlementGrants('customer-1', '01J1SD3QDV86GP77TQ4PZZ4EXE')
*/
public async listEntitlementGrants(
subjectIdOrKey: string,
entitlementIdOrFeatureIdOrFeatureKey: string,
entitlementId: string,
params?: ListEntitlementGrantQueryParams,
options?: RequestOptions
): Promise<EntitlementGrant[]> {
const searchParams = params
? BaseClient.toURLSearchParams(params)
: undefined
return await this.request({
path: `/api/v1/subjects/${subjectIdOrKey}/entitlements/${entitlementIdOrFeatureIdOrFeatureKey}/grants`,
path: `/api/v1/subjects/${subjectIdOrKey}/entitlements/${entitlementId}/grants`,
method: 'GET',
searchParams,
options,
Expand Down

0 comments on commit 024b40c

Please sign in to comment.