Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): update via SDK Studio #20

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 14 additions & 16 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ Types:

Methods:

- <code title="get /plans">client.plans.<a href="./src/resources/plans.ts">list</a>({ ...params }) -> PlanListResponse</code>
- <code title="get /plans">client.plans.<a href="./src/resources/plans.ts">list</a>({ ...params }) -> PlanListResponsesCursorPage</code>
- <code title="get /planDetails/{plan_id}">client.plans.<a href="./src/resources/plans.ts">getDetails</a>(planId) -> PlanGetDetailsResponse</code>
- <code title="get /planDetails/{plan_id}/charges">client.plans.<a href="./src/resources/plans.ts">listCharges</a>(planId, { ...params }) -> PlanListChargesResponse</code>
- <code title="get /planDetails/{plan_id}/customers">client.plans.<a href="./src/resources/plans.ts">listCustomers</a>(planId, { ...params }) -> PlanListCustomersResponse</code>
- <code title="get /planDetails/{plan_id}/charges">client.plans.<a href="./src/resources/plans.ts">listCharges</a>(planId, { ...params }) -> PlanListChargesResponsesCursorPage</code>
- <code title="get /planDetails/{plan_id}/customers">client.plans.<a href="./src/resources/plans.ts">listCustomers</a>(planId, { ...params }) -> PlanListCustomersResponsesCursorPage</code>

# CreditGrants

Expand All @@ -58,9 +58,9 @@ Types:
Methods:

- <code title="post /credits/createGrant">client.creditGrants.<a href="./src/resources/credit-grants.ts">create</a>({ ...params }) -> CreditGrantCreateResponse</code>
- <code title="post /credits/listGrants">client.creditGrants.<a href="./src/resources/credit-grants.ts">list</a>({ ...params }) -> CreditGrantListResponse</code>
- <code title="post /credits/listGrants">client.creditGrants.<a href="./src/resources/credit-grants.ts">list</a>({ ...params }) -> CreditGrantListResponsesCursorPage</code>
- <code title="post /credits/editGrant">client.creditGrants.<a href="./src/resources/credit-grants.ts">edit</a>({ ...params }) -> CreditGrantEditResponse</code>
- <code title="get /credit-types/list">client.creditGrants.<a href="./src/resources/credit-grants.ts">listCreditTypes</a>({ ...params }) -> CreditGrantListCreditTypesResponse</code>
- <code title="get /credit-types/list">client.creditGrants.<a href="./src/resources/credit-grants.ts">listCreditTypes</a>({ ...params }) -> CreditGrantListCreditTypesResponsesCursorPage</code>
- <code title="post /credits/listEntries">client.creditGrants.<a href="./src/resources/credit-grants.ts">listEntries</a>({ ...params }) -> CreditGrantListEntriesResponse</code>
- <code title="post /credits/voidGrant">client.creditGrants.<a href="./src/resources/credit-grants.ts">void</a>({ ...params }) -> CreditGrantVoidResponse</code>

Expand All @@ -72,7 +72,6 @@ Types:
- <code><a href="./src/resources/customers/customers.ts">CustomerDetail</a></code>
- <code><a href="./src/resources/customers/customers.ts">CustomerCreateResponse</a></code>
- <code><a href="./src/resources/customers/customers.ts">CustomerRetrieveResponse</a></code>
- <code><a href="./src/resources/customers/customers.ts">CustomerListResponse</a></code>
- <code><a href="./src/resources/customers/customers.ts">CustomerArchiveResponse</a></code>
- <code><a href="./src/resources/customers/customers.ts">CustomerListBillableMetricsResponse</a></code>
- <code><a href="./src/resources/customers/customers.ts">CustomerListCostsResponse</a></code>
Expand All @@ -82,10 +81,10 @@ Methods:

- <code title="post /customers">client.customers.<a href="./src/resources/customers/customers.ts">create</a>({ ...params }) -> CustomerCreateResponse</code>
- <code title="get /customers/{customer_id}">client.customers.<a href="./src/resources/customers/customers.ts">retrieve</a>(customerId) -> CustomerRetrieveResponse</code>
- <code title="get /customers">client.customers.<a href="./src/resources/customers/customers.ts">list</a>({ ...params }) -> CustomerListResponse</code>
- <code title="get /customers">client.customers.<a href="./src/resources/customers/customers.ts">list</a>({ ...params }) -> CustomerDetailsCursorPage</code>
- <code title="post /customers/archive">client.customers.<a href="./src/resources/customers/customers.ts">archive</a>({ ...params }) -> CustomerArchiveResponse</code>
- <code title="get /customers/{customer_id}/billable-metrics">client.customers.<a href="./src/resources/customers/customers.ts">listBillableMetrics</a>(customerId, { ...params }) -> CustomerListBillableMetricsResponse</code>
- <code title="get /customers/{customer_id}/costs">client.customers.<a href="./src/resources/customers/customers.ts">listCosts</a>(customerId, { ...params }) -> CustomerListCostsResponse</code>
- <code title="get /customers/{customer_id}/billable-metrics">client.customers.<a href="./src/resources/customers/customers.ts">listBillableMetrics</a>(customerId, { ...params }) -> CustomerListBillableMetricsResponsesCursorPage</code>
- <code title="get /customers/{customer_id}/costs">client.customers.<a href="./src/resources/customers/customers.ts">listCosts</a>(customerId, { ...params }) -> CustomerListCostsResponsesCursorPage</code>
- <code title="post /customers/{customer_id}/setIngestAliases">client.customers.<a href="./src/resources/customers/customers.ts">setIngestAliases</a>(customerId, { ...params }) -> void</code>
- <code title="post /customers/{customer_id}/setName">client.customers.<a href="./src/resources/customers/customers.ts">setName</a>(customerId, { ...params }) -> CustomerSetNameResponse</code>
- <code title="post /customers/{customer_id}/updateConfig">client.customers.<a href="./src/resources/customers/customers.ts">updateConfig</a>(customerId, { ...params }) -> void</code>
Expand Down Expand Up @@ -115,24 +114,23 @@ Types:

Methods:

- <code title="get /customers/{customer_id}/plans">client.customers.plans.<a href="./src/resources/customers/plans.ts">list</a>(customerId, { ...params }) -> PlanListResponse</code>
- <code title="get /customers/{customer_id}/plans">client.customers.plans.<a href="./src/resources/customers/plans.ts">list</a>(customerId, { ...params }) -> PlanListResponsesCursorPage</code>
- <code title="post /customers/{customer_id}/plans/add">client.customers.plans.<a href="./src/resources/customers/plans.ts">add</a>(customerId, { ...params }) -> PlanAddResponse</code>
- <code title="post /customers/{customer_id}/plans/{customer_plan_id}/end">client.customers.plans.<a href="./src/resources/customers/plans.ts">end</a>(customerId, customerPlanId, { ...params }) -> PlanEndResponse</code>
- <code title="get /customers/{customer_id}/plans/{customer_plan_id}/priceAdjustments">client.customers.plans.<a href="./src/resources/customers/plans.ts">listPriceAdjustments</a>(customerId, customerPlanId, { ...params }) -> PlanListPriceAdjustmentsResponse</code>
- <code title="get /customers/{customer_id}/plans/{customer_plan_id}/priceAdjustments">client.customers.plans.<a href="./src/resources/customers/plans.ts">listPriceAdjustments</a>(customerId, customerPlanId, { ...params }) -> PlanListPriceAdjustmentsResponsesCursorPage</code>

## Invoices

Types:

- <code><a href="./src/resources/customers/invoices.ts">Invoice</a></code>
- <code><a href="./src/resources/customers/invoices.ts">InvoiceRetrieveResponse</a></code>
- <code><a href="./src/resources/customers/invoices.ts">InvoiceListResponse</a></code>
- <code><a href="./src/resources/customers/invoices.ts">InvoiceAddChargeResponse</a></code>

Methods:

- <code title="get /customers/{customer_id}/invoices/{invoice_id}">client.customers.invoices.<a href="./src/resources/customers/invoices.ts">retrieve</a>(customerId, invoiceId, { ...params }) -> InvoiceRetrieveResponse</code>
- <code title="get /customers/{customer_id}/invoices">client.customers.invoices.<a href="./src/resources/customers/invoices.ts">list</a>(customerId, { ...params }) -> InvoiceListResponse</code>
- <code title="get /customers/{customer_id}/invoices">client.customers.invoices.<a href="./src/resources/customers/invoices.ts">list</a>(customerId, { ...params }) -> InvoicesCursorPage</code>
- <code title="post /customers/{customer_id}/addCharge">client.customers.invoices.<a href="./src/resources/customers/invoices.ts">addCharge</a>(customerId, { ...params }) -> InvoiceAddChargeResponse</code>

## BillingConfig
Expand Down Expand Up @@ -168,7 +166,7 @@ Methods:

- <code title="post /usage">client.usage.<a href="./src/resources/usage.ts">list</a>({ ...params }) -> UsageListResponse</code>
- <code title="post /ingest">client.usage.<a href="./src/resources/usage.ts">ingest</a>([ ...usage ]) -> void</code>
- <code title="post /usage/groups">client.usage.<a href="./src/resources/usage.ts">listWithGroups</a>({ ...params }) -> UsageListWithGroupsResponse</code>
- <code title="post /usage/groups">client.usage.<a href="./src/resources/usage.ts">listWithGroups</a>({ ...params }) -> UsageListWithGroupsResponsesCursorPage</code>

# AuditLogs

Expand All @@ -178,7 +176,7 @@ Types:

Methods:

- <code title="get /auditLogs">client.auditLogs.<a href="./src/resources/audit-logs.ts">list</a>({ ...params }) -> AuditLogListResponse</code>
- <code title="get /auditLogs">client.auditLogs.<a href="./src/resources/audit-logs.ts">list</a>({ ...params }) -> AuditLogListResponsesCursorPage</code>

# CustomFields

Expand Down Expand Up @@ -207,7 +205,7 @@ Methods:

- <code title="post /billable-metrics/create">client.billableMetrics.<a href="./src/resources/billable-metrics.ts">create</a>({ ...params }) -> BillableMetricCreateResponse</code>
- <code title="get /billable-metrics/{billable_metric_id}">client.billableMetrics.<a href="./src/resources/billable-metrics.ts">retrieve</a>(billableMetricId) -> BillableMetricRetrieveResponse</code>
- <code title="get /customers/{customer_id}/billable-metrics">client.billableMetrics.<a href="./src/resources/billable-metrics.ts">list</a>(customerId, { ...params }) -> BillableMetricListResponse</code>
- <code title="get /customers/{customer_id}/billable-metrics">client.billableMetrics.<a href="./src/resources/billable-metrics.ts">list</a>(customerId, { ...params }) -> BillableMetricListResponsesCursorPage</code>
- <code title="post /billable-metrics/archive">client.billableMetrics.<a href="./src/resources/billable-metrics.ts">archive</a>({ ...params }) -> BillableMetricArchiveResponse</code>

# Services
Expand Down
17 changes: 16 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as Errors from './error';
import { type Agent } from './_shims/index';
import * as Uploads from './uploads';
import * as qs from 'qs';
import * as Pagination from '@metronome/sdk/pagination';
import * as API from '@metronome/sdk/resources/index';

export interface ClientOptions {
Expand Down Expand Up @@ -199,6 +200,10 @@ export import fileFromPath = Uploads.fileFromPath;
export namespace Metronome {
export import RequestOptions = Core.RequestOptions;

export import CursorPage = Pagination.CursorPage;
export import CursorPageParams = Pagination.CursorPageParams;
export import CursorPageResponse = Pagination.CursorPageResponse;

export import Alerts = API.Alerts;
export import AlertCreateResponse = API.AlertCreateResponse;
export import AlertArchiveResponse = API.AlertArchiveResponse;
Expand All @@ -211,6 +216,9 @@ export namespace Metronome {
export import PlanGetDetailsResponse = API.PlanGetDetailsResponse;
export import PlanListChargesResponse = API.PlanListChargesResponse;
export import PlanListCustomersResponse = API.PlanListCustomersResponse;
export import PlanListResponsesCursorPage = API.PlanListResponsesCursorPage;
export import PlanListChargesResponsesCursorPage = API.PlanListChargesResponsesCursorPage;
export import PlanListCustomersResponsesCursorPage = API.PlanListCustomersResponsesCursorPage;
export import PlanListParams = API.PlanListParams;
export import PlanListChargesParams = API.PlanListChargesParams;
export import PlanListCustomersParams = API.PlanListCustomersParams;
Expand All @@ -225,6 +233,8 @@ export namespace Metronome {
export import CreditGrantListCreditTypesResponse = API.CreditGrantListCreditTypesResponse;
export import CreditGrantListEntriesResponse = API.CreditGrantListEntriesResponse;
export import CreditGrantVoidResponse = API.CreditGrantVoidResponse;
export import CreditGrantListResponsesCursorPage = API.CreditGrantListResponsesCursorPage;
export import CreditGrantListCreditTypesResponsesCursorPage = API.CreditGrantListCreditTypesResponsesCursorPage;
export import CreditGrantCreateParams = API.CreditGrantCreateParams;
export import CreditGrantListParams = API.CreditGrantListParams;
export import CreditGrantEditParams = API.CreditGrantEditParams;
Expand All @@ -237,11 +247,13 @@ export namespace Metronome {
export import CustomerDetail = API.CustomerDetail;
export import CustomerCreateResponse = API.CustomerCreateResponse;
export import CustomerRetrieveResponse = API.CustomerRetrieveResponse;
export import CustomerListResponse = API.CustomerListResponse;
export import CustomerArchiveResponse = API.CustomerArchiveResponse;
export import CustomerListBillableMetricsResponse = API.CustomerListBillableMetricsResponse;
export import CustomerListCostsResponse = API.CustomerListCostsResponse;
export import CustomerSetNameResponse = API.CustomerSetNameResponse;
export import CustomerDetailsCursorPage = API.CustomerDetailsCursorPage;
export import CustomerListBillableMetricsResponsesCursorPage = API.CustomerListBillableMetricsResponsesCursorPage;
export import CustomerListCostsResponsesCursorPage = API.CustomerListCostsResponsesCursorPage;
export import CustomerCreateParams = API.CustomerCreateParams;
export import CustomerListParams = API.CustomerListParams;
export import CustomerArchiveParams = API.CustomerArchiveParams;
Expand All @@ -258,12 +270,14 @@ export namespace Metronome {
export import Usage = API.Usage;
export import UsageListResponse = API.UsageListResponse;
export import UsageListWithGroupsResponse = API.UsageListWithGroupsResponse;
export import UsageListWithGroupsResponsesCursorPage = API.UsageListWithGroupsResponsesCursorPage;
export import UsageListParams = API.UsageListParams;
export import UsageIngestParams = API.UsageIngestParams;
export import UsageListWithGroupsParams = API.UsageListWithGroupsParams;

export import AuditLogs = API.AuditLogs;
export import AuditLogListResponse = API.AuditLogListResponse;
export import AuditLogListResponsesCursorPage = API.AuditLogListResponsesCursorPage;
export import AuditLogListParams = API.AuditLogListParams;

export import CustomFields = API.CustomFields;
Expand All @@ -279,6 +293,7 @@ export namespace Metronome {
export import BillableMetricRetrieveResponse = API.BillableMetricRetrieveResponse;
export import BillableMetricListResponse = API.BillableMetricListResponse;
export import BillableMetricArchiveResponse = API.BillableMetricArchiveResponse;
export import BillableMetricListResponsesCursorPage = API.BillableMetricListResponsesCursorPage;
export import BillableMetricCreateParams = API.BillableMetricCreateParams;
export import BillableMetricListParams = API.BillableMetricListParams;
export import BillableMetricArchiveParams = API.BillableMetricArchiveParams;
Expand Down
78 changes: 78 additions & 0 deletions src/pagination.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { AbstractPage, Response, APIClient, FinalRequestOptions, PageInfo } from './core';

export interface CursorPageResponse<Item> {
/**
* Cursor to fetch the next page
*/
next_page: string;

/**
* Items of the page
*/
data: Array<Item>;
}

export interface CursorPageParams {
/**
* Cursor to begin fetching from
*/
next_page?: string;

/**
* Number of elements to fetch
*/
limit?: number;
}

export class CursorPage<Item> extends AbstractPage<Item> implements CursorPageResponse<Item> {
/**
* Cursor to fetch the next page
*/
next_page: string;

/**
* Items of the page
*/
data: Array<Item>;

constructor(
client: APIClient,
response: Response,
body: CursorPageResponse<Item>,
options: FinalRequestOptions,
) {
super(client, response, body, options);

this.next_page = body.next_page || '';
this.data = body.data || [];
}

getPaginatedItems(): Item[] {
return this.data ?? [];
}

// @deprecated Please use `nextPageInfo()` instead
nextPageParams(): Partial<CursorPageParams> | null {
const info = this.nextPageInfo();
if (!info) return null;
if ('params' in info) return info.params;
const params = Object.fromEntries(info.url.searchParams);
if (!Object.keys(params).length) return null;
return params;
}

nextPageInfo(): PageInfo | null {
const cursor = this.next_page;
if (!cursor) {
return null;
}

return {
params: {
next_page: cursor,
},
};
}
}
Loading