From cff8c9d86782342fbef787152ac4cfa32fdd70f7 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 15 Jul 2026 22:59:47 +0000 Subject: [PATCH 1/5] feat(api): manual updates add service-account api keys doc --- .stats.yml | 8 +- go.mod | 2 +- go.sum | 4 +- .../adminorganizationprojectserviceaccount.go | 7 +- ...norganizationprojectserviceaccount_test.go | 5 +- ...organizationprojectserviceaccountapikey.go | 99 +++++++++++++++++++ ...izationprojectserviceaccountapikey_test.go | 40 ++++++++ pkg/cmd/cmd.go | 8 ++ 8 files changed, 164 insertions(+), 9 deletions(-) create mode 100644 pkg/cmd/adminorganizationprojectserviceaccountapikey.go create mode 100644 pkg/cmd/adminorganizationprojectserviceaccountapikey_test.go diff --git a/.stats.yml b/.stats.yml index 013a733..7692619 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 258 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai/openai-ae4c1a92306e31f05678c3de72efbf1903b5c09924dacd42a555cc5ccc0e5eb1.yml -openapi_spec_hash: 0973932f9a3f0b46a0933b143878f9fe -config_hash: b40012963b4619be8229fcca0105b627 +configured_endpoints: 259 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai/openai-3d8082a8a69fcab4d284f7316a701759c11ccf1e05fc6d45c210cf752833c9bd.yml +openapi_spec_hash: 56ad4f4009878ee5036929cd7f377591 +config_hash: f26d37753793f28a7c52ab44907a355b diff --git a/go.mod b/go.mod index 6b8e61d..de76c26 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/goccy/go-yaml v1.18.0 github.com/itchyny/json2yaml v0.1.4 github.com/muesli/reflow v0.3.0 - github.com/openai/openai-go/v3 v3.42.0 + github.com/openai/openai-go/v3 v3.43.0 github.com/stretchr/testify v1.10.0 github.com/tidwall/gjson v1.18.0 github.com/tidwall/pretty v1.2.1 diff --git a/go.sum b/go.sum index 63a425e..458ce7f 100644 --- a/go.sum +++ b/go.sum @@ -45,8 +45,8 @@ github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s= github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8= github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc= github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk= -github.com/openai/openai-go/v3 v3.42.0 h1:16Skv1hpEhSm3imZpPGSeEBDUgVJJA9cHryKGGsVYI8= -github.com/openai/openai-go/v3 v3.42.0/go.mod h1:cdufnVK14cWcT9qA1rRtrXx4FTRsgbDPW7Ia7SS5cZo= +github.com/openai/openai-go/v3 v3.43.0 h1:C+MFVUMU3TJNgES+Ikt7HF8xcX7J0wynKeR9ST22hZM= +github.com/openai/openai-go/v3 v3.43.0/go.mod h1:cdufnVK14cWcT9qA1rRtrXx4FTRsgbDPW7Ia7SS5cZo= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= diff --git a/pkg/cmd/adminorganizationprojectserviceaccount.go b/pkg/cmd/adminorganizationprojectserviceaccount.go index 127ed9e..4dd8bd1 100644 --- a/pkg/cmd/adminorganizationprojectserviceaccount.go +++ b/pkg/cmd/adminorganizationprojectserviceaccount.go @@ -16,7 +16,7 @@ import ( var adminOrganizationProjectsServiceAccountsCreate = cli.Command{ Name: "create", - Usage: "Creates a new service account in the project. This also returns an unredacted\nAPI key for the service account.", + Usage: "Creates a new service account in the project. By default, this also returns an\nunredacted API key for the service account.", Suggest: true, Flags: []cli.Flag{ &requestflag.Flag[string]{ @@ -30,6 +30,11 @@ var adminOrganizationProjectsServiceAccountsCreate = cli.Command{ Required: true, BodyPath: "name", }, + &requestflag.Flag[*bool]{ + Name: "create-service-account-only", + Usage: "Create the service account without default roles or an API key.", + BodyPath: "create_service_account_only", + }, }, Action: handleAdminOrganizationProjectsServiceAccountsCreate, HideHelpCommand: true, diff --git a/pkg/cmd/adminorganizationprojectserviceaccount_test.go b/pkg/cmd/adminorganizationprojectserviceaccount_test.go index ce252b1..4ef6441 100644 --- a/pkg/cmd/adminorganizationprojectserviceaccount_test.go +++ b/pkg/cmd/adminorganizationprojectserviceaccount_test.go @@ -17,12 +17,15 @@ func TestAdminOrganizationProjectsServiceAccountsCreate(t *testing.T) { "admin:organization:projects:service-accounts", "create", "--project-id", "project_id", "--name", "name", + "--create-service-account-only=true", ) }) t.Run("piping data", func(t *testing.T) { // Test piping YAML data over stdin - pipeData := []byte("name: name") + pipeData := []byte("" + + "name: name\n" + + "create_service_account_only: true\n") mocktest.TestRunMockTestWithPipeAndFlags( t, pipeData, "--api-key", "string", diff --git a/pkg/cmd/adminorganizationprojectserviceaccountapikey.go b/pkg/cmd/adminorganizationprojectserviceaccountapikey.go new file mode 100644 index 0000000..96219da --- /dev/null +++ b/pkg/cmd/adminorganizationprojectserviceaccountapikey.go @@ -0,0 +1,99 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package cmd + +import ( + "context" + "fmt" + + "github.com/openai/openai-cli/internal/apiquery" + "github.com/openai/openai-cli/internal/requestflag" + "github.com/openai/openai-go/v3" + "github.com/openai/openai-go/v3/option" + "github.com/tidwall/gjson" + "github.com/urfave/cli/v3" +) + +var adminOrganizationProjectsServiceAccountsAPIKeysCreate = cli.Command{ + Name: "create", + Usage: "Creates an API key for a service account in the project.", + Suggest: true, + Flags: []cli.Flag{ + &requestflag.Flag[string]{ + Name: "project-id", + Required: true, + PathParam: "project_id", + }, + &requestflag.Flag[string]{ + Name: "service-account-id", + Required: true, + PathParam: "service_account_id", + }, + &requestflag.Flag[string]{ + Name: "name", + Usage: "API key name.", + BodyPath: "name", + }, + &requestflag.Flag[[]string]{ + Name: "scope", + Usage: "API key scopes.", + BodyPath: "scopes", + }, + }, + Action: handleAdminOrganizationProjectsServiceAccountsAPIKeysCreate, + HideHelpCommand: true, +} + +func handleAdminOrganizationProjectsServiceAccountsAPIKeysCreate(ctx context.Context, cmd *cli.Command) error { + client := openai.NewClient(getDefaultRequestOptions(cmd)...) + unusedArgs := cmd.Args().Slice() + if !cmd.IsSet("project-id") && len(unusedArgs) > 0 { + cmd.Set("project-id", unusedArgs[0]) + unusedArgs = unusedArgs[1:] + } + if !cmd.IsSet("service-account-id") && len(unusedArgs) > 0 { + cmd.Set("service-account-id", unusedArgs[0]) + unusedArgs = unusedArgs[1:] + } + if len(unusedArgs) > 0 { + return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) + } + + options, err := flagOptions( + cmd, + apiquery.NestedQueryFormatBrackets, + apiquery.ArrayQueryFormatBrackets, + ApplicationJSON, + false, + ) + if err != nil { + return err + } + + params := openai.AdminOrganizationProjectServiceAccountAPIKeyNewParams{} + + var res []byte + options = append(options, option.WithResponseBodyInto(&res)) + _, err = client.Admin.Organization.Projects.ServiceAccounts.APIKeys.New( + ctx, + cmd.Value("project-id").(string), + cmd.Value("service-account-id").(string), + params, + options..., + ) + if err != nil { + return err + } + + obj := gjson.ParseBytes(res) + format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") + transform := cmd.Root().String("transform") + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + RawOutput: cmd.Root().Bool("raw-output"), + Title: "admin:organization:projects:service-accounts:api-keys create", + Transform: transform, + }) +} diff --git a/pkg/cmd/adminorganizationprojectserviceaccountapikey_test.go b/pkg/cmd/adminorganizationprojectserviceaccountapikey_test.go new file mode 100644 index 0000000..f99963b --- /dev/null +++ b/pkg/cmd/adminorganizationprojectserviceaccountapikey_test.go @@ -0,0 +1,40 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package cmd + +import ( + "testing" + + "github.com/openai/openai-cli/internal/mocktest" +) + +func TestAdminOrganizationProjectsServiceAccountsAPIKeysCreate(t *testing.T) { + t.Run("regular flags", func(t *testing.T) { + mocktest.TestRunMockTestWithFlags( + t, + "--api-key", "string", + "--admin-api-key", "string", + "admin:organization:projects:service-accounts:api-keys", "create", + "--project-id", "project_id", + "--service-account-id", "service_account_id", + "--name", "name", + "--scope", "string", + ) + }) + + t.Run("piping data", func(t *testing.T) { + // Test piping YAML data over stdin + pipeData := []byte("" + + "name: name\n" + + "scopes:\n" + + " - string\n") + mocktest.TestRunMockTestWithPipeAndFlags( + t, pipeData, + "--api-key", "string", + "--admin-api-key", "string", + "admin:organization:projects:service-accounts:api-keys", "create", + "--project-id", "project_id", + "--service-account-id", "service_account_id", + ) + }) +} diff --git a/pkg/cmd/cmd.go b/pkg/cmd/cmd.go index d8cff5e..4c7183e 100644 --- a/pkg/cmd/cmd.go +++ b/pkg/cmd/cmd.go @@ -612,6 +612,14 @@ func init() { &adminOrganizationProjectsServiceAccountsDelete, }, }, + { + Name: "admin:organization:projects:service-accounts:api-keys", + Category: "API RESOURCE", + Suggest: true, + Commands: []*cli.Command{ + &adminOrganizationProjectsServiceAccountsAPIKeysCreate, + }, + }, { Name: "admin:organization:projects:api-keys", Category: "API RESOURCE", From ad0f9fa6c506df6341cb3e7a7170cde6a6744fef Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 16 Jul 2026 21:21:18 +0000 Subject: [PATCH 2/5] feat(api): /organization/projects/{project_id}/service_accounts/{service_account_id}/api_keys" endpoint --- .stats.yml | 6 +- .../adminorganizationprojectserviceaccount.go | 86 ++++++++++++++++ ...norganizationprojectserviceaccount_test.go | 31 ++++++ ...organizationprojectserviceaccountapikey.go | 99 ------------------- ...izationprojectserviceaccountapikey_test.go | 40 -------- pkg/cmd/cmd.go | 9 +- 6 files changed, 121 insertions(+), 150 deletions(-) delete mode 100644 pkg/cmd/adminorganizationprojectserviceaccountapikey.go delete mode 100644 pkg/cmd/adminorganizationprojectserviceaccountapikey_test.go diff --git a/.stats.yml b/.stats.yml index 7692619..47d69ae 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 259 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai/openai-3d8082a8a69fcab4d284f7316a701759c11ccf1e05fc6d45c210cf752833c9bd.yml -openapi_spec_hash: 56ad4f4009878ee5036929cd7f377591 -config_hash: f26d37753793f28a7c52ab44907a355b +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai/openai-ca959bb4438a37cb70d0924c7a0401238bb52a85967b23b6f1d855ee866c1890.yml +openapi_spec_hash: 96da1d0eaded6713794a524166b23735 +config_hash: e1fd667219a2ea183d8a45918d6f78e3 diff --git a/pkg/cmd/adminorganizationprojectserviceaccount.go b/pkg/cmd/adminorganizationprojectserviceaccount.go index 4dd8bd1..edc6518 100644 --- a/pkg/cmd/adminorganizationprojectserviceaccount.go +++ b/pkg/cmd/adminorganizationprojectserviceaccount.go @@ -140,6 +140,38 @@ var adminOrganizationProjectsServiceAccountsDelete = cli.Command{ HideHelpCommand: true, } +var adminOrganizationProjectsServiceAccountsCreateAPIKey = cli.Command{ + Name: "create-api-key", + Usage: "Creates an API key for a service account in the project.", + Suggest: true, + Flags: []cli.Flag{ + &requestflag.Flag[string]{ + Name: "project-id", + Usage: "The ID of the project.", + Required: true, + PathParam: "project_id", + }, + &requestflag.Flag[string]{ + Name: "service-account-id", + Usage: "The ID of the service account.", + Required: true, + PathParam: "service_account_id", + }, + &requestflag.Flag[string]{ + Name: "name", + Usage: "API key name.", + BodyPath: "name", + }, + &requestflag.Flag[[]string]{ + Name: "scope", + Usage: "API key scopes.", + BodyPath: "scopes", + }, + }, + Action: handleAdminOrganizationProjectsServiceAccountsCreateAPIKey, + HideHelpCommand: true, +} + func handleAdminOrganizationProjectsServiceAccountsCreate(ctx context.Context, cmd *cli.Command) error { client := openai.NewClient(getDefaultRequestOptions(cmd)...) unusedArgs := cmd.Args().Slice() @@ -412,3 +444,57 @@ func handleAdminOrganizationProjectsServiceAccountsDelete(ctx context.Context, c Transform: transform, }) } + +func handleAdminOrganizationProjectsServiceAccountsCreateAPIKey(ctx context.Context, cmd *cli.Command) error { + client := openai.NewClient(getDefaultRequestOptions(cmd)...) + unusedArgs := cmd.Args().Slice() + if !cmd.IsSet("project-id") && len(unusedArgs) > 0 { + cmd.Set("project-id", unusedArgs[0]) + unusedArgs = unusedArgs[1:] + } + if !cmd.IsSet("service-account-id") && len(unusedArgs) > 0 { + cmd.Set("service-account-id", unusedArgs[0]) + unusedArgs = unusedArgs[1:] + } + if len(unusedArgs) > 0 { + return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) + } + + options, err := flagOptions( + cmd, + apiquery.NestedQueryFormatBrackets, + apiquery.ArrayQueryFormatBrackets, + ApplicationJSON, + false, + ) + if err != nil { + return err + } + + params := openai.AdminOrganizationProjectServiceAccountNewAPIKeyParams{} + + var res []byte + options = append(options, option.WithResponseBodyInto(&res)) + _, err = client.Admin.Organization.Projects.ServiceAccounts.NewAPIKey( + ctx, + cmd.Value("project-id").(string), + cmd.Value("service-account-id").(string), + params, + options..., + ) + if err != nil { + return err + } + + obj := gjson.ParseBytes(res) + format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") + transform := cmd.Root().String("transform") + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + RawOutput: cmd.Root().Bool("raw-output"), + Title: "admin:organization:projects:service-accounts create-api-key", + Transform: transform, + }) +} diff --git a/pkg/cmd/adminorganizationprojectserviceaccount_test.go b/pkg/cmd/adminorganizationprojectserviceaccount_test.go index 4ef6441..85bda2a 100644 --- a/pkg/cmd/adminorganizationprojectserviceaccount_test.go +++ b/pkg/cmd/adminorganizationprojectserviceaccount_test.go @@ -106,3 +106,34 @@ func TestAdminOrganizationProjectsServiceAccountsDelete(t *testing.T) { ) }) } + +func TestAdminOrganizationProjectsServiceAccountsCreateAPIKey(t *testing.T) { + t.Run("regular flags", func(t *testing.T) { + mocktest.TestRunMockTestWithFlags( + t, + "--api-key", "string", + "--admin-api-key", "string", + "admin:organization:projects:service-accounts", "create-api-key", + "--project-id", "project_id", + "--service-account-id", "service_account_id", + "--name", "name", + "--scope", "string", + ) + }) + + t.Run("piping data", func(t *testing.T) { + // Test piping YAML data over stdin + pipeData := []byte("" + + "name: name\n" + + "scopes:\n" + + " - string\n") + mocktest.TestRunMockTestWithPipeAndFlags( + t, pipeData, + "--api-key", "string", + "--admin-api-key", "string", + "admin:organization:projects:service-accounts", "create-api-key", + "--project-id", "project_id", + "--service-account-id", "service_account_id", + ) + }) +} diff --git a/pkg/cmd/adminorganizationprojectserviceaccountapikey.go b/pkg/cmd/adminorganizationprojectserviceaccountapikey.go deleted file mode 100644 index 96219da..0000000 --- a/pkg/cmd/adminorganizationprojectserviceaccountapikey.go +++ /dev/null @@ -1,99 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package cmd - -import ( - "context" - "fmt" - - "github.com/openai/openai-cli/internal/apiquery" - "github.com/openai/openai-cli/internal/requestflag" - "github.com/openai/openai-go/v3" - "github.com/openai/openai-go/v3/option" - "github.com/tidwall/gjson" - "github.com/urfave/cli/v3" -) - -var adminOrganizationProjectsServiceAccountsAPIKeysCreate = cli.Command{ - Name: "create", - Usage: "Creates an API key for a service account in the project.", - Suggest: true, - Flags: []cli.Flag{ - &requestflag.Flag[string]{ - Name: "project-id", - Required: true, - PathParam: "project_id", - }, - &requestflag.Flag[string]{ - Name: "service-account-id", - Required: true, - PathParam: "service_account_id", - }, - &requestflag.Flag[string]{ - Name: "name", - Usage: "API key name.", - BodyPath: "name", - }, - &requestflag.Flag[[]string]{ - Name: "scope", - Usage: "API key scopes.", - BodyPath: "scopes", - }, - }, - Action: handleAdminOrganizationProjectsServiceAccountsAPIKeysCreate, - HideHelpCommand: true, -} - -func handleAdminOrganizationProjectsServiceAccountsAPIKeysCreate(ctx context.Context, cmd *cli.Command) error { - client := openai.NewClient(getDefaultRequestOptions(cmd)...) - unusedArgs := cmd.Args().Slice() - if !cmd.IsSet("project-id") && len(unusedArgs) > 0 { - cmd.Set("project-id", unusedArgs[0]) - unusedArgs = unusedArgs[1:] - } - if !cmd.IsSet("service-account-id") && len(unusedArgs) > 0 { - cmd.Set("service-account-id", unusedArgs[0]) - unusedArgs = unusedArgs[1:] - } - if len(unusedArgs) > 0 { - return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) - } - - options, err := flagOptions( - cmd, - apiquery.NestedQueryFormatBrackets, - apiquery.ArrayQueryFormatBrackets, - ApplicationJSON, - false, - ) - if err != nil { - return err - } - - params := openai.AdminOrganizationProjectServiceAccountAPIKeyNewParams{} - - var res []byte - options = append(options, option.WithResponseBodyInto(&res)) - _, err = client.Admin.Organization.Projects.ServiceAccounts.APIKeys.New( - ctx, - cmd.Value("project-id").(string), - cmd.Value("service-account-id").(string), - params, - options..., - ) - if err != nil { - return err - } - - obj := gjson.ParseBytes(res) - format := cmd.Root().String("format") - explicitFormat := cmd.Root().IsSet("format") - transform := cmd.Root().String("transform") - return ShowJSON(obj, ShowJSONOpts{ - ExplicitFormat: explicitFormat, - Format: format, - RawOutput: cmd.Root().Bool("raw-output"), - Title: "admin:organization:projects:service-accounts:api-keys create", - Transform: transform, - }) -} diff --git a/pkg/cmd/adminorganizationprojectserviceaccountapikey_test.go b/pkg/cmd/adminorganizationprojectserviceaccountapikey_test.go deleted file mode 100644 index f99963b..0000000 --- a/pkg/cmd/adminorganizationprojectserviceaccountapikey_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package cmd - -import ( - "testing" - - "github.com/openai/openai-cli/internal/mocktest" -) - -func TestAdminOrganizationProjectsServiceAccountsAPIKeysCreate(t *testing.T) { - t.Run("regular flags", func(t *testing.T) { - mocktest.TestRunMockTestWithFlags( - t, - "--api-key", "string", - "--admin-api-key", "string", - "admin:organization:projects:service-accounts:api-keys", "create", - "--project-id", "project_id", - "--service-account-id", "service_account_id", - "--name", "name", - "--scope", "string", - ) - }) - - t.Run("piping data", func(t *testing.T) { - // Test piping YAML data over stdin - pipeData := []byte("" + - "name: name\n" + - "scopes:\n" + - " - string\n") - mocktest.TestRunMockTestWithPipeAndFlags( - t, pipeData, - "--api-key", "string", - "--admin-api-key", "string", - "admin:organization:projects:service-accounts:api-keys", "create", - "--project-id", "project_id", - "--service-account-id", "service_account_id", - ) - }) -} diff --git a/pkg/cmd/cmd.go b/pkg/cmd/cmd.go index 4c7183e..b660499 100644 --- a/pkg/cmd/cmd.go +++ b/pkg/cmd/cmd.go @@ -610,14 +610,7 @@ func init() { &adminOrganizationProjectsServiceAccountsUpdate, &adminOrganizationProjectsServiceAccountsList, &adminOrganizationProjectsServiceAccountsDelete, - }, - }, - { - Name: "admin:organization:projects:service-accounts:api-keys", - Category: "API RESOURCE", - Suggest: true, - Commands: []*cli.Command{ - &adminOrganizationProjectsServiceAccountsAPIKeysCreate, + &adminOrganizationProjectsServiceAccountsCreateAPIKey, }, }, { From 3c1f4b878c9c9e612f70369816c2fcf98306a350 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 17 Jul 2026 02:27:46 +0000 Subject: [PATCH 3/5] feat(api): manual updates --- .stats.yml | 6 +- .../adminorganizationprojectserviceaccount.go | 86 --------------- ...norganizationprojectserviceaccount_test.go | 31 ------ ...organizationprojectserviceaccountapikey.go | 101 ++++++++++++++++++ ...izationprojectserviceaccountapikey_test.go | 40 +++++++ pkg/cmd/cmd.go | 9 +- 6 files changed, 152 insertions(+), 121 deletions(-) create mode 100644 pkg/cmd/adminorganizationprojectserviceaccountapikey.go create mode 100644 pkg/cmd/adminorganizationprojectserviceaccountapikey_test.go diff --git a/.stats.yml b/.stats.yml index 47d69ae..c691eb3 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 259 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai/openai-ca959bb4438a37cb70d0924c7a0401238bb52a85967b23b6f1d855ee866c1890.yml -openapi_spec_hash: 96da1d0eaded6713794a524166b23735 -config_hash: e1fd667219a2ea183d8a45918d6f78e3 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai/openai-8ed7dcb0d163e7f5205dbe172d6ad5b7ce367b23c20629830e39a0aee920a029.yml +openapi_spec_hash: 011cdae0c67909fb80a4a5eb54ca5bca +config_hash: 896f0f71bc7d1ee09435813cdef97523 diff --git a/pkg/cmd/adminorganizationprojectserviceaccount.go b/pkg/cmd/adminorganizationprojectserviceaccount.go index edc6518..4dd8bd1 100644 --- a/pkg/cmd/adminorganizationprojectserviceaccount.go +++ b/pkg/cmd/adminorganizationprojectserviceaccount.go @@ -140,38 +140,6 @@ var adminOrganizationProjectsServiceAccountsDelete = cli.Command{ HideHelpCommand: true, } -var adminOrganizationProjectsServiceAccountsCreateAPIKey = cli.Command{ - Name: "create-api-key", - Usage: "Creates an API key for a service account in the project.", - Suggest: true, - Flags: []cli.Flag{ - &requestflag.Flag[string]{ - Name: "project-id", - Usage: "The ID of the project.", - Required: true, - PathParam: "project_id", - }, - &requestflag.Flag[string]{ - Name: "service-account-id", - Usage: "The ID of the service account.", - Required: true, - PathParam: "service_account_id", - }, - &requestflag.Flag[string]{ - Name: "name", - Usage: "API key name.", - BodyPath: "name", - }, - &requestflag.Flag[[]string]{ - Name: "scope", - Usage: "API key scopes.", - BodyPath: "scopes", - }, - }, - Action: handleAdminOrganizationProjectsServiceAccountsCreateAPIKey, - HideHelpCommand: true, -} - func handleAdminOrganizationProjectsServiceAccountsCreate(ctx context.Context, cmd *cli.Command) error { client := openai.NewClient(getDefaultRequestOptions(cmd)...) unusedArgs := cmd.Args().Slice() @@ -444,57 +412,3 @@ func handleAdminOrganizationProjectsServiceAccountsDelete(ctx context.Context, c Transform: transform, }) } - -func handleAdminOrganizationProjectsServiceAccountsCreateAPIKey(ctx context.Context, cmd *cli.Command) error { - client := openai.NewClient(getDefaultRequestOptions(cmd)...) - unusedArgs := cmd.Args().Slice() - if !cmd.IsSet("project-id") && len(unusedArgs) > 0 { - cmd.Set("project-id", unusedArgs[0]) - unusedArgs = unusedArgs[1:] - } - if !cmd.IsSet("service-account-id") && len(unusedArgs) > 0 { - cmd.Set("service-account-id", unusedArgs[0]) - unusedArgs = unusedArgs[1:] - } - if len(unusedArgs) > 0 { - return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) - } - - options, err := flagOptions( - cmd, - apiquery.NestedQueryFormatBrackets, - apiquery.ArrayQueryFormatBrackets, - ApplicationJSON, - false, - ) - if err != nil { - return err - } - - params := openai.AdminOrganizationProjectServiceAccountNewAPIKeyParams{} - - var res []byte - options = append(options, option.WithResponseBodyInto(&res)) - _, err = client.Admin.Organization.Projects.ServiceAccounts.NewAPIKey( - ctx, - cmd.Value("project-id").(string), - cmd.Value("service-account-id").(string), - params, - options..., - ) - if err != nil { - return err - } - - obj := gjson.ParseBytes(res) - format := cmd.Root().String("format") - explicitFormat := cmd.Root().IsSet("format") - transform := cmd.Root().String("transform") - return ShowJSON(obj, ShowJSONOpts{ - ExplicitFormat: explicitFormat, - Format: format, - RawOutput: cmd.Root().Bool("raw-output"), - Title: "admin:organization:projects:service-accounts create-api-key", - Transform: transform, - }) -} diff --git a/pkg/cmd/adminorganizationprojectserviceaccount_test.go b/pkg/cmd/adminorganizationprojectserviceaccount_test.go index 85bda2a..4ef6441 100644 --- a/pkg/cmd/adminorganizationprojectserviceaccount_test.go +++ b/pkg/cmd/adminorganizationprojectserviceaccount_test.go @@ -106,34 +106,3 @@ func TestAdminOrganizationProjectsServiceAccountsDelete(t *testing.T) { ) }) } - -func TestAdminOrganizationProjectsServiceAccountsCreateAPIKey(t *testing.T) { - t.Run("regular flags", func(t *testing.T) { - mocktest.TestRunMockTestWithFlags( - t, - "--api-key", "string", - "--admin-api-key", "string", - "admin:organization:projects:service-accounts", "create-api-key", - "--project-id", "project_id", - "--service-account-id", "service_account_id", - "--name", "name", - "--scope", "string", - ) - }) - - t.Run("piping data", func(t *testing.T) { - // Test piping YAML data over stdin - pipeData := []byte("" + - "name: name\n" + - "scopes:\n" + - " - string\n") - mocktest.TestRunMockTestWithPipeAndFlags( - t, pipeData, - "--api-key", "string", - "--admin-api-key", "string", - "admin:organization:projects:service-accounts", "create-api-key", - "--project-id", "project_id", - "--service-account-id", "service_account_id", - ) - }) -} diff --git a/pkg/cmd/adminorganizationprojectserviceaccountapikey.go b/pkg/cmd/adminorganizationprojectserviceaccountapikey.go new file mode 100644 index 0000000..372cb7b --- /dev/null +++ b/pkg/cmd/adminorganizationprojectserviceaccountapikey.go @@ -0,0 +1,101 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package cmd + +import ( + "context" + "fmt" + + "github.com/openai/openai-cli/internal/apiquery" + "github.com/openai/openai-cli/internal/requestflag" + "github.com/openai/openai-go/v3" + "github.com/openai/openai-go/v3/option" + "github.com/tidwall/gjson" + "github.com/urfave/cli/v3" +) + +var adminOrganizationProjectsServiceAccountsAPIKeysCreate = cli.Command{ + Name: "create", + Usage: "Creates an API key for a service account in the project.", + Suggest: true, + Flags: []cli.Flag{ + &requestflag.Flag[string]{ + Name: "project-id", + Usage: "The ID of the project.", + Required: true, + PathParam: "project_id", + }, + &requestflag.Flag[string]{ + Name: "service-account-id", + Usage: "The ID of the service account.", + Required: true, + PathParam: "service_account_id", + }, + &requestflag.Flag[string]{ + Name: "name", + Usage: "API key name.", + BodyPath: "name", + }, + &requestflag.Flag[[]string]{ + Name: "scope", + Usage: "API key scopes.", + BodyPath: "scopes", + }, + }, + Action: handleAdminOrganizationProjectsServiceAccountsAPIKeysCreate, + HideHelpCommand: true, +} + +func handleAdminOrganizationProjectsServiceAccountsAPIKeysCreate(ctx context.Context, cmd *cli.Command) error { + client := openai.NewClient(getDefaultRequestOptions(cmd)...) + unusedArgs := cmd.Args().Slice() + if !cmd.IsSet("project-id") && len(unusedArgs) > 0 { + cmd.Set("project-id", unusedArgs[0]) + unusedArgs = unusedArgs[1:] + } + if !cmd.IsSet("service-account-id") && len(unusedArgs) > 0 { + cmd.Set("service-account-id", unusedArgs[0]) + unusedArgs = unusedArgs[1:] + } + if len(unusedArgs) > 0 { + return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs) + } + + options, err := flagOptions( + cmd, + apiquery.NestedQueryFormatBrackets, + apiquery.ArrayQueryFormatBrackets, + ApplicationJSON, + false, + ) + if err != nil { + return err + } + + params := openai.AdminOrganizationProjectServiceAccountAPIKeyNewParams{} + + var res []byte + options = append(options, option.WithResponseBodyInto(&res)) + _, err = client.Admin.Organization.Projects.ServiceAccounts.APIKeys.New( + ctx, + cmd.Value("project-id").(string), + cmd.Value("service-account-id").(string), + params, + options..., + ) + if err != nil { + return err + } + + obj := gjson.ParseBytes(res) + format := cmd.Root().String("format") + explicitFormat := cmd.Root().IsSet("format") + transform := cmd.Root().String("transform") + return ShowJSON(obj, ShowJSONOpts{ + ExplicitFormat: explicitFormat, + Format: format, + RawOutput: cmd.Root().Bool("raw-output"), + Title: "admin:organization:projects:service-accounts:api-keys create", + Transform: transform, + }) +} diff --git a/pkg/cmd/adminorganizationprojectserviceaccountapikey_test.go b/pkg/cmd/adminorganizationprojectserviceaccountapikey_test.go new file mode 100644 index 0000000..f99963b --- /dev/null +++ b/pkg/cmd/adminorganizationprojectserviceaccountapikey_test.go @@ -0,0 +1,40 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package cmd + +import ( + "testing" + + "github.com/openai/openai-cli/internal/mocktest" +) + +func TestAdminOrganizationProjectsServiceAccountsAPIKeysCreate(t *testing.T) { + t.Run("regular flags", func(t *testing.T) { + mocktest.TestRunMockTestWithFlags( + t, + "--api-key", "string", + "--admin-api-key", "string", + "admin:organization:projects:service-accounts:api-keys", "create", + "--project-id", "project_id", + "--service-account-id", "service_account_id", + "--name", "name", + "--scope", "string", + ) + }) + + t.Run("piping data", func(t *testing.T) { + // Test piping YAML data over stdin + pipeData := []byte("" + + "name: name\n" + + "scopes:\n" + + " - string\n") + mocktest.TestRunMockTestWithPipeAndFlags( + t, pipeData, + "--api-key", "string", + "--admin-api-key", "string", + "admin:organization:projects:service-accounts:api-keys", "create", + "--project-id", "project_id", + "--service-account-id", "service_account_id", + ) + }) +} diff --git a/pkg/cmd/cmd.go b/pkg/cmd/cmd.go index b660499..4c7183e 100644 --- a/pkg/cmd/cmd.go +++ b/pkg/cmd/cmd.go @@ -610,7 +610,14 @@ func init() { &adminOrganizationProjectsServiceAccountsUpdate, &adminOrganizationProjectsServiceAccountsList, &adminOrganizationProjectsServiceAccountsDelete, - &adminOrganizationProjectsServiceAccountsCreateAPIKey, + }, + }, + { + Name: "admin:organization:projects:service-accounts:api-keys", + Category: "API RESOURCE", + Suggest: true, + Commands: []*cli.Command{ + &adminOrganizationProjectsServiceAccountsAPIKeysCreate, }, }, { From 8c73e8c92716a1cdb9a374f1325626828a5b9577 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 17 Jul 2026 17:17:49 +0000 Subject: [PATCH 4/5] feat(stlc): configurable CI runner and private-production-repo support in workflow templates --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 36d2860..d38675b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: lint: timeout-minutes: 10 name: lint - runs-on: ${{ github.repository == 'stainless-sdks/openai-cli' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + runs-on: ${{ startsWith(github.repository, 'stainless-sdks/') && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') steps: @@ -54,7 +54,7 @@ jobs: permissions: contents: read id-token: write - runs-on: ${{ github.repository == 'stainless-sdks/openai-cli' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + runs-on: ${{ startsWith(github.repository, 'stainless-sdks/') && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 @@ -109,7 +109,7 @@ jobs: test: timeout-minutes: 10 name: test - runs-on: ${{ github.repository == 'stainless-sdks/openai-cli' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + runs-on: ${{ startsWith(github.repository, 'stainless-sdks/') && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 From e31157e70c9e8597090e9a2c1638926654816538 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 17 Jul 2026 17:18:22 +0000 Subject: [PATCH 5/5] release: 1.5.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 11 +++++++++++ pkg/cmd/version.go | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 3e9af1b..fbd9082 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.4.0" + ".": "1.5.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index fcdebd1..124166e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Changelog +## 1.5.0 (2026-07-17) + +Full Changelog: [v1.4.0...v1.5.0](https://github.com/openai/openai-cli/compare/v1.4.0...v1.5.0) + +### Features + +* **api:** /organization/projects/{project_id}/service_accounts/{service_account_id}/api_keys" endpoint ([ad0f9fa](https://github.com/openai/openai-cli/commit/ad0f9fa6c506df6341cb3e7a7170cde6a6744fef)) +* **api:** manual updates ([3c1f4b8](https://github.com/openai/openai-cli/commit/3c1f4b878c9c9e612f70369816c2fcf98306a350)) +* **api:** manual updates ([cff8c9d](https://github.com/openai/openai-cli/commit/cff8c9d86782342fbef787152ac4cfa32fdd70f7)) +* **stlc:** configurable CI runner and private-production-repo support in workflow templates ([8c73e8c](https://github.com/openai/openai-cli/commit/8c73e8c92716a1cdb9a374f1325626828a5b9577)) + ## 1.4.0 (2026-07-14) Full Changelog: [v1.3.0...v1.4.0](https://github.com/openai/openai-cli/compare/v1.3.0...v1.4.0) diff --git a/pkg/cmd/version.go b/pkg/cmd/version.go index a2e6c7d..cf77cd0 100644 --- a/pkg/cmd/version.go +++ b/pkg/cmd/version.go @@ -2,4 +2,4 @@ package cmd -const Version = "1.4.0" // x-release-please-version +const Version = "1.5.0" // x-release-please-version