Skip to content

Commit e02d02e

Browse files
feat(api): manual updates
1 parent 5f2e61b commit e02d02e

4 files changed

Lines changed: 138 additions & 3 deletions

File tree

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 30
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-42c531dcf60b5d35e3996c1a669a3fe2de19d8caedf2bfd69e4864a1041c9bfa.yml
1+
configured_endpoints: 32
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-d25300a20809f87d2069c1f4417b158b2e2d1cef3ca9b6bf7653e02233deba2c.yml
33
openapi_spec_hash: e43dd84c75e6d710c7346b9f12c34738
4-
config_hash: daabb160675d86b354711da1e77e5129
4+
config_hash: 70e7e80b5e87f94981bee396c6cd41e8

pkg/cmd/cmd.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ func init() {
155155
&monitorsUpdate,
156156
&monitorsList,
157157
&monitorsDelete,
158+
&monitorsGetCreditUsage,
159+
&monitorsGetLimits,
158160
&monitorsListAccountChanges,
159161
&monitorsListAccountRuns,
160162
&monitorsListChanges,

pkg/cmd/monitor.go

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,35 @@ var monitorsDelete = cli.Command{
270270
HideHelpCommand: true,
271271
}
272272

273+
var monitorsGetCreditUsage = cli.Command{
274+
Name: "get-credit-usage",
275+
Usage: "Returns credits charged per monitor over an optional [since, until] window,\nnewest spenders first.",
276+
Suggest: true,
277+
Flags: []cli.Flag{
278+
&requestflag.Flag[any]{
279+
Name: "since",
280+
Usage: "Only include items at or after this ISO 8601 timestamp.",
281+
QueryPath: "since",
282+
},
283+
&requestflag.Flag[any]{
284+
Name: "until",
285+
Usage: "Only include items before this ISO 8601 timestamp.",
286+
QueryPath: "until",
287+
},
288+
},
289+
Action: handleMonitorsGetCreditUsage,
290+
HideHelpCommand: true,
291+
}
292+
293+
var monitorsGetLimits = cli.Command{
294+
Name: "get-limits",
295+
Usage: "Returns how many monitors the account has and the maximum it allows.",
296+
Suggest: true,
297+
Flags: []cli.Flag{},
298+
Action: handleMonitorsGetLimits,
299+
HideHelpCommand: true,
300+
}
301+
273302
var monitorsListAccountChanges = cli.Command{
274303
Name: "list-account-changes",
275304
Usage: "Returns an account-wide feed of detected changes across monitors.",
@@ -660,6 +689,86 @@ func handleMonitorsDelete(ctx context.Context, cmd *cli.Command) error {
660689
})
661690
}
662691

692+
func handleMonitorsGetCreditUsage(ctx context.Context, cmd *cli.Command) error {
693+
client := contextdev.NewClient(getDefaultRequestOptions(cmd)...)
694+
unusedArgs := cmd.Args().Slice()
695+
696+
if len(unusedArgs) > 0 {
697+
return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs)
698+
}
699+
700+
options, err := flagOptions(
701+
cmd,
702+
apiquery.NestedQueryFormatBrackets,
703+
apiquery.ArrayQueryFormatComma,
704+
EmptyBody,
705+
false,
706+
)
707+
if err != nil {
708+
return err
709+
}
710+
711+
params := contextdev.MonitorGetCreditUsageParams{}
712+
713+
var res []byte
714+
options = append(options, option.WithResponseBodyInto(&res))
715+
_, err = client.Monitors.GetCreditUsage(ctx, params, options...)
716+
if err != nil {
717+
return err
718+
}
719+
720+
obj := gjson.ParseBytes(res)
721+
format := cmd.Root().String("format")
722+
explicitFormat := cmd.Root().IsSet("format")
723+
transform := cmd.Root().String("transform")
724+
return ShowJSON(obj, ShowJSONOpts{
725+
ExplicitFormat: explicitFormat,
726+
Format: format,
727+
RawOutput: cmd.Root().Bool("raw-output"),
728+
Title: "monitors get-credit-usage",
729+
Transform: transform,
730+
})
731+
}
732+
733+
func handleMonitorsGetLimits(ctx context.Context, cmd *cli.Command) error {
734+
client := contextdev.NewClient(getDefaultRequestOptions(cmd)...)
735+
unusedArgs := cmd.Args().Slice()
736+
737+
if len(unusedArgs) > 0 {
738+
return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs)
739+
}
740+
741+
options, err := flagOptions(
742+
cmd,
743+
apiquery.NestedQueryFormatBrackets,
744+
apiquery.ArrayQueryFormatComma,
745+
EmptyBody,
746+
false,
747+
)
748+
if err != nil {
749+
return err
750+
}
751+
752+
var res []byte
753+
options = append(options, option.WithResponseBodyInto(&res))
754+
_, err = client.Monitors.GetLimits(ctx, options...)
755+
if err != nil {
756+
return err
757+
}
758+
759+
obj := gjson.ParseBytes(res)
760+
format := cmd.Root().String("format")
761+
explicitFormat := cmd.Root().IsSet("format")
762+
transform := cmd.Root().String("transform")
763+
return ShowJSON(obj, ShowJSONOpts{
764+
ExplicitFormat: explicitFormat,
765+
Format: format,
766+
RawOutput: cmd.Root().Bool("raw-output"),
767+
Title: "monitors get-limits",
768+
Transform: transform,
769+
})
770+
}
771+
663772
func handleMonitorsListAccountChanges(ctx context.Context, cmd *cli.Command) error {
664773
client := contextdev.NewClient(getDefaultRequestOptions(cmd)...)
665774
unusedArgs := cmd.Args().Slice()

pkg/cmd/monitor_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,30 @@ func TestMonitorsDelete(t *testing.T) {
201201
})
202202
}
203203

204+
func TestMonitorsGetCreditUsage(t *testing.T) {
205+
t.Skip("Mock server tests are disabled")
206+
t.Run("regular flags", func(t *testing.T) {
207+
mocktest.TestRunMockTestWithFlags(
208+
t,
209+
"--api-key", "string",
210+
"monitors", "get-credit-usage",
211+
"--since", "'2026-06-01T00:00:00Z'",
212+
"--until", "'2026-06-28T00:00:00Z'",
213+
)
214+
})
215+
}
216+
217+
func TestMonitorsGetLimits(t *testing.T) {
218+
t.Skip("Mock server tests are disabled")
219+
t.Run("regular flags", func(t *testing.T) {
220+
mocktest.TestRunMockTestWithFlags(
221+
t,
222+
"--api-key", "string",
223+
"monitors", "get-limits",
224+
)
225+
})
226+
}
227+
204228
func TestMonitorsListAccountChanges(t *testing.T) {
205229
t.Skip("Mock server tests are disabled")
206230
t.Run("regular flags", func(t *testing.T) {

0 commit comments

Comments
 (0)