diff --git a/cmd/stackpack.go b/cmd/stackpack.go index 0f7fc83f..4dd582f5 100644 --- a/cmd/stackpack.go +++ b/cmd/stackpack.go @@ -33,6 +33,7 @@ func StackPackCommand(cli *di.Deps) *cobra.Command { cmd.AddCommand(stackpack.StackpackScaffoldCommand(cli)) cmd.AddCommand(stackpack.StackpackPackageCommand(cli)) cmd.AddCommand(stackpack.StackpackTestDeployCommand(cli)) + cmd.AddCommand(stackpack.StackpackValidateCommand(cli)) } return cmd diff --git a/cmd/stackpack/stackpack_validate.go b/cmd/stackpack/stackpack_validate.go new file mode 100644 index 00000000..523f0619 --- /dev/null +++ b/cmd/stackpack/stackpack_validate.go @@ -0,0 +1,153 @@ +package stackpack + +import ( + "fmt" + "os" + "path/filepath" + + "github.com/spf13/cobra" + "github.com/stackvista/stackstate-cli/generated/stackstate_api" + "github.com/stackvista/stackstate-cli/internal/common" + "github.com/stackvista/stackstate-cli/internal/di" +) + +// ValidateArgs contains arguments for stackpack validate command +type ValidateArgs struct { + StackpackDir string + StackpackFile string +} + +// StackpackValidateCommand creates the validate subcommand +func StackpackValidateCommand(cli *di.Deps) *cobra.Command { + return stackpackValidateCommandWithArgs(cli, &ValidateArgs{}) +} + +// stackpackValidateCommandWithArgs creates the validate command with injected args (for testing) +func stackpackValidateCommandWithArgs(cli *di.Deps, args *ValidateArgs) *cobra.Command { + cmd := &cobra.Command{ + Use: "validate", + Short: "Validate a stackpack", + Long: `Validate a stackpack against a SUSE Observability server. + +This command validates a stackpack by uploading it to the server. +- If a directory is provided, it is automatically packaged into a .sts file before uploading +- If a .sts file is provided, it is uploaded directly + +Exactly one of --stackpack-directory or --stackpack-file must be specified. + +This command is experimental and requires STS_EXPERIMENTAL_STACKPACK environment variable to be set.`, + Example: `# Validate a stackpack directory (automatically packaged) +sts stackpack validate --stackpack-directory ./my-stackpack + +# Validate a pre-packaged .sts file +sts stackpack validate --stackpack-file ./my-stackpack.sts`, + RunE: cli.CmdRunEWithApi(RunStackpackValidateCommand(args)), + } + + cmd.Flags().StringVarP(&args.StackpackDir, "stackpack-directory", "d", "", "Path to stackpack directory") + cmd.Flags().StringVarP(&args.StackpackFile, "stackpack-file", "f", "", "Path to .sts file") + + return cmd +} + +// RunStackpackValidateCommand executes the validate command +func RunStackpackValidateCommand(args *ValidateArgs) di.CmdWithApiFn { + return func( + cmd *cobra.Command, + cli *di.Deps, + api *stackstate_api.APIClient, + serverInfo *stackstate_api.ServerInfo, + ) common.CLIError { + // Validate exactly one of directory or file is set + if (args.StackpackDir == "" && args.StackpackFile == "") || + (args.StackpackDir != "" && args.StackpackFile != "") { + return common.NewCLIArgParseError(fmt.Errorf("exactly one of --stackpack-directory or --stackpack-file must be specified")) + } + + // Prepare file to validate - if directory is provided, package it first + fileToValidate, cleanup, err := prepareStackpackFile(args) + if err != nil { + return err + } + defer cleanup() + + // Open the file + file, openErr := os.Open(fileToValidate) + if openErr != nil { + return common.NewRuntimeError(fmt.Errorf("failed to open stackpack file: %w", openErr)) + } + defer file.Close() + + // Call validate endpoint + result, resp, validateErr := api.StackpackApi.StackPackValidate(cli.Context).StackPack(file).Execute() + if validateErr != nil { + return common.NewResponseError(validateErr, resp) + } + + if cli.IsJson() { + cli.Printer.PrintJson(map[string]interface{}{ + "success": true, + "result": result, + }) + } else { + cli.Printer.Success("Stackpack validation successful!") + if result != "" { + fmt.Println(result) + } + } + + return nil + } +} + +// prepareStackpackFile returns the path to the stackpack file to validate. +// If a directory is provided, it packages it into a temporary .sts file. +// Returns the file path and a cleanup function that should be deferred. +func prepareStackpackFile(args *ValidateArgs) (string, func(), common.CLIError) { + if args.StackpackFile != "" { + // Use provided .sts file directly + if _, err := os.Stat(args.StackpackFile); err != nil { + return "", func() {}, common.NewRuntimeError(fmt.Errorf("failed to access stackpack file: %w", err)) + } + return args.StackpackFile, func() {}, nil + } + + // Package the directory + absDir, err := filepath.Abs(args.StackpackDir) + if err != nil { + return "", func() {}, common.NewRuntimeError(fmt.Errorf("failed to resolve stackpack directory: %w", err)) + } + + // Validate stackpack directory + if err := validateStackpackDirectory(absDir); err != nil { + return "", func() {}, common.NewCLIArgParseError(err) + } + + // Parse stackpack info + parser := &YamlParser{} + stackpackInfo, err := parser.Parse(filepath.Join(absDir, "stackpack.yaml")) + if err != nil { + return "", func() {}, common.NewRuntimeError(fmt.Errorf("failed to parse stackpack.yaml: %w", err)) + } + + // Create temporary .sts file + tmpFile, err := os.CreateTemp("", fmt.Sprintf("%s-*.sts", stackpackInfo.Name)) + if err != nil { + return "", func() {}, common.NewRuntimeError(fmt.Errorf("failed to create temporary file: %w", err)) + } + tmpFile.Close() + tmpPath := tmpFile.Name() + + // Package stackpack into temporary file + if err := createStackpackZip(absDir, tmpPath); err != nil { + os.Remove(tmpPath) // Clean up on error + return "", func() {}, common.NewRuntimeError(fmt.Errorf("failed to package stackpack: %w", err)) + } + + // Return cleanup function that removes the temporary file + cleanup := func() { + os.Remove(tmpPath) + } + + return tmpPath, cleanup, nil +} diff --git a/cmd/stackpack/stackpack_validate_test.go b/cmd/stackpack/stackpack_validate_test.go new file mode 100644 index 00000000..0ff0a068 --- /dev/null +++ b/cmd/stackpack/stackpack_validate_test.go @@ -0,0 +1,214 @@ +package stackpack + +import ( + "fmt" + "os" + "path/filepath" + "testing" + + "github.com/spf13/cobra" + "github.com/stackvista/stackstate-cli/internal/config" + "github.com/stackvista/stackstate-cli/internal/di" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +// setupValidateCmd creates a test command with API context +func setupValidateCmd(t *testing.T) (*di.MockDeps, *cobra.Command) { + cli := di.NewMockDeps(t) + cfg := &config.Config{ + CurrentContext: "test-context", + Contexts: []*config.NamedContext{ + { + Name: "test-context", + Context: &config.StsContext{ + URL: "https://test-server.example.com", + APIPath: "/api", + }, + }, + }, + } + cli.ConfigPath = filepath.Join(t.TempDir(), "config.yaml") + err := config.WriteConfig(cli.ConfigPath, cfg) + require.NoError(t, err) + + cmd := StackpackValidateCommand(&cli.Deps) + return &cli, cmd +} + +// createTestStackpackDir creates a minimal stackpack directory with required items +func createTestStackpackDir(t *testing.T, dir string, name string, version string) { + require.NoError(t, os.MkdirAll(filepath.Join(dir, "settings"), 0755)) + require.NoError(t, os.MkdirAll(filepath.Join(dir, "resources"), 0755)) + + stackpackConf := fmt.Sprintf(`name: "%s" +version: "%s" +`, name, version) + require.NoError(t, os.WriteFile(filepath.Join(dir, "stackpack.yaml"), []byte(stackpackConf), 0644)) + require.NoError(t, os.WriteFile(filepath.Join(dir, "README.md"), []byte("# Test Stackpack"), 0644)) +} + +// ===== Tests ===== + +func TestValidate_WithDirectory_AutoPackages(t *testing.T) { + cli, cmd := setupValidateCmd(t) + + tempDir, err := os.MkdirTemp("", "stackpack-validate-test-*") + require.NoError(t, err) + defer os.RemoveAll(tempDir) + + stackpackDir := filepath.Join(tempDir, "test-stackpack") + require.NoError(t, os.MkdirAll(stackpackDir, 0755)) + createTestStackpackDir(t, stackpackDir, "test-stackpack", "1.0.0") + + _, err = di.ExecuteCommandWithContext(&cli.Deps, cmd, "--stackpack-directory", stackpackDir) + require.NoError(t, err) + + // Verify success message + require.NotEmpty(t, *cli.MockPrinter.SuccessCalls) + successCall := (*cli.MockPrinter.SuccessCalls)[0] + assert.Contains(t, successCall, "validation successful") +} + +func TestValidate_WithDirectory_InvalidStackpack(t *testing.T) { + cli, cmd := setupValidateCmd(t) + + tempDir, err := os.MkdirTemp("", "stackpack-validate-test-*") + require.NoError(t, err) + defer os.RemoveAll(tempDir) + + // Create directory with missing required items + stackpackDir := filepath.Join(tempDir, "invalid-stackpack") + require.NoError(t, os.MkdirAll(stackpackDir, 0755)) + + _, err = di.ExecuteCommandWithContext(&cli.Deps, cmd, "--stackpack-directory", stackpackDir) + require.Error(t, err) + assert.Contains(t, err.Error(), "required stackpack item not found") +} + +func TestValidate_WithDirectory_MissingStackpackYaml(t *testing.T) { + cli, cmd := setupValidateCmd(t) + + tempDir, err := os.MkdirTemp("", "stackpack-validate-test-*") + require.NoError(t, err) + defer os.RemoveAll(tempDir) + + stackpackDir := filepath.Join(tempDir, "test-stackpack") + require.NoError(t, os.MkdirAll(filepath.Join(stackpackDir, "settings"), 0755)) + require.NoError(t, os.MkdirAll(filepath.Join(stackpackDir, "resources"), 0755)) + require.NoError(t, os.WriteFile(filepath.Join(stackpackDir, "README.md"), []byte("test"), 0644)) + + _, err = di.ExecuteCommandWithContext(&cli.Deps, cmd, "--stackpack-directory", stackpackDir) + require.Error(t, err) + assert.Contains(t, err.Error(), "required stackpack item not found") +} + +func TestValidate_WithPrePackagedFile(t *testing.T) { + cli, cmd := setupValidateCmd(t) + + tempDir, err := os.MkdirTemp("", "stackpack-validate-test-*") + require.NoError(t, err) + defer os.RemoveAll(tempDir) + + // Create a pre-packaged .sts file + stackpackFile := filepath.Join(tempDir, "test.sts") + require.NoError(t, os.WriteFile(stackpackFile, []byte("test stackpack content"), 0644)) + + _, err = di.ExecuteCommandWithContext(&cli.Deps, cmd, "--stackpack-file", stackpackFile) + require.NoError(t, err) + + // Verify success message + require.NotEmpty(t, *cli.MockPrinter.SuccessCalls) + successCall := (*cli.MockPrinter.SuccessCalls)[0] + assert.Contains(t, successCall, "validation successful") +} + +func TestValidate_JSONOutput(t *testing.T) { + cli, cmd := setupValidateCmd(t) + + tempDir, err := os.MkdirTemp("", "stackpack-validate-test-*") + require.NoError(t, err) + defer os.RemoveAll(tempDir) + + stackpackFile := filepath.Join(tempDir, "test.sts") + require.NoError(t, os.WriteFile(stackpackFile, []byte("test content"), 0644)) + + _, err = di.ExecuteCommandWithContext(&cli.Deps, cmd, "--stackpack-file", stackpackFile, "-o", "json") + require.NoError(t, err) + + // Verify JSON was called + require.Len(t, *cli.MockPrinter.PrintJsonCalls, 1) + jsonOutput := (*cli.MockPrinter.PrintJsonCalls)[0] + + assert.Equal(t, true, jsonOutput["success"]) +} + +func TestValidate_MissingPath(t *testing.T) { + cli, cmd := setupValidateCmd(t) + + _, err := di.ExecuteCommandWithContext(&cli.Deps, cmd) + require.Error(t, err) + assert.Contains(t, err.Error(), "exactly one of") +} + +func TestValidate_MutuallyExclusive(t *testing.T) { + cli, cmd := setupValidateCmd(t) + + tempDir, err := os.MkdirTemp("", "stackpack-validate-test-*") + require.NoError(t, err) + defer os.RemoveAll(tempDir) + + stackpackDir := filepath.Join(tempDir, "stackpack") + require.NoError(t, os.MkdirAll(stackpackDir, 0755)) + + stackpackFile := filepath.Join(tempDir, "test.sts") + require.NoError(t, os.WriteFile(stackpackFile, []byte("test"), 0644)) + + _, err = di.ExecuteCommandWithContext(&cli.Deps, cmd, + "-d", stackpackDir, + "-f", stackpackFile) + require.Error(t, err) + assert.Contains(t, err.Error(), "exactly one of") +} + +func TestValidate_NonexistentFile(t *testing.T) { + cli, cmd := setupValidateCmd(t) + + _, err := di.ExecuteCommandWithContext(&cli.Deps, cmd, "--stackpack-file", "/nonexistent/path/file.sts") + require.Error(t, err) + assert.Contains(t, err.Error(), "failed to access stackpack file") +} + +func TestValidate_WithDirectory_IncludingOptionalItems(t *testing.T) { + cli, cmd := setupValidateCmd(t) + + tempDir, err := os.MkdirTemp("", "stackpack-validate-test-*") + require.NoError(t, err) + defer os.RemoveAll(tempDir) + + stackpackDir := filepath.Join(tempDir, "test-stackpack") + require.NoError(t, os.MkdirAll(stackpackDir, 0755)) + createTestStackpackDir(t, stackpackDir, "test-stackpack", "1.0.0") + + // Add optional items + require.NoError(t, os.MkdirAll(filepath.Join(stackpackDir, "icons"), 0755)) + require.NoError(t, os.WriteFile(filepath.Join(stackpackDir, "icons", "icon.png"), []byte("fake png"), 0644)) + require.NoError(t, os.MkdirAll(filepath.Join(stackpackDir, "includes"), 0755)) + require.NoError(t, os.WriteFile(filepath.Join(stackpackDir, "includes", "include.txt"), []byte("include data"), 0644)) + + _, err = di.ExecuteCommandWithContext(&cli.Deps, cmd, "--stackpack-directory", stackpackDir) + require.NoError(t, err) + + // Verify success message + require.NotEmpty(t, *cli.MockPrinter.SuccessCalls) + successCall := (*cli.MockPrinter.SuccessCalls)[0] + assert.Contains(t, successCall, "validation successful") +} + +func TestValidate_NonexistentDirectory(t *testing.T) { + cli, cmd := setupValidateCmd(t) + + _, err := di.ExecuteCommandWithContext(&cli.Deps, cmd, "--stackpack-directory", "/nonexistent/stackpack/dir") + require.Error(t, err) + assert.Contains(t, err.Error(), "required stackpack item not found") +} diff --git a/generated/stackstate_api/README.md b/generated/stackstate_api/README.md index 3c5dc9a7..a0f7b0cf 100644 --- a/generated/stackstate_api/README.md +++ b/generated/stackstate_api/README.md @@ -227,6 +227,7 @@ Class | Method | HTTP request | Description *StackpackApi* | [**ProvisionUninstall**](docs/StackpackApi.md#provisionuninstall) | **Post** /stackpack/{stackPackName}/deprovision/{stackPackInstanceId} | Provision API *StackpackApi* | [**StackPackList**](docs/StackpackApi.md#stackpacklist) | **Get** /stackpack | StackPack API *StackpackApi* | [**StackPackUpload**](docs/StackpackApi.md#stackpackupload) | **Post** /stackpack | StackPack API +*StackpackApi* | [**StackPackValidate**](docs/StackpackApi.md#stackpackvalidate) | **Post** /stackpack/validate | Validate API *StackpackApi* | [**UpgradeStackPack**](docs/StackpackApi.md#upgradestackpack) | **Post** /stackpack/{stackPackName}/upgrade | Upgrade API *SubjectApi* | [**CreateSubject**](docs/SubjectApi.md#createsubject) | **Put** /security/subjects/{subject} | Create a subject *SubjectApi* | [**DeleteSubject**](docs/SubjectApi.md#deletesubject) | **Delete** /security/subjects/{subject} | Delete a subject diff --git a/generated/stackstate_api/api/openapi.yaml b/generated/stackstate_api/api/openapi.yaml index d5f64d5a..5f8522c4 100644 --- a/generated/stackstate_api/api/openapi.yaml +++ b/generated/stackstate_api/api/openapi.yaml @@ -364,6 +364,39 @@ paths: summary: StackPack API tags: - stackpack + /stackpack/validate: + post: + description: Validate a stackpack's setting declarations + operationId: stackPackValidate + requestBody: + content: + multipart/form-data: + schema: + $ref: '#/components/schemas/StackPackUpload' + responses: + "200": + content: + application/json: + schema: + type: string + description: validation successful + "400": + content: + application/json: + schema: + items: + type: string + type: array + description: bad request + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/GenericErrorsResponse' + description: Error when handling the request on the server side. + summary: Validate API + tags: + - stackpack /stackpack/{stackPackName}/provision: post: description: Provision details @@ -9054,8 +9087,8 @@ components: dummy: true component: identifier: identifier - iconbase64: iconbase64 name: name + icon: icon id: 1 type: type troubleshootingSteps: troubleshootingSteps @@ -9187,8 +9220,8 @@ components: MonitorCheckStatusComponent: example: identifier: identifier - iconbase64: iconbase64 name: name + icon: icon id: 1 type: type properties: @@ -9201,7 +9234,7 @@ components: type: string type: type: string - iconbase64: + icon: type: string required: - id @@ -9235,8 +9268,8 @@ components: - identifier: identifier component: identifier: identifier - iconbase64: iconbase64 name: name + icon: icon id: 1 type: type triggeredTimestamp: 1 @@ -9248,8 +9281,8 @@ components: - identifier: identifier component: identifier: identifier - iconbase64: iconbase64 name: name + icon: icon id: 1 type: type triggeredTimestamp: 1 @@ -9277,8 +9310,8 @@ components: identifier: identifier component: identifier: identifier - iconbase64: iconbase64 name: name + icon: icon id: 1 type: type triggeredTimestamp: 1 @@ -10311,7 +10344,7 @@ components: items: type: string type: array - iconbase64: + icon: type: string required: - _type @@ -13904,8 +13937,8 @@ components: tags: - tags - tags - iconbase64: iconbase64 typeName: typeName + icon: icon boundTraces: filter: traceId: @@ -14002,7 +14035,7 @@ components: properties: typeName: type: string - iconbase64: + icon: type: string data: $ref: '#/components/schemas/ComponentData' @@ -15021,8 +15054,8 @@ components: tags: - tags - tags - iconbase64: iconbase64 typeName: typeName + icon: icon boundTraces: filter: traceId: @@ -15209,8 +15242,8 @@ components: tags: - tags - tags - iconbase64: iconbase64 typeName: typeName + icon: icon boundTraces: filter: traceId: @@ -17023,11 +17056,11 @@ components: presentation: overview: mainMenu: - iconbase64: iconbase64 + icon: icon group: group order: 0.8008281904610115 title: title - iconbase64: iconbase64 + icon: icon name: plural: plural singular: singular @@ -17056,16 +17089,16 @@ components: example: overview: mainMenu: - iconbase64: iconbase64 + icon: icon group: group order: 0.8008281904610115 title: title - iconbase64: iconbase64 + icon: icon name: plural: plural singular: singular properties: - iconbase64: + icon: type: string name: $ref: '#/components/schemas/PresentationName' @@ -17088,7 +17121,7 @@ components: PresentationOverview: example: mainMenu: - iconbase64: iconbase64 + icon: icon group: group order: 0.8008281904610115 title: title @@ -17102,13 +17135,13 @@ components: type: object PresentationMainMenu: example: - iconbase64: iconbase64 + icon: icon group: group order: 0.8008281904610115 properties: group: type: string - iconbase64: + icon: type: string order: format: double @@ -17127,16 +17160,16 @@ components: MainMenuGroup: example: identifier: identifier - iconbase64: iconbase64 name: name + icon: icon description: description defaultOpen: true items: - identifier: identifier - iconbase64: iconbase64 + icon: icon title: title - identifier: identifier - iconbase64: iconbase64 + icon: icon title: title properties: name: @@ -17147,7 +17180,7 @@ components: type: string defaultOpen: type: boolean - iconbase64: + icon: type: string items: items: @@ -17155,13 +17188,13 @@ components: type: array required: - defaultOpen - - iconbase64 + - icon - items - name MainMenuViewItem: example: identifier: identifier - iconbase64: iconbase64 + icon: icon title: title properties: identifier: @@ -17169,7 +17202,7 @@ components: type: string title: type: string - iconbase64: + icon: type: string required: - identifier diff --git a/generated/stackstate_api/api_stackpack.go b/generated/stackstate_api/api_stackpack.go index 8ebe39cf..1f51f4f0 100644 --- a/generated/stackstate_api/api_stackpack.go +++ b/generated/stackstate_api/api_stackpack.go @@ -98,6 +98,20 @@ type StackpackApi interface { // @return StackPack StackPackUploadExecute(r ApiStackPackUploadRequest) (*StackPack, *http.Response, error) + /* + StackPackValidate Validate API + + Validate a stackpack's setting declarations + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return ApiStackPackValidateRequest + */ + StackPackValidate(ctx context.Context) ApiStackPackValidateRequest + + // StackPackValidateExecute executes the request + // @return string + StackPackValidateExecute(r ApiStackPackValidateRequest) (string, *http.Response, error) + /* UpgradeStackPack Upgrade API @@ -963,6 +977,190 @@ func (a *StackpackApiService) StackPackUploadExecute(r ApiStackPackUploadRequest return localVarReturnValue, localVarHTTPResponse, nil } +type ApiStackPackValidateRequest struct { + ctx context.Context + ApiService StackpackApi + stackPack **os.File +} + +func (r ApiStackPackValidateRequest) StackPack(stackPack *os.File) ApiStackPackValidateRequest { + r.stackPack = &stackPack + return r +} + +func (r ApiStackPackValidateRequest) Execute() (string, *http.Response, error) { + return r.ApiService.StackPackValidateExecute(r) +} + +/* +StackPackValidate Validate API + +Validate a stackpack's setting declarations + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return ApiStackPackValidateRequest +*/ +func (a *StackpackApiService) StackPackValidate(ctx context.Context) ApiStackPackValidateRequest { + return ApiStackPackValidateRequest{ + ApiService: a, + ctx: ctx, + } +} + +// Execute executes the request +// +// @return string +func (a *StackpackApiService) StackPackValidateExecute(r ApiStackPackValidateRequest) (string, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue string + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "StackpackApiService.StackPackValidate") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/stackpack/validate" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"multipart/form-data"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + var stackPackLocalVarFormFileName string + var stackPackLocalVarFileName string + var stackPackLocalVarFileBytes []byte + + stackPackLocalVarFormFileName = "stackPack" + + var stackPackLocalVarFile *os.File + if r.stackPack != nil { + stackPackLocalVarFile = *r.stackPack + } + if stackPackLocalVarFile != nil { + fbs, _ := ioutil.ReadAll(stackPackLocalVarFile) + stackPackLocalVarFileBytes = fbs + stackPackLocalVarFileName = stackPackLocalVarFile.Name() + stackPackLocalVarFile.Close() + } + formFiles = append(formFiles, formFile{fileBytes: stackPackLocalVarFileBytes, fileName: stackPackLocalVarFileName, formFileName: stackPackLocalVarFormFileName}) + if r.ctx != nil { + // API Key Authentication + if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { + if apiKey, ok := auth["ApiToken"]; ok { + var key string + if apiKey.Prefix != "" { + key = apiKey.Prefix + " " + apiKey.Key + } else { + key = apiKey.Key + } + localVarHeaderParams["X-API-Token"] = key + } + } + } + if r.ctx != nil { + // API Key Authentication + if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { + if apiKey, ok := auth["ServiceBearer"]; ok { + var key string + if apiKey.Prefix != "" { + key = apiKey.Prefix + " " + apiKey.Key + } else { + key = apiKey.Key + } + localVarHeaderParams["X-API-ServiceBearer"] = key + } + } + } + if r.ctx != nil { + // API Key Authentication + if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { + if apiKey, ok := auth["ServiceToken"]; ok { + var key string + if apiKey.Prefix != "" { + key = apiKey.Prefix + " " + apiKey.Key + } else { + key = apiKey.Key + } + localVarHeaderParams["X-API-Key"] = key + } + } + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v []string + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 500 { + var v GenericErrorsResponse + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.model = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + type ApiUpgradeStackPackRequest struct { ctx context.Context ApiService StackpackApi @@ -1143,6 +1341,8 @@ type StackpackApiMock struct { StackPackListResponse StackPackListMockResponse StackPackUploadCalls *[]StackPackUploadCall StackPackUploadResponse StackPackUploadMockResponse + StackPackValidateCalls *[]StackPackValidateCall + StackPackValidateResponse StackPackValidateMockResponse UpgradeStackPackCalls *[]UpgradeStackPackCall UpgradeStackPackResponse UpgradeStackPackMockResponse } @@ -1153,6 +1353,7 @@ func NewStackpackApiMock() StackpackApiMock { xProvisionUninstallCalls := make([]ProvisionUninstallCall, 0) xStackPackListCalls := make([]StackPackListCall, 0) xStackPackUploadCalls := make([]StackPackUploadCall, 0) + xStackPackValidateCalls := make([]StackPackValidateCall, 0) xUpgradeStackPackCalls := make([]UpgradeStackPackCall, 0) return StackpackApiMock{ ConfirmManualStepsCalls: &xConfirmManualStepsCalls, @@ -1160,6 +1361,7 @@ func NewStackpackApiMock() StackpackApiMock { ProvisionUninstallCalls: &xProvisionUninstallCalls, StackPackListCalls: &xStackPackListCalls, StackPackUploadCalls: &xStackPackUploadCalls, + StackPackValidateCalls: &xStackPackValidateCalls, UpgradeStackPackCalls: &xUpgradeStackPackCalls, } } @@ -1299,6 +1501,31 @@ func (mock StackpackApiMock) StackPackUploadExecute(r ApiStackPackUploadRequest) return &mock.StackPackUploadResponse.Result, mock.StackPackUploadResponse.Response, mock.StackPackUploadResponse.Error } +type StackPackValidateMockResponse struct { + Result string + Response *http.Response + Error error +} + +type StackPackValidateCall struct { + PstackPack **os.File +} + +func (mock StackpackApiMock) StackPackValidate(ctx context.Context) ApiStackPackValidateRequest { + return ApiStackPackValidateRequest{ + ApiService: mock, + ctx: ctx, + } +} + +func (mock StackpackApiMock) StackPackValidateExecute(r ApiStackPackValidateRequest) (string, *http.Response, error) { + p := StackPackValidateCall{ + PstackPack: r.stackPack, + } + *mock.StackPackValidateCalls = append(*mock.StackPackValidateCalls, p) + return mock.StackPackValidateResponse.Result, mock.StackPackValidateResponse.Response, mock.StackPackValidateResponse.Error +} + type UpgradeStackPackMockResponse struct { Result string Response *http.Response diff --git a/generated/stackstate_api/docs/EventComponent.md b/generated/stackstate_api/docs/EventComponent.md index 39f16d41..16155b1a 100644 --- a/generated/stackstate_api/docs/EventComponent.md +++ b/generated/stackstate_api/docs/EventComponent.md @@ -9,7 +9,7 @@ Name | Type | Description | Notes **TypeName** | **string** | | **Name** | **string** | | **Identifiers** | **[]string** | | -**Iconbase64** | Pointer to **string** | | [optional] +**Icon** | Pointer to **string** | | [optional] ## Methods @@ -130,30 +130,30 @@ and a boolean to check if the value has been set. SetIdentifiers sets Identifiers field to given value. -### GetIconbase64 +### GetIcon -`func (o *EventComponent) GetIconbase64() string` +`func (o *EventComponent) GetIcon() string` -GetIconbase64 returns the Iconbase64 field if non-nil, zero value otherwise. +GetIcon returns the Icon field if non-nil, zero value otherwise. -### GetIconbase64Ok +### GetIconOk -`func (o *EventComponent) GetIconbase64Ok() (*string, bool)` +`func (o *EventComponent) GetIconOk() (*string, bool)` -GetIconbase64Ok returns a tuple with the Iconbase64 field if it's non-nil, zero value otherwise +GetIconOk returns a tuple with the Icon field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. -### SetIconbase64 +### SetIcon -`func (o *EventComponent) SetIconbase64(v string)` +`func (o *EventComponent) SetIcon(v string)` -SetIconbase64 sets Iconbase64 field to given value. +SetIcon sets Icon field to given value. -### HasIconbase64 +### HasIcon -`func (o *EventComponent) HasIconbase64() bool` +`func (o *EventComponent) HasIcon() bool` -HasIconbase64 returns a boolean if a field has been set. +HasIcon returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/generated/stackstate_api/docs/EventElement.md b/generated/stackstate_api/docs/EventElement.md index 5324aa95..cc2e6e4f 100644 --- a/generated/stackstate_api/docs/EventElement.md +++ b/generated/stackstate_api/docs/EventElement.md @@ -9,7 +9,7 @@ Name | Type | Description | Notes **TypeName** | **string** | | **Name** | **string** | | **Identifiers** | **[]string** | | -**Iconbase64** | Pointer to **string** | | [optional] +**Icon** | Pointer to **string** | | [optional] **Source** | [**EventComponent**](EventComponent.md) | | **Target** | [**EventComponent**](EventComponent.md) | | **DependencyDirection** | [**DependencyDirection**](DependencyDirection.md) | | @@ -133,30 +133,30 @@ and a boolean to check if the value has been set. SetIdentifiers sets Identifiers field to given value. -### GetIconbase64 +### GetIcon -`func (o *EventElement) GetIconbase64() string` +`func (o *EventElement) GetIcon() string` -GetIconbase64 returns the Iconbase64 field if non-nil, zero value otherwise. +GetIcon returns the Icon field if non-nil, zero value otherwise. -### GetIconbase64Ok +### GetIconOk -`func (o *EventElement) GetIconbase64Ok() (*string, bool)` +`func (o *EventElement) GetIconOk() (*string, bool)` -GetIconbase64Ok returns a tuple with the Iconbase64 field if it's non-nil, zero value otherwise +GetIconOk returns a tuple with the Icon field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. -### SetIconbase64 +### SetIcon -`func (o *EventElement) SetIconbase64(v string)` +`func (o *EventElement) SetIcon(v string)` -SetIconbase64 sets Iconbase64 field to given value. +SetIcon sets Icon field to given value. -### HasIconbase64 +### HasIcon -`func (o *EventElement) HasIconbase64() bool` +`func (o *EventElement) HasIcon() bool` -HasIconbase64 returns a boolean if a field has been set. +HasIcon returns a boolean if a field has been set. ### GetSource diff --git a/generated/stackstate_api/docs/FullComponent.md b/generated/stackstate_api/docs/FullComponent.md index eb30f6ad..8926a619 100644 --- a/generated/stackstate_api/docs/FullComponent.md +++ b/generated/stackstate_api/docs/FullComponent.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **TypeName** | **string** | | -**Iconbase64** | Pointer to **string** | | [optional] +**Icon** | Pointer to **string** | | [optional] **Data** | [**ComponentData**](ComponentData.md) | | **Highlights** | Pointer to [**ComponentTypeHighlights**](ComponentTypeHighlights.md) | | [optional] **Actions** | [**[]ComponentAction**](ComponentAction.md) | | @@ -51,30 +51,30 @@ and a boolean to check if the value has been set. SetTypeName sets TypeName field to given value. -### GetIconbase64 +### GetIcon -`func (o *FullComponent) GetIconbase64() string` +`func (o *FullComponent) GetIcon() string` -GetIconbase64 returns the Iconbase64 field if non-nil, zero value otherwise. +GetIcon returns the Icon field if non-nil, zero value otherwise. -### GetIconbase64Ok +### GetIconOk -`func (o *FullComponent) GetIconbase64Ok() (*string, bool)` +`func (o *FullComponent) GetIconOk() (*string, bool)` -GetIconbase64Ok returns a tuple with the Iconbase64 field if it's non-nil, zero value otherwise +GetIconOk returns a tuple with the Icon field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. -### SetIconbase64 +### SetIcon -`func (o *FullComponent) SetIconbase64(v string)` +`func (o *FullComponent) SetIcon(v string)` -SetIconbase64 sets Iconbase64 field to given value. +SetIcon sets Icon field to given value. -### HasIconbase64 +### HasIcon -`func (o *FullComponent) HasIconbase64() bool` +`func (o *FullComponent) HasIcon() bool` -HasIconbase64 returns a boolean if a field has been set. +HasIcon returns a boolean if a field has been set. ### GetData diff --git a/generated/stackstate_api/docs/MainMenuGroup.md b/generated/stackstate_api/docs/MainMenuGroup.md index a5d04102..56aebc45 100644 --- a/generated/stackstate_api/docs/MainMenuGroup.md +++ b/generated/stackstate_api/docs/MainMenuGroup.md @@ -8,14 +8,14 @@ Name | Type | Description | Notes **Identifier** | Pointer to **string** | | [optional] **Description** | Pointer to **string** | | [optional] **DefaultOpen** | **bool** | | -**Iconbase64** | **string** | | +**Icon** | **string** | | **Items** | [**[]MainMenuViewItem**](MainMenuViewItem.md) | | ## Methods ### NewMainMenuGroup -`func NewMainMenuGroup(name string, defaultOpen bool, iconbase64 string, items []MainMenuViewItem, ) *MainMenuGroup` +`func NewMainMenuGroup(name string, defaultOpen bool, icon string, items []MainMenuViewItem, ) *MainMenuGroup` NewMainMenuGroup instantiates a new MainMenuGroup object This constructor will assign default values to properties that have it defined, @@ -120,24 +120,24 @@ and a boolean to check if the value has been set. SetDefaultOpen sets DefaultOpen field to given value. -### GetIconbase64 +### GetIcon -`func (o *MainMenuGroup) GetIconbase64() string` +`func (o *MainMenuGroup) GetIcon() string` -GetIconbase64 returns the Iconbase64 field if non-nil, zero value otherwise. +GetIcon returns the Icon field if non-nil, zero value otherwise. -### GetIconbase64Ok +### GetIconOk -`func (o *MainMenuGroup) GetIconbase64Ok() (*string, bool)` +`func (o *MainMenuGroup) GetIconOk() (*string, bool)` -GetIconbase64Ok returns a tuple with the Iconbase64 field if it's non-nil, zero value otherwise +GetIconOk returns a tuple with the Icon field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. -### SetIconbase64 +### SetIcon -`func (o *MainMenuGroup) SetIconbase64(v string)` +`func (o *MainMenuGroup) SetIcon(v string)` -SetIconbase64 sets Iconbase64 field to given value. +SetIcon sets Icon field to given value. ### GetItems diff --git a/generated/stackstate_api/docs/MainMenuViewItem.md b/generated/stackstate_api/docs/MainMenuViewItem.md index 5e5cee1c..e1b246d0 100644 --- a/generated/stackstate_api/docs/MainMenuViewItem.md +++ b/generated/stackstate_api/docs/MainMenuViewItem.md @@ -6,7 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **Identifier** | **string** | Either a viewIdentifier or a componentPresentationIdentifier | **Title** | **string** | | -**Iconbase64** | Pointer to **string** | | [optional] +**Icon** | Pointer to **string** | | [optional] ## Methods @@ -67,30 +67,30 @@ and a boolean to check if the value has been set. SetTitle sets Title field to given value. -### GetIconbase64 +### GetIcon -`func (o *MainMenuViewItem) GetIconbase64() string` +`func (o *MainMenuViewItem) GetIcon() string` -GetIconbase64 returns the Iconbase64 field if non-nil, zero value otherwise. +GetIcon returns the Icon field if non-nil, zero value otherwise. -### GetIconbase64Ok +### GetIconOk -`func (o *MainMenuViewItem) GetIconbase64Ok() (*string, bool)` +`func (o *MainMenuViewItem) GetIconOk() (*string, bool)` -GetIconbase64Ok returns a tuple with the Iconbase64 field if it's non-nil, zero value otherwise +GetIconOk returns a tuple with the Icon field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. -### SetIconbase64 +### SetIcon -`func (o *MainMenuViewItem) SetIconbase64(v string)` +`func (o *MainMenuViewItem) SetIcon(v string)` -SetIconbase64 sets Iconbase64 field to given value. +SetIcon sets Icon field to given value. -### HasIconbase64 +### HasIcon -`func (o *MainMenuViewItem) HasIconbase64() bool` +`func (o *MainMenuViewItem) HasIcon() bool` -HasIconbase64 returns a boolean if a field has been set. +HasIcon returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/generated/stackstate_api/docs/MonitorCheckStatusComponent.md b/generated/stackstate_api/docs/MonitorCheckStatusComponent.md index eb6b842e..c3902f76 100644 --- a/generated/stackstate_api/docs/MonitorCheckStatusComponent.md +++ b/generated/stackstate_api/docs/MonitorCheckStatusComponent.md @@ -8,7 +8,7 @@ Name | Type | Description | Notes **Identifier** | **string** | | **Name** | **string** | | **Type** | **string** | | -**Iconbase64** | Pointer to **string** | | [optional] +**Icon** | Pointer to **string** | | [optional] ## Methods @@ -109,30 +109,30 @@ and a boolean to check if the value has been set. SetType sets Type field to given value. -### GetIconbase64 +### GetIcon -`func (o *MonitorCheckStatusComponent) GetIconbase64() string` +`func (o *MonitorCheckStatusComponent) GetIcon() string` -GetIconbase64 returns the Iconbase64 field if non-nil, zero value otherwise. +GetIcon returns the Icon field if non-nil, zero value otherwise. -### GetIconbase64Ok +### GetIconOk -`func (o *MonitorCheckStatusComponent) GetIconbase64Ok() (*string, bool)` +`func (o *MonitorCheckStatusComponent) GetIconOk() (*string, bool)` -GetIconbase64Ok returns a tuple with the Iconbase64 field if it's non-nil, zero value otherwise +GetIconOk returns a tuple with the Icon field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. -### SetIconbase64 +### SetIcon -`func (o *MonitorCheckStatusComponent) SetIconbase64(v string)` +`func (o *MonitorCheckStatusComponent) SetIcon(v string)` -SetIconbase64 sets Iconbase64 field to given value. +SetIcon sets Icon field to given value. -### HasIconbase64 +### HasIcon -`func (o *MonitorCheckStatusComponent) HasIconbase64() bool` +`func (o *MonitorCheckStatusComponent) HasIcon() bool` -HasIconbase64 returns a boolean if a field has been set. +HasIcon returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/generated/stackstate_api/docs/PresentationDefinition.md b/generated/stackstate_api/docs/PresentationDefinition.md index 3a9f9fb5..ea74496b 100644 --- a/generated/stackstate_api/docs/PresentationDefinition.md +++ b/generated/stackstate_api/docs/PresentationDefinition.md @@ -4,7 +4,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Iconbase64** | Pointer to **string** | | [optional] +**Icon** | Pointer to **string** | | [optional] **Name** | Pointer to [**PresentationName**](PresentationName.md) | | [optional] **Overview** | Pointer to [**PresentationOverview**](PresentationOverview.md) | | [optional] @@ -27,30 +27,30 @@ NewPresentationDefinitionWithDefaults instantiates a new PresentationDefinition This constructor will only assign default values to properties that have it defined, but it doesn't guarantee that properties required by API are set -### GetIconbase64 +### GetIcon -`func (o *PresentationDefinition) GetIconbase64() string` +`func (o *PresentationDefinition) GetIcon() string` -GetIconbase64 returns the Iconbase64 field if non-nil, zero value otherwise. +GetIcon returns the Icon field if non-nil, zero value otherwise. -### GetIconbase64Ok +### GetIconOk -`func (o *PresentationDefinition) GetIconbase64Ok() (*string, bool)` +`func (o *PresentationDefinition) GetIconOk() (*string, bool)` -GetIconbase64Ok returns a tuple with the Iconbase64 field if it's non-nil, zero value otherwise +GetIconOk returns a tuple with the Icon field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. -### SetIconbase64 +### SetIcon -`func (o *PresentationDefinition) SetIconbase64(v string)` +`func (o *PresentationDefinition) SetIcon(v string)` -SetIconbase64 sets Iconbase64 field to given value. +SetIcon sets Icon field to given value. -### HasIconbase64 +### HasIcon -`func (o *PresentationDefinition) HasIconbase64() bool` +`func (o *PresentationDefinition) HasIcon() bool` -HasIconbase64 returns a boolean if a field has been set. +HasIcon returns a boolean if a field has been set. ### GetName diff --git a/generated/stackstate_api/docs/PresentationMainMenu.md b/generated/stackstate_api/docs/PresentationMainMenu.md index c9b46c41..2a4f6c47 100644 --- a/generated/stackstate_api/docs/PresentationMainMenu.md +++ b/generated/stackstate_api/docs/PresentationMainMenu.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **Group** | **string** | | -**Iconbase64** | Pointer to **string** | | [optional] +**Icon** | Pointer to **string** | | [optional] **Order** | **float64** | | ## Methods @@ -47,30 +47,30 @@ and a boolean to check if the value has been set. SetGroup sets Group field to given value. -### GetIconbase64 +### GetIcon -`func (o *PresentationMainMenu) GetIconbase64() string` +`func (o *PresentationMainMenu) GetIcon() string` -GetIconbase64 returns the Iconbase64 field if non-nil, zero value otherwise. +GetIcon returns the Icon field if non-nil, zero value otherwise. -### GetIconbase64Ok +### GetIconOk -`func (o *PresentationMainMenu) GetIconbase64Ok() (*string, bool)` +`func (o *PresentationMainMenu) GetIconOk() (*string, bool)` -GetIconbase64Ok returns a tuple with the Iconbase64 field if it's non-nil, zero value otherwise +GetIconOk returns a tuple with the Icon field if it's non-nil, zero value otherwise and a boolean to check if the value has been set. -### SetIconbase64 +### SetIcon -`func (o *PresentationMainMenu) SetIconbase64(v string)` +`func (o *PresentationMainMenu) SetIcon(v string)` -SetIconbase64 sets Iconbase64 field to given value. +SetIcon sets Icon field to given value. -### HasIconbase64 +### HasIcon -`func (o *PresentationMainMenu) HasIconbase64() bool` +`func (o *PresentationMainMenu) HasIcon() bool` -HasIconbase64 returns a boolean if a field has been set. +HasIcon returns a boolean if a field has been set. ### GetOrder diff --git a/generated/stackstate_api/docs/StackpackApi.md b/generated/stackstate_api/docs/StackpackApi.md index 9c4fc4de..00613e7f 100644 --- a/generated/stackstate_api/docs/StackpackApi.md +++ b/generated/stackstate_api/docs/StackpackApi.md @@ -9,6 +9,7 @@ Method | HTTP request | Description [**ProvisionUninstall**](StackpackApi.md#ProvisionUninstall) | **Post** /stackpack/{stackPackName}/deprovision/{stackPackInstanceId} | Provision API [**StackPackList**](StackpackApi.md#StackPackList) | **Get** /stackpack | StackPack API [**StackPackUpload**](StackpackApi.md#StackPackUpload) | **Post** /stackpack | StackPack API +[**StackPackValidate**](StackpackApi.md#StackPackValidate) | **Post** /stackpack/validate | Validate API [**UpgradeStackPack**](StackpackApi.md#UpgradeStackPack) | **Post** /stackpack/{stackPackName}/upgrade | Upgrade API @@ -360,6 +361,72 @@ Name | Type | Description | Notes [[Back to README]](../README.md) +## StackPackValidate + +> string StackPackValidate(ctx).StackPack(stackPack).Execute() + +Validate API + + + +### Example + +```go +package main + +import ( + "context" + "fmt" + "os" + openapiclient "./openapi" +) + +func main() { + stackPack := os.NewFile(1234, "some_file") // *os.File | (optional) + + configuration := openapiclient.NewConfiguration() + apiClient := openapiclient.NewAPIClient(configuration) + resp, r, err := apiClient.StackpackApi.StackPackValidate(context.Background()).StackPack(stackPack).Execute() + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `StackpackApi.StackPackValidate``: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + // response from `StackPackValidate`: string + fmt.Fprintf(os.Stdout, "Response from `StackpackApi.StackPackValidate`: %v\n", resp) +} +``` + +### Path Parameters + + + +### Other Parameters + +Other parameters are passed through a pointer to a apiStackPackValidateRequest struct via the builder pattern + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **stackPack** | ***os.File** | | + +### Return type + +**string** + +### Authorization + +[ApiToken](../README.md#ApiToken), [ServiceBearer](../README.md#ServiceBearer), [ServiceToken](../README.md#ServiceToken) + +### HTTP request headers + +- **Content-Type**: multipart/form-data +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) +[[Back to Model list]](../README.md#documentation-for-models) +[[Back to README]](../README.md) + + ## UpgradeStackPack > string UpgradeStackPack(ctx, stackPackName).Unlocked(unlocked).Execute() diff --git a/generated/stackstate_api/model_event_component.go b/generated/stackstate_api/model_event_component.go index 17ced566..60e87144 100644 --- a/generated/stackstate_api/model_event_component.go +++ b/generated/stackstate_api/model_event_component.go @@ -22,7 +22,7 @@ type EventComponent struct { TypeName string `json:"typeName" yaml:"typeName"` Name string `json:"name" yaml:"name"` Identifiers []string `json:"identifiers" yaml:"identifiers"` - Iconbase64 *string `json:"iconbase64,omitempty" yaml:"iconbase64,omitempty"` + Icon *string `json:"icon,omitempty" yaml:"icon,omitempty"` } // NewEventComponent instantiates a new EventComponent object @@ -167,36 +167,36 @@ func (o *EventComponent) SetIdentifiers(v []string) { o.Identifiers = v } -// GetIconbase64 returns the Iconbase64 field value if set, zero value otherwise. -func (o *EventComponent) GetIconbase64() string { - if o == nil || o.Iconbase64 == nil { +// GetIcon returns the Icon field value if set, zero value otherwise. +func (o *EventComponent) GetIcon() string { + if o == nil || o.Icon == nil { var ret string return ret } - return *o.Iconbase64 + return *o.Icon } -// GetIconbase64Ok returns a tuple with the Iconbase64 field value if set, nil otherwise +// GetIconOk returns a tuple with the Icon field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *EventComponent) GetIconbase64Ok() (*string, bool) { - if o == nil || o.Iconbase64 == nil { +func (o *EventComponent) GetIconOk() (*string, bool) { + if o == nil || o.Icon == nil { return nil, false } - return o.Iconbase64, true + return o.Icon, true } -// HasIconbase64 returns a boolean if a field has been set. -func (o *EventComponent) HasIconbase64() bool { - if o != nil && o.Iconbase64 != nil { +// HasIcon returns a boolean if a field has been set. +func (o *EventComponent) HasIcon() bool { + if o != nil && o.Icon != nil { return true } return false } -// SetIconbase64 gets a reference to the given string and assigns it to the Iconbase64 field. -func (o *EventComponent) SetIconbase64(v string) { - o.Iconbase64 = &v +// SetIcon gets a reference to the given string and assigns it to the Icon field. +func (o *EventComponent) SetIcon(v string) { + o.Icon = &v } func (o EventComponent) MarshalJSON() ([]byte, error) { @@ -216,8 +216,8 @@ func (o EventComponent) MarshalJSON() ([]byte, error) { if true { toSerialize["identifiers"] = o.Identifiers } - if o.Iconbase64 != nil { - toSerialize["iconbase64"] = o.Iconbase64 + if o.Icon != nil { + toSerialize["icon"] = o.Icon } return json.Marshal(toSerialize) } diff --git a/generated/stackstate_api/model_full_component.go b/generated/stackstate_api/model_full_component.go index 26ad426f..1019577c 100644 --- a/generated/stackstate_api/model_full_component.go +++ b/generated/stackstate_api/model_full_component.go @@ -18,7 +18,7 @@ import ( // FullComponent struct for FullComponent type FullComponent struct { TypeName string `json:"typeName" yaml:"typeName"` - Iconbase64 *string `json:"iconbase64,omitempty" yaml:"iconbase64,omitempty"` + Icon *string `json:"icon,omitempty" yaml:"icon,omitempty"` Data ComponentData `json:"data" yaml:"data"` Highlights *ComponentTypeHighlights `json:"highlights,omitempty" yaml:"highlights,omitempty"` Actions []ComponentAction `json:"actions" yaml:"actions"` @@ -71,36 +71,36 @@ func (o *FullComponent) SetTypeName(v string) { o.TypeName = v } -// GetIconbase64 returns the Iconbase64 field value if set, zero value otherwise. -func (o *FullComponent) GetIconbase64() string { - if o == nil || o.Iconbase64 == nil { +// GetIcon returns the Icon field value if set, zero value otherwise. +func (o *FullComponent) GetIcon() string { + if o == nil || o.Icon == nil { var ret string return ret } - return *o.Iconbase64 + return *o.Icon } -// GetIconbase64Ok returns a tuple with the Iconbase64 field value if set, nil otherwise +// GetIconOk returns a tuple with the Icon field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *FullComponent) GetIconbase64Ok() (*string, bool) { - if o == nil || o.Iconbase64 == nil { +func (o *FullComponent) GetIconOk() (*string, bool) { + if o == nil || o.Icon == nil { return nil, false } - return o.Iconbase64, true + return o.Icon, true } -// HasIconbase64 returns a boolean if a field has been set. -func (o *FullComponent) HasIconbase64() bool { - if o != nil && o.Iconbase64 != nil { +// HasIcon returns a boolean if a field has been set. +func (o *FullComponent) HasIcon() bool { + if o != nil && o.Icon != nil { return true } return false } -// SetIconbase64 gets a reference to the given string and assigns it to the Iconbase64 field. -func (o *FullComponent) SetIconbase64(v string) { - o.Iconbase64 = &v +// SetIcon gets a reference to the given string and assigns it to the Icon field. +func (o *FullComponent) SetIcon(v string) { + o.Icon = &v } // GetData returns the Data field value @@ -244,8 +244,8 @@ func (o FullComponent) MarshalJSON() ([]byte, error) { if true { toSerialize["typeName"] = o.TypeName } - if o.Iconbase64 != nil { - toSerialize["iconbase64"] = o.Iconbase64 + if o.Icon != nil { + toSerialize["icon"] = o.Icon } if true { toSerialize["data"] = o.Data diff --git a/generated/stackstate_api/model_main_menu_group.go b/generated/stackstate_api/model_main_menu_group.go index 351f2508..cd2bfb1a 100644 --- a/generated/stackstate_api/model_main_menu_group.go +++ b/generated/stackstate_api/model_main_menu_group.go @@ -21,7 +21,7 @@ type MainMenuGroup struct { Identifier *string `json:"identifier,omitempty" yaml:"identifier,omitempty"` Description *string `json:"description,omitempty" yaml:"description,omitempty"` DefaultOpen bool `json:"defaultOpen" yaml:"defaultOpen"` - Iconbase64 string `json:"iconbase64" yaml:"iconbase64"` + Icon string `json:"icon" yaml:"icon"` Items []MainMenuViewItem `json:"items" yaml:"items"` } @@ -29,11 +29,11 @@ type MainMenuGroup struct { // This constructor will assign default values to properties that have it defined, // and makes sure properties required by API are set, but the set of arguments // will change when the set of required properties is changed -func NewMainMenuGroup(name string, defaultOpen bool, iconbase64 string, items []MainMenuViewItem) *MainMenuGroup { +func NewMainMenuGroup(name string, defaultOpen bool, icon string, items []MainMenuViewItem) *MainMenuGroup { this := MainMenuGroup{} this.Name = name this.DefaultOpen = defaultOpen - this.Iconbase64 = iconbase64 + this.Icon = icon this.Items = items return &this } @@ -158,28 +158,28 @@ func (o *MainMenuGroup) SetDefaultOpen(v bool) { o.DefaultOpen = v } -// GetIconbase64 returns the Iconbase64 field value -func (o *MainMenuGroup) GetIconbase64() string { +// GetIcon returns the Icon field value +func (o *MainMenuGroup) GetIcon() string { if o == nil { var ret string return ret } - return o.Iconbase64 + return o.Icon } -// GetIconbase64Ok returns a tuple with the Iconbase64 field value +// GetIconOk returns a tuple with the Icon field value // and a boolean to check if the value has been set. -func (o *MainMenuGroup) GetIconbase64Ok() (*string, bool) { +func (o *MainMenuGroup) GetIconOk() (*string, bool) { if o == nil { return nil, false } - return &o.Iconbase64, true + return &o.Icon, true } -// SetIconbase64 sets field value -func (o *MainMenuGroup) SetIconbase64(v string) { - o.Iconbase64 = v +// SetIcon sets field value +func (o *MainMenuGroup) SetIcon(v string) { + o.Icon = v } // GetItems returns the Items field value @@ -221,7 +221,7 @@ func (o MainMenuGroup) MarshalJSON() ([]byte, error) { toSerialize["defaultOpen"] = o.DefaultOpen } if true { - toSerialize["iconbase64"] = o.Iconbase64 + toSerialize["icon"] = o.Icon } if true { toSerialize["items"] = o.Items diff --git a/generated/stackstate_api/model_main_menu_view_item.go b/generated/stackstate_api/model_main_menu_view_item.go index 635fe14d..2829308c 100644 --- a/generated/stackstate_api/model_main_menu_view_item.go +++ b/generated/stackstate_api/model_main_menu_view_item.go @@ -20,7 +20,7 @@ type MainMenuViewItem struct { // Either a viewIdentifier or a componentPresentationIdentifier Identifier string `json:"identifier" yaml:"identifier"` Title string `json:"title" yaml:"title"` - Iconbase64 *string `json:"iconbase64,omitempty" yaml:"iconbase64,omitempty"` + Icon *string `json:"icon,omitempty" yaml:"icon,omitempty"` } // NewMainMenuViewItem instantiates a new MainMenuViewItem object @@ -90,36 +90,36 @@ func (o *MainMenuViewItem) SetTitle(v string) { o.Title = v } -// GetIconbase64 returns the Iconbase64 field value if set, zero value otherwise. -func (o *MainMenuViewItem) GetIconbase64() string { - if o == nil || o.Iconbase64 == nil { +// GetIcon returns the Icon field value if set, zero value otherwise. +func (o *MainMenuViewItem) GetIcon() string { + if o == nil || o.Icon == nil { var ret string return ret } - return *o.Iconbase64 + return *o.Icon } -// GetIconbase64Ok returns a tuple with the Iconbase64 field value if set, nil otherwise +// GetIconOk returns a tuple with the Icon field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *MainMenuViewItem) GetIconbase64Ok() (*string, bool) { - if o == nil || o.Iconbase64 == nil { +func (o *MainMenuViewItem) GetIconOk() (*string, bool) { + if o == nil || o.Icon == nil { return nil, false } - return o.Iconbase64, true + return o.Icon, true } -// HasIconbase64 returns a boolean if a field has been set. -func (o *MainMenuViewItem) HasIconbase64() bool { - if o != nil && o.Iconbase64 != nil { +// HasIcon returns a boolean if a field has been set. +func (o *MainMenuViewItem) HasIcon() bool { + if o != nil && o.Icon != nil { return true } return false } -// SetIconbase64 gets a reference to the given string and assigns it to the Iconbase64 field. -func (o *MainMenuViewItem) SetIconbase64(v string) { - o.Iconbase64 = &v +// SetIcon gets a reference to the given string and assigns it to the Icon field. +func (o *MainMenuViewItem) SetIcon(v string) { + o.Icon = &v } func (o MainMenuViewItem) MarshalJSON() ([]byte, error) { @@ -130,8 +130,8 @@ func (o MainMenuViewItem) MarshalJSON() ([]byte, error) { if true { toSerialize["title"] = o.Title } - if o.Iconbase64 != nil { - toSerialize["iconbase64"] = o.Iconbase64 + if o.Icon != nil { + toSerialize["icon"] = o.Icon } return json.Marshal(toSerialize) } diff --git a/generated/stackstate_api/model_monitor_check_status_component.go b/generated/stackstate_api/model_monitor_check_status_component.go index 185d0d55..55fb5ed3 100644 --- a/generated/stackstate_api/model_monitor_check_status_component.go +++ b/generated/stackstate_api/model_monitor_check_status_component.go @@ -21,7 +21,7 @@ type MonitorCheckStatusComponent struct { Identifier string `json:"identifier" yaml:"identifier"` Name string `json:"name" yaml:"name"` Type string `json:"type" yaml:"type"` - Iconbase64 *string `json:"iconbase64,omitempty" yaml:"iconbase64,omitempty"` + Icon *string `json:"icon,omitempty" yaml:"icon,omitempty"` } // NewMonitorCheckStatusComponent instantiates a new MonitorCheckStatusComponent object @@ -141,36 +141,36 @@ func (o *MonitorCheckStatusComponent) SetType(v string) { o.Type = v } -// GetIconbase64 returns the Iconbase64 field value if set, zero value otherwise. -func (o *MonitorCheckStatusComponent) GetIconbase64() string { - if o == nil || o.Iconbase64 == nil { +// GetIcon returns the Icon field value if set, zero value otherwise. +func (o *MonitorCheckStatusComponent) GetIcon() string { + if o == nil || o.Icon == nil { var ret string return ret } - return *o.Iconbase64 + return *o.Icon } -// GetIconbase64Ok returns a tuple with the Iconbase64 field value if set, nil otherwise +// GetIconOk returns a tuple with the Icon field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *MonitorCheckStatusComponent) GetIconbase64Ok() (*string, bool) { - if o == nil || o.Iconbase64 == nil { +func (o *MonitorCheckStatusComponent) GetIconOk() (*string, bool) { + if o == nil || o.Icon == nil { return nil, false } - return o.Iconbase64, true + return o.Icon, true } -// HasIconbase64 returns a boolean if a field has been set. -func (o *MonitorCheckStatusComponent) HasIconbase64() bool { - if o != nil && o.Iconbase64 != nil { +// HasIcon returns a boolean if a field has been set. +func (o *MonitorCheckStatusComponent) HasIcon() bool { + if o != nil && o.Icon != nil { return true } return false } -// SetIconbase64 gets a reference to the given string and assigns it to the Iconbase64 field. -func (o *MonitorCheckStatusComponent) SetIconbase64(v string) { - o.Iconbase64 = &v +// SetIcon gets a reference to the given string and assigns it to the Icon field. +func (o *MonitorCheckStatusComponent) SetIcon(v string) { + o.Icon = &v } func (o MonitorCheckStatusComponent) MarshalJSON() ([]byte, error) { @@ -187,8 +187,8 @@ func (o MonitorCheckStatusComponent) MarshalJSON() ([]byte, error) { if true { toSerialize["type"] = o.Type } - if o.Iconbase64 != nil { - toSerialize["iconbase64"] = o.Iconbase64 + if o.Icon != nil { + toSerialize["icon"] = o.Icon } return json.Marshal(toSerialize) } diff --git a/generated/stackstate_api/model_presentation_definition.go b/generated/stackstate_api/model_presentation_definition.go index f4cf059b..c3feb1fe 100644 --- a/generated/stackstate_api/model_presentation_definition.go +++ b/generated/stackstate_api/model_presentation_definition.go @@ -17,9 +17,9 @@ import ( // PresentationDefinition struct for PresentationDefinition type PresentationDefinition struct { - Iconbase64 *string `json:"iconbase64,omitempty" yaml:"iconbase64,omitempty"` - Name *PresentationName `json:"name,omitempty" yaml:"name,omitempty"` - Overview *PresentationOverview `json:"overview,omitempty" yaml:"overview,omitempty"` + Icon *string `json:"icon,omitempty" yaml:"icon,omitempty"` + Name *PresentationName `json:"name,omitempty" yaml:"name,omitempty"` + Overview *PresentationOverview `json:"overview,omitempty" yaml:"overview,omitempty"` } // NewPresentationDefinition instantiates a new PresentationDefinition object @@ -39,36 +39,36 @@ func NewPresentationDefinitionWithDefaults() *PresentationDefinition { return &this } -// GetIconbase64 returns the Iconbase64 field value if set, zero value otherwise. -func (o *PresentationDefinition) GetIconbase64() string { - if o == nil || o.Iconbase64 == nil { +// GetIcon returns the Icon field value if set, zero value otherwise. +func (o *PresentationDefinition) GetIcon() string { + if o == nil || o.Icon == nil { var ret string return ret } - return *o.Iconbase64 + return *o.Icon } -// GetIconbase64Ok returns a tuple with the Iconbase64 field value if set, nil otherwise +// GetIconOk returns a tuple with the Icon field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *PresentationDefinition) GetIconbase64Ok() (*string, bool) { - if o == nil || o.Iconbase64 == nil { +func (o *PresentationDefinition) GetIconOk() (*string, bool) { + if o == nil || o.Icon == nil { return nil, false } - return o.Iconbase64, true + return o.Icon, true } -// HasIconbase64 returns a boolean if a field has been set. -func (o *PresentationDefinition) HasIconbase64() bool { - if o != nil && o.Iconbase64 != nil { +// HasIcon returns a boolean if a field has been set. +func (o *PresentationDefinition) HasIcon() bool { + if o != nil && o.Icon != nil { return true } return false } -// SetIconbase64 gets a reference to the given string and assigns it to the Iconbase64 field. -func (o *PresentationDefinition) SetIconbase64(v string) { - o.Iconbase64 = &v +// SetIcon gets a reference to the given string and assigns it to the Icon field. +func (o *PresentationDefinition) SetIcon(v string) { + o.Icon = &v } // GetName returns the Name field value if set, zero value otherwise. @@ -137,8 +137,8 @@ func (o *PresentationDefinition) SetOverview(v PresentationOverview) { func (o PresentationDefinition) MarshalJSON() ([]byte, error) { toSerialize := map[string]interface{}{} - if o.Iconbase64 != nil { - toSerialize["iconbase64"] = o.Iconbase64 + if o.Icon != nil { + toSerialize["icon"] = o.Icon } if o.Name != nil { toSerialize["name"] = o.Name diff --git a/generated/stackstate_api/model_presentation_main_menu.go b/generated/stackstate_api/model_presentation_main_menu.go index 21981432..6d1a7072 100644 --- a/generated/stackstate_api/model_presentation_main_menu.go +++ b/generated/stackstate_api/model_presentation_main_menu.go @@ -17,9 +17,9 @@ import ( // PresentationMainMenu struct for PresentationMainMenu type PresentationMainMenu struct { - Group string `json:"group" yaml:"group"` - Iconbase64 *string `json:"iconbase64,omitempty" yaml:"iconbase64,omitempty"` - Order float64 `json:"order" yaml:"order"` + Group string `json:"group" yaml:"group"` + Icon *string `json:"icon,omitempty" yaml:"icon,omitempty"` + Order float64 `json:"order" yaml:"order"` } // NewPresentationMainMenu instantiates a new PresentationMainMenu object @@ -65,36 +65,36 @@ func (o *PresentationMainMenu) SetGroup(v string) { o.Group = v } -// GetIconbase64 returns the Iconbase64 field value if set, zero value otherwise. -func (o *PresentationMainMenu) GetIconbase64() string { - if o == nil || o.Iconbase64 == nil { +// GetIcon returns the Icon field value if set, zero value otherwise. +func (o *PresentationMainMenu) GetIcon() string { + if o == nil || o.Icon == nil { var ret string return ret } - return *o.Iconbase64 + return *o.Icon } -// GetIconbase64Ok returns a tuple with the Iconbase64 field value if set, nil otherwise +// GetIconOk returns a tuple with the Icon field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *PresentationMainMenu) GetIconbase64Ok() (*string, bool) { - if o == nil || o.Iconbase64 == nil { +func (o *PresentationMainMenu) GetIconOk() (*string, bool) { + if o == nil || o.Icon == nil { return nil, false } - return o.Iconbase64, true + return o.Icon, true } -// HasIconbase64 returns a boolean if a field has been set. -func (o *PresentationMainMenu) HasIconbase64() bool { - if o != nil && o.Iconbase64 != nil { +// HasIcon returns a boolean if a field has been set. +func (o *PresentationMainMenu) HasIcon() bool { + if o != nil && o.Icon != nil { return true } return false } -// SetIconbase64 gets a reference to the given string and assigns it to the Iconbase64 field. -func (o *PresentationMainMenu) SetIconbase64(v string) { - o.Iconbase64 = &v +// SetIcon gets a reference to the given string and assigns it to the Icon field. +func (o *PresentationMainMenu) SetIcon(v string) { + o.Icon = &v } // GetOrder returns the Order field value @@ -126,8 +126,8 @@ func (o PresentationMainMenu) MarshalJSON() ([]byte, error) { if true { toSerialize["group"] = o.Group } - if o.Iconbase64 != nil { - toSerialize["iconbase64"] = o.Iconbase64 + if o.Icon != nil { + toSerialize["icon"] = o.Icon } if true { toSerialize["order"] = o.Order diff --git a/stackstate_openapi/openapi_version b/stackstate_openapi/openapi_version index 51986b0b..631a8996 100644 --- a/stackstate_openapi/openapi_version +++ b/stackstate_openapi/openapi_version @@ -1 +1 @@ -86eab764e5f831277671d3eb9bf029f523d9a96c +36a7262f51769ebff26827b33e2ebf8afd9b0f69