Skip to content

Commit

Permalink
feat(api): OpenAPI spec update via Stainless API (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Sep 5, 2024
1 parent ac9dca1 commit 7a51725
Show file tree
Hide file tree
Showing 9 changed files with 471 additions and 41 deletions.
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 88
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/metronome%2Fmetronome-2213de19fd79bd2188fb178888a30c39dbcacebd7b0693b47e293d118fba5228.yml
configured_endpoints: 90
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/metronome%2Fmetronome-689348d45e1dedd9c2658451fce83ea94d995005f95e67b73f3b9ec8e30b0a93.yml
4 changes: 3 additions & 1 deletion api.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ Methods:

- <code title="post /billable-metrics/create">client.BillableMetrics.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#BillableMetricService.New">New</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go">metronome</a>.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#BillableMetricNewParams">BillableMetricNewParams</a>) (<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go">metronome</a>.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#BillableMetricNewResponse">BillableMetricNewResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /billable-metrics/{billable_metric_id}">client.BillableMetrics.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#BillableMetricService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, billableMetricID <a href="https://pkg.go.dev/builtin#string">string</a>) (<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go">metronome</a>.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#BillableMetricGetResponse">BillableMetricGetResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /customers/{customer_id}/billable-metrics">client.BillableMetrics.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#BillableMetricService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, customerID <a href="https://pkg.go.dev/builtin#string">string</a>, query <a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go">metronome</a>.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#BillableMetricListParams">BillableMetricListParams</a>) (<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go/internal/pagination">pagination</a>.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go/internal/pagination#CursorPage">CursorPage</a>[<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go">metronome</a>.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#BillableMetricListResponse">BillableMetricListResponse</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /billable-metrics">client.BillableMetrics.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#BillableMetricService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, query <a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go">metronome</a>.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#BillableMetricListParams">BillableMetricListParams</a>) (<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go/internal/pagination">pagination</a>.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go/internal/pagination#CursorPage">CursorPage</a>[<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go">metronome</a>.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#BillableMetricListResponse">BillableMetricListResponse</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="post /billable-metrics/archive">client.BillableMetrics.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#BillableMetricService.Archive">Archive</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go">metronome</a>.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#BillableMetricArchiveParams">BillableMetricArchiveParams</a>) (<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go">metronome</a>.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#BillableMetricArchiveResponse">BillableMetricArchiveResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

# Services
Expand Down Expand Up @@ -294,6 +294,7 @@ Response Types:
- <a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go">metronome</a>.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#ContractListResponse">ContractListResponse</a>
- <a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go">metronome</a>.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#ContractAmendResponse">ContractAmendResponse</a>
- <a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go">metronome</a>.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#ContractArchiveResponse">ContractArchiveResponse</a>
- <a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go">metronome</a>.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#ContractNewHistoricalInvoicesResponse">ContractNewHistoricalInvoicesResponse</a>
- <a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go">metronome</a>.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#ContractListBalancesResponse">ContractListBalancesResponse</a>
- <a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go">metronome</a>.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#ContractGetRateScheduleResponse">ContractGetRateScheduleResponse</a>
- <a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go">metronome</a>.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#ContractScheduleProServicesInvoiceResponse">ContractScheduleProServicesInvoiceResponse</a>
Expand All @@ -307,6 +308,7 @@ Methods:
- <code title="post /contracts/addManualBalanceLedgerEntry">client.Contracts.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#ContractService.AddManualBalanceEntry">AddManualBalanceEntry</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go">metronome</a>.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#ContractAddManualBalanceEntryParams">ContractAddManualBalanceEntryParams</a>) <a href="https://pkg.go.dev/builtin#error">error</a></code>
- <code title="post /contracts/amend">client.Contracts.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#ContractService.Amend">Amend</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go">metronome</a>.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#ContractAmendParams">ContractAmendParams</a>) (<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go">metronome</a>.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#ContractAmendResponse">ContractAmendResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="post /contracts/archive">client.Contracts.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#ContractService.Archive">Archive</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go">metronome</a>.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#ContractArchiveParams">ContractArchiveParams</a>) (<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go">metronome</a>.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#ContractArchiveResponse">ContractArchiveResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="post /contracts/createHistoricalInvoices">client.Contracts.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#ContractService.NewHistoricalInvoices">NewHistoricalInvoices</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go">metronome</a>.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#ContractNewHistoricalInvoicesParams">ContractNewHistoricalInvoicesParams</a>) (<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go">metronome</a>.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#ContractNewHistoricalInvoicesResponse">ContractNewHistoricalInvoicesResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="post /contracts/customerBalances/list">client.Contracts.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#ContractService.ListBalances">ListBalances</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go">metronome</a>.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#ContractListBalancesParams">ContractListBalancesParams</a>) (<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go">metronome</a>.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#ContractListBalancesResponse">ContractListBalancesResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="post /contracts/getContractRateSchedule">client.Contracts.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#ContractService.GetRateSchedule">GetRateSchedule</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, params <a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go">metronome</a>.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#ContractGetRateScheduleParams">ContractGetRateScheduleParams</a>) (<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go">metronome</a>.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#ContractGetRateScheduleResponse">ContractGetRateScheduleResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="post /contracts/scheduleProServicesInvoice">client.Contracts.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#ContractService.ScheduleProServicesInvoice">ScheduleProServicesInvoice</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go">metronome</a>.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#ContractScheduleProServicesInvoiceParams">ContractScheduleProServicesInvoiceParams</a>) (<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go">metronome</a>.<a href="https://pkg.go.dev/github.com/Metronome-Industries/metronome-go#ContractScheduleProServicesInvoiceResponse">ContractScheduleProServicesInvoiceResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
Expand Down
35 changes: 9 additions & 26 deletions billablemetric.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,12 @@ func (r *BillableMetricService) Get(ctx context.Context, billableMetricID string
return
}

// Get all billable metrics for a given customer.
func (r *BillableMetricService) List(ctx context.Context, customerID string, query BillableMetricListParams, opts ...option.RequestOption) (res *pagination.CursorPage[BillableMetricListResponse], err error) {
// List all billable metrics.
func (r *BillableMetricService) List(ctx context.Context, query BillableMetricListParams, opts ...option.RequestOption) (res *pagination.CursorPage[BillableMetricListResponse], err error) {
var raw *http.Response
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
if customerID == "" {
err = errors.New("missing required customer_id parameter")
return
}
path := fmt.Sprintf("customers/%s/billable-metrics", customerID)
path := "billable-metrics"
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
if err != nil {
return nil, err
Expand All @@ -79,9 +75,9 @@ func (r *BillableMetricService) List(ctx context.Context, customerID string, que
return res, nil
}

// Get all billable metrics for a given customer.
func (r *BillableMetricService) ListAutoPaging(ctx context.Context, customerID string, query BillableMetricListParams, opts ...option.RequestOption) *pagination.CursorPageAutoPager[BillableMetricListResponse] {
return pagination.NewCursorPageAutoPager(r.List(ctx, customerID, query, opts...))
// List all billable metrics.
func (r *BillableMetricService) ListAutoPaging(ctx context.Context, query BillableMetricListParams, opts ...option.RequestOption) *pagination.CursorPageAutoPager[BillableMetricListResponse] {
return pagination.NewCursorPageAutoPager(r.List(ctx, query, opts...))
}

// Archive an existing billable metric.
Expand Down Expand Up @@ -204,12 +200,10 @@ func (r BillableMetricGetResponseDataAggregationType) IsKnown() bool {
}

type BillableMetricListResponse struct {
ID string `json:"id,required" format:"uuid"`
// ID of the billable metric
ID string `json:"id,required" format:"uuid"`
// The display name of the billable metric.
Name string `json:"name,required"`
// (DEPRECATED) use aggregation_type instead
Aggregate string `json:"aggregate"`
// (DEPRECATED) use aggregation_key instead
AggregateKeys []string `json:"aggregate_keys"`
// A key that specifies which property of the event is used to aggregate data. This
// key must be one of the property filter names and is not applicable when the
// aggregation type is 'count'.
Expand All @@ -219,10 +213,6 @@ type BillableMetricListResponse struct {
CustomFields map[string]string `json:"custom_fields"`
// An optional filtering rule to match the 'event_type' property of an event.
EventTypeFilter shared.EventTypeFilter `json:"event_type_filter"`
// (DEPRECATED) use property_filters & event_type_filter instead
Filter map[string]interface{} `json:"filter"`
// (DEPRECATED) use group_keys instead
GroupBy []string `json:"group_by"`
// Property names that are used to group usage costs on an invoice. Each entry
// represents a set of properties used to slice events into distinct buckets.
GroupKeys [][]string `json:"group_keys"`
Expand All @@ -240,14 +230,10 @@ type BillableMetricListResponse struct {
type billableMetricListResponseJSON struct {
ID apijson.Field
Name apijson.Field
Aggregate apijson.Field
AggregateKeys apijson.Field
AggregationKey apijson.Field
AggregationType apijson.Field
CustomFields apijson.Field
EventTypeFilter apijson.Field
Filter apijson.Field
GroupBy apijson.Field
GroupKeys apijson.Field
PropertyFilters apijson.Field
Sql apijson.Field
Expand Down Expand Up @@ -353,9 +339,6 @@ type BillableMetricListParams struct {
Limit param.Field[int64] `query:"limit"`
// Cursor that indicates where the next page of results should start.
NextPage param.Field[string] `query:"next_page"`
// If true, the list of metrics will be filtered to just ones that are on the
// customer's current plan
OnCurrentPlan param.Field[bool] `query:"on_current_plan"`
}

// URLQuery serializes [BillableMetricListParams]'s query parameters as
Expand Down
13 changes: 4 additions & 9 deletions billablemetric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,10 @@ func TestBillableMetricListWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithBearerToken("My Bearer Token"),
)
_, err := client.BillableMetrics.List(
context.TODO(),
"d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",
metronome.BillableMetricListParams{
Limit: metronome.F(int64(1)),
NextPage: metronome.F("next_page"),
OnCurrentPlan: metronome.F(true),
},
)
_, err := client.BillableMetrics.List(context.TODO(), metronome.BillableMetricListParams{
Limit: metronome.F(int64(1)),
NextPage: metronome.F("next_page"),
})
if err != nil {
var apierr *metronome.Error
if errors.As(err, &apierr) {
Expand Down
Loading

0 comments on commit 7a51725

Please sign in to comment.