diff --git a/.gitignore b/.gitignore index bec5dcfe..d1a220dc 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,5 @@ release-notes.json .localdev/ stackstate-cli + +.claude diff --git a/cmd/sts.go b/cmd/sts.go index 9c6501a3..38700ced 100644 --- a/cmd/sts.go +++ b/cmd/sts.go @@ -33,6 +33,7 @@ func STSCommand(cli *di.Deps) *cobra.Command { cmd.AddCommand(AgentCommand(cli)) cmd.AddCommand(UserSessionCommand(cli)) cmd.AddCommand(DashboardCommand(cli)) + cmd.AddCommand(TopologyCommand(cli)) // Experimental commands for otel mapping if os.Getenv("STS_EXPERIMENTAL_OTEL_MAPPING") != "" { diff --git a/cmd/sts_test.go b/cmd/sts_test.go index 50281337..699880cb 100644 --- a/cmd/sts_test.go +++ b/cmd/sts_test.go @@ -38,6 +38,7 @@ func TestSTSCommandContainsExpectedSubcommands(t *testing.T) { "agent", "user-session", "dashboard", + "topology", } // Verify expected commands are present @@ -57,7 +58,7 @@ func TestSTSCommandStructure(t *testing.T) { cli := di.NewMockDeps(t) cmd := STSCommand(&cli.Deps) - assert.Len(t, cmd.Commands(), 16, "Expected 16 subcommands") + assert.Len(t, cmd.Commands(), 17, "Expected 17 subcommands") } func TestSTSCommandUsageTemplate(t *testing.T) { diff --git a/cmd/topology.go b/cmd/topology.go new file mode 100644 index 00000000..0bf400be --- /dev/null +++ b/cmd/topology.go @@ -0,0 +1,18 @@ +package cmd + +import ( + "github.com/spf13/cobra" + "github.com/stackvista/stackstate-cli/cmd/topology" + "github.com/stackvista/stackstate-cli/internal/di" +) + +func TopologyCommand(cli *di.Deps) *cobra.Command { + cmd := &cobra.Command{ + Use: "topology", + Short: "Inspect SUSE Observability topology components", + Long: "Inspect SUSE Observability topology components. Query and display topology components using component types, tags, and identifiers.", + } + cmd.AddCommand(topology.InspectCommand(cli)) + + return cmd +} diff --git a/cmd/topology/topology_inspect.go b/cmd/topology/topology_inspect.go new file mode 100644 index 00000000..affa1df9 --- /dev/null +++ b/cmd/topology/topology_inspect.go @@ -0,0 +1,419 @@ +package topology + +import ( + "fmt" + "net/http" + "net/url" + "strings" + + "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" + "github.com/stackvista/stackstate-cli/internal/printer" +) + +type InspectArgs struct { + ComponentType string + Tags []string + Identifiers []string + Limit int +} + +func InspectCommand(cli *di.Deps) *cobra.Command { + args := &InspectArgs{} + + cmd := &cobra.Command{ + Use: "inspect", + Short: "Inspect topology components", + Long: "Inspect topology components by type, tags, and identifiers. Displays component details and provides links to the UI.", + Example: `# inspect components of a specific type +sts topology inspect --type "otel service instance" + +# inspect with tag filtering +sts topology inspect --type "otel service instance" --tag "service.namespace:opentelemetry-demo-demo-dev" + +# inspect with multiple tags (ANDed) +sts topology inspect --type "otel service instance" \ + --tag "service.namespace:opentelemetry-demo-demo-dev" \ + --tag "service.name:accountingservice" + +# inspect with identifier filtering +sts topology inspect --type "otel service instance" --identifier "urn:opentelemetry:..." + +# inspect with limit on number of results +sts topology inspect --type "otel service instance" --limit 10 + +# inspect and display as JSON (includes component links) +sts topology inspect --type "otel service instance" -o json`, + RunE: cli.CmdRunEWithApi(func(cmd *cobra.Command, cli *di.Deps, api *stackstate_api.APIClient, serverInfo *stackstate_api.ServerInfo) common.CLIError { + return RunInspectCommand(cmd, cli, api, serverInfo, args) + }), + } + + cmd.Flags().StringVar(&args.ComponentType, "type", "", "Component type (required)") + cmd.MarkFlagRequired("type") //nolint:errcheck + cmd.Flags().StringSliceVar(&args.Tags, "tag", []string{}, "Filter by tags in format 'tag-name:tag-value' (multiple allowed, ANDed together)") + cmd.Flags().StringSliceVar(&args.Identifiers, "identifier", []string{}, "Filter by component identifiers (multiple allowed, ANDed together)") + cmd.Flags().IntVar(&args.Limit, "limit", 0, "Maximum number of components to output (must be positive)") + + return cmd +} + +func RunInspectCommand( + _ *cobra.Command, + cli *di.Deps, + api *stackstate_api.APIClient, + _ *stackstate_api.ServerInfo, + args *InspectArgs, +) common.CLIError { + if args.Limit < 0 { + return common.NewExecutionError(fmt.Errorf("limit must be a positive number, got: %d", args.Limit)) + } + + query := buildSTQLQuery(args.ComponentType, args.Tags, args.Identifiers) + + metadata := stackstate_api.NewQueryMetadata( + false, + false, + 0, + false, + false, + false, + false, + false, + false, + true, + ) + + request := stackstate_api.NewViewSnapshotRequest( + "ViewSnapshotRequest", + query, + "0.0.1", + *metadata, + ) + + result, resp, err := api.SnapshotApi.QuerySnapshot(cli.Context). + ViewSnapshotRequest(*request). + Execute() + if err != nil { + return common.NewResponseError(err, resp) + } + + // The `CmdRunEWithApi` ensures the current context is loaded, so it should be safe to access context properties + components, parseErr := parseSnapshotResponse(result, cli.CurrentContext.URL) + if parseErr != nil { + // Check if the error is a typed error from the response by examining the _type discriminator + if typedErr := handleViewSnapshotError(result.ViewSnapshotResponse, resp); typedErr != nil { + return typedErr + } + return common.NewExecutionError(parseErr) + } + + // Apply limit if specified + if args.Limit > 0 && len(components) > args.Limit { + components = components[:args.Limit] + } + + if cli.IsJson() { + cli.Printer.PrintJson(map[string]interface{}{ + "components": components, + }) + return nil + } else { + printTableOutput(cli, components) + } + + return nil +} + +func buildSTQLQuery(componentType string, tags []string, identifiers []string) string { + query := fmt.Sprintf(`type = "%s"`, componentType) + + for _, tag := range tags { + query += fmt.Sprintf(` AND label = "%s"`, tag) + } + + // Add identifier filters (ANDed with IN clause) + if len(identifiers) > 0 { + quotedIds := make([]string, len(identifiers)) + for i, id := range identifiers { + quotedIds[i] = fmt.Sprintf(`"%s"`, id) + } + query += fmt.Sprintf(` AND identifier IN (%s)`, strings.Join(quotedIds, ", ")) + } + + return query +} + +type Component struct { + ID int64 `json:"id"` + Name string `json:"name"` + Type string `json:"type"` + Identifiers []string `json:"identifiers"` + Tags []string `json:"tags"` + Properties map[string]interface{} `json:"properties"` + Layer map[string]interface{} `json:"layer"` + Domain map[string]interface{} `json:"domain"` + Environment map[string]interface{} `json:"environment,omitempty"` + Link string `json:"link"` +} + +type ComponentMetadata struct { + ComponentTypes map[int64]string + Layers map[int64]string + Domains map[int64]string + Environments map[int64]string +} + +// handleViewSnapshotError checks if the response is a typed error by examining the _type discriminator +func handleViewSnapshotError(respMap map[string]interface{}, resp *http.Response) common.CLIError { + if respMap == nil { + return nil + } + + responseType, ok := respMap["_type"].(string) + if !ok { + return nil + } + + switch responseType { + case "ViewSnapshotFetchTimeout": + if usedTimeoutSeconds, ok := respMap["usedTimeoutSeconds"].(float64); ok { + message := fmt.Sprintf( + "Query timed out after %d seconds. Please refine your query to be more specific.", + int64(usedTimeoutSeconds), + ) + return common.NewResponseError(fmt.Errorf("%s", message), resp) + } + + case "ViewSnapshotTooManyActiveQueries": + message := "Too many active queries are running. Please try again later." + return common.NewResponseError(fmt.Errorf("%s", message), resp) + + case "ViewSnapshotTopologySizeOverflow": + if maxSize, ok := respMap["maxSize"].(float64); ok { + message := fmt.Sprintf( + "Query result exceeded maximum size of %d components. Please refine your query to be more specific.", + int64(maxSize), + ) + return common.NewResponseError(fmt.Errorf("%s", message), resp) + } + + case "ViewSnapshotDataUnavailable": + if availableSinceEpochMs, ok := respMap["availableSinceEpochMs"].(float64); ok { + message := fmt.Sprintf( + "Requested data is not available. Data is available from %d (epoch ms) onwards.", + int64(availableSinceEpochMs), + ) + return common.NewResponseError(fmt.Errorf("%s", message), resp) + } + } + + return nil +} + +func parseSnapshotResponse( + result *stackstate_api.QuerySnapshotResult, + baseURL string, +) ([]Component, error) { + // ViewSnapshotResponse is already typed as map[string]interface{} from the generated API + respMap := result.ViewSnapshotResponse + if respMap == nil { + return nil, fmt.Errorf("response data is nil") + } + + // Check if this is a ViewSnapshot (success) or an error type + respType, ok := respMap["_type"].(string) + if !ok { + return nil, fmt.Errorf("response has no _type discriminator") + } + + // If it's not a ViewSnapshot, it's an error type - return empty components and let error handler deal with it + if respType != "ViewSnapshot" { + return nil, fmt.Errorf("response is an error type: %s", respType) + } + + metadata := parseMetadata(respMap) + + // Parse components from the already-unmarshalled components field + var components []Component + if componentsSlice, ok := respMap["components"].([]interface{}); ok { + for _, comp := range componentsSlice { + if compMap, ok := comp.(map[string]interface{}); ok { + components = append(components, parseComponentFromMap(compMap, metadata, baseURL)) + } + } + } + + return components, nil +} + +// metadataFieldMapping maps response JSON field names to the corresponding +// ComponentMetadata struct field setter. Used by parseMetadata to extract +// all metadata categories in a single loop. +var metadataFieldMapping = []struct { + field string + setter func(*ComponentMetadata) *map[int64]string +}{ + {"componentTypes", func(m *ComponentMetadata) *map[int64]string { return &m.ComponentTypes }}, + {"layers", func(m *ComponentMetadata) *map[int64]string { return &m.Layers }}, + {"domains", func(m *ComponentMetadata) *map[int64]string { return &m.Domains }}, + {"environments", func(m *ComponentMetadata) *map[int64]string { return &m.Environments }}, +} + +// parseMetadata extracts component type, layer, domain, and environment metadata +// from the opaque ViewSnapshot response using a table-driven approach. +func parseMetadata(respMap map[string]interface{}) ComponentMetadata { + metadata := ComponentMetadata{ + ComponentTypes: make(map[int64]string), + Layers: make(map[int64]string), + Domains: make(map[int64]string), + Environments: make(map[int64]string), + } + + metadataMap, ok := respMap["metadata"].(map[string]interface{}) + if !ok { + return metadata + } + + for _, mapping := range metadataFieldMapping { + if fieldValue, ok := metadataMap[mapping.field]; ok { + *mapping.setter(&metadata) = parseMetadataField(fieldValue) + } + } + + return metadata +} + +// parseMetadataField extracts id/name pairs from a metadata field. +// Each item in the slice should have "id" and "name" fields. +func parseMetadataField(metadataValue interface{}) map[int64]string { + result := make(map[int64]string) + + if metadataValue == nil { + return result + } + + // The JSON decoder produces []interface{} for arrays + items, ok := metadataValue.([]interface{}) + if !ok { + return result + } + + for _, item := range items { + if itemMap, ok := item.(map[string]interface{}); ok { + id, idOk := itemMap["id"].(float64) + name, nameOk := itemMap["name"].(string) + if idOk && nameOk { + result[int64(id)] = name + } + } + } + + return result +} + +func parseComponentFromMap(compMap map[string]interface{}, metadata ComponentMetadata, baseURL string) Component { + comp := Component{ + Identifiers: []string{}, + Tags: []string{}, + Properties: make(map[string]interface{}), + } + + // Parse basic fields + if id, ok := compMap["id"].(float64); ok { + comp.ID = int64(id) + } + if name, ok := compMap["name"].(string); ok { + comp.Name = name + } + + // Parse type (first id and then lookup from component type metadata) + if typeID, ok := compMap["type"].(float64); ok { + if typeName, found := metadata.ComponentTypes[int64(typeID)]; found { + comp.Type = typeName + } else { + comp.Type = fmt.Sprintf("Unknown (%d)", int64(typeID)) + } + } + + // Parse identifiers + if identifiersRaw, ok := compMap["identifiers"].([]interface{}); ok { + for _, idRaw := range identifiersRaw { + if id, ok := idRaw.(string); ok { + comp.Identifiers = append(comp.Identifiers, id) + } + } + } + + // Parse tags + if tagsRaw, ok := compMap["tags"].([]interface{}); ok { + for _, tagRaw := range tagsRaw { + if tag, ok := tagRaw.(string); ok { + comp.Tags = append(comp.Tags, tag) + } + } + } + + // Parse properties + if propertiesRaw, ok := compMap["properties"].(map[string]interface{}); ok { + comp.Properties = propertiesRaw + } + + // Parse layer, domain, and environment references + comp.Layer = parseComponentReference(compMap, "layer", metadata.Layers) + comp.Domain = parseComponentReference(compMap, "domain", metadata.Domains) + comp.Environment = parseComponentReference(compMap, "environment", metadata.Environments) + + // Build link + if len(comp.Identifiers) > 0 { + comp.Link = buildComponentLink(baseURL, comp.Identifiers[0]) + } + + return comp +} + +// parseComponentReference extracts a reference field (layer, domain, or environment) +// from a component and looks up its name in the provided metadata map. +// Returns a map with "id" and "name" keys, or nil if the field is not present. +func parseComponentReference(compMap map[string]interface{}, fieldName string, metadataMap map[int64]string) map[string]interface{} { + if refID, ok := compMap[fieldName].(float64); ok { + refIDInt := int64(refID) + refName := "Unknown" + if name, found := metadataMap[refIDInt]; found { + refName = name + } + return map[string]interface{}{ + "id": refIDInt, + "name": refName, + } + } + return nil +} + +func buildComponentLink(baseURL, identifier string) string { + encodedIdentifier := url.PathEscape(identifier) + return fmt.Sprintf("%s/#/components/%s", baseURL, encodedIdentifier) +} + +func printTableOutput( + cli *di.Deps, + components []Component, +) { + var tableData [][]interface{} + for _, comp := range components { + identifiersStr := strings.Join(comp.Identifiers, ", ") + tableData = append(tableData, []interface{}{ + comp.Name, + comp.Type, + identifiersStr, + }) + } + + cli.Printer.Table(printer.TableData{ + Header: []string{"Name", "Type", "Identifiers"}, + Data: tableData, + MissingTableDataMsg: printer.NotFoundMsg{Types: "components"}, + }) +} diff --git a/cmd/topology/topology_inspect_test.go b/cmd/topology/topology_inspect_test.go new file mode 100644 index 00000000..fac775fa --- /dev/null +++ b/cmd/topology/topology_inspect_test.go @@ -0,0 +1,358 @@ +package topology + +import ( + "testing" + + "github.com/spf13/cobra" + sts "github.com/stackvista/stackstate-cli/generated/stackstate_api" + "github.com/stackvista/stackstate-cli/internal/di" + "github.com/stackvista/stackstate-cli/internal/printer" + "github.com/stretchr/testify/assert" +) + +const baseURL = "https://suse-observability-instance.com" + +func setInspectCmd(t *testing.T) (*di.MockDeps, *cobra.Command) { + cli := di.NewMockDeps(t) + cmd := InspectCommand(&cli.Deps) + return &cli, cmd +} + +func mockSnapshotResponse() sts.QuerySnapshotResult { + return sts.QuerySnapshotResult{ + Type: "QuerySnapshotResult", + ViewSnapshotResponse: map[string]interface{}{ + "_type": "ViewSnapshot", + "components": []interface{}{ + map[string]interface{}{ + "id": float64(229404307680647), + "name": "test-component", + "type": float64(239975151751041), + "layer": float64(186771622698247), + "domain": float64(209616858431909), + "identifiers": []interface{}{"urn:test:component:1"}, + "tags": []interface{}{"service.namespace:test"}, + "properties": map[string]interface{}{"key": "value"}, + }, + }, + "metadata": map[string]interface{}{ + "componentTypes": []interface{}{ + map[string]interface{}{ + "id": float64(239975151751041), + "name": "test type", + }, + }, + "layers": []interface{}{ + map[string]interface{}{ + "id": float64(186771622698247), + "name": "Test Layer", + }, + }, + "domains": []interface{}{ + map[string]interface{}{ + "id": float64(209616858431909), + "name": "Test Domain", + }, + }, + }, + }, + } +} + +func TestTopologyInspectJson(t *testing.T) { + cli, cmd := setInspectCmd(t) + cli.MockClient.ApiMocks.SnapshotApi.QuerySnapshotResponse.Result = mockSnapshotResponse() + cli.CurrentContext.URL = baseURL + + di.ExecuteCommandWithContextUnsafe(&cli.Deps, cmd, "--type", "test type", "-o", "json") + + // Assert API was called + calls := *cli.MockClient.ApiMocks.SnapshotApi.QuerySnapshotCalls + assert.Len(t, calls, 1) + + // Assert JSON output contains components + jsonCalls := *cli.MockPrinter.PrintJsonCalls + assert.Len(t, jsonCalls, 1) + + jsonData := jsonCalls[0] + // Components are serialized from []Component struct + assert.NotNil(t, jsonData["components"]) + + assert.True(t, len(calls) > 0, "API should have been called") +} + +func TestTopologyInspectTable(t *testing.T) { + cli, cmd := setInspectCmd(t) + cli.MockClient.ApiMocks.SnapshotApi.QuerySnapshotResponse.Result = mockSnapshotResponse() + cli.CurrentContext.URL = baseURL + + di.ExecuteCommandWithContextUnsafe(&cli.Deps, cmd, "--type", "test type") + + // Assert API was called + calls := *cli.MockClient.ApiMocks.SnapshotApi.QuerySnapshotCalls + assert.Len(t, calls, 1) + + // Assert table output + tableCalls := *cli.MockPrinter.TableCalls + assert.Len(t, tableCalls, 1) + + table := tableCalls[0] + assert.Equal(t, []string{"Name", "Type", "Identifiers"}, table.Header) + assert.Len(t, table.Data, 1) + + row := table.Data[0] + assert.Equal(t, "test-component", row[0]) + assert.Equal(t, "test type", row[1]) + assert.Equal(t, "urn:test:component:1", row[2]) +} + +func TestTopologyInspectWithTags(t *testing.T) { + cli, cmd := setInspectCmd(t) + cli.MockClient.ApiMocks.SnapshotApi.QuerySnapshotResponse.Result = mockSnapshotResponse() + cli.CurrentContext.URL = baseURL + + di.ExecuteCommandWithContextUnsafe(&cli.Deps, cmd, + "--type", "test type", + "--tag", "service.namespace:test", + "--tag", "service.name:myservice") + + calls := *cli.MockClient.ApiMocks.SnapshotApi.QuerySnapshotCalls + assert.Len(t, calls, 1) + + // Verify query contains both tags ANDed + call := calls[0] + request := call.PviewSnapshotRequest + expectedQuery := `type = "test type" AND label = "service.namespace:test" AND label = "service.name:myservice"` + assert.Equal(t, expectedQuery, request.Query) +} + +func TestTopologyInspectWithIdentifiers(t *testing.T) { + cli, cmd := setInspectCmd(t) + cli.MockClient.ApiMocks.SnapshotApi.QuerySnapshotResponse.Result = mockSnapshotResponse() + cli.CurrentContext.URL = baseURL + + di.ExecuteCommandWithContextUnsafe(&cli.Deps, cmd, + "--type", "test type", + "--identifier", "urn:test:1", + "--identifier", "urn:test:2") + + calls := *cli.MockClient.ApiMocks.SnapshotApi.QuerySnapshotCalls + assert.Len(t, calls, 1) + + // Verify query contains identifiers in IN clause + call := calls[0] + request := call.PviewSnapshotRequest + expectedQuery := `type = "test type" AND identifier IN ("urn:test:1", "urn:test:2")` + assert.Equal(t, expectedQuery, request.Query) +} + +func TestTopologyInspectNoResults(t *testing.T) { + cli, cmd := setInspectCmd(t) + cli.MockClient.ApiMocks.SnapshotApi.QuerySnapshotResponse.Result = sts.QuerySnapshotResult{ + Type: "QuerySnapshotResult", + ViewSnapshotResponse: map[string]interface{}{ + "_type": "ViewSnapshot", + "components": []interface{}{}, + "metadata": map[string]interface{}{ + "componentTypes": []interface{}{}, + "layers": []interface{}{}, + "domains": []interface{}{}, + }, + }, + } + cli.CurrentContext.URL = baseURL + + di.ExecuteCommandWithContextUnsafe(&cli.Deps, cmd, "--type", "nonexistent") + + // Verify empty table is displayed + tableCalls := *cli.MockPrinter.TableCalls + assert.Len(t, tableCalls, 1) + + table := tableCalls[0] + assert.Equal(t, []string{"Name", "Type", "Identifiers"}, table.Header) + assert.Len(t, table.Data, 0) + assert.Equal(t, printer.NotFoundMsg{Types: "components"}, table.MissingTableDataMsg) +} + +func TestTopologyInspectMultipleIdentifiers(t *testing.T) { + cli, cmd := setInspectCmd(t) + responseData := mockSnapshotResponse() + // Modify to include multiple identifiers + components := responseData.ViewSnapshotResponse["components"].([]interface{}) + comp := components[0].(map[string]interface{}) + comp["identifiers"] = []interface{}{"urn:test:1", "urn:test:2", "urn:test:3"} + cli.MockClient.ApiMocks.SnapshotApi.QuerySnapshotResponse.Result = responseData + cli.CurrentContext.URL = baseURL + + di.ExecuteCommandWithContextUnsafe(&cli.Deps, cmd, "--type", "test type") + + // Verify multiple identifiers are joined with comma + tableCalls := *cli.MockPrinter.TableCalls + assert.Len(t, tableCalls, 1) + + table := tableCalls[0] + row := table.Data[0] + assert.Equal(t, "urn:test:1, urn:test:2, urn:test:3", row[2]) +} + +func TestTopologyInspectURLEncoding(t *testing.T) { + cli, cmd := setInspectCmd(t) + responseData := mockSnapshotResponse() + // Set identifier with special characters + components := responseData.ViewSnapshotResponse["components"].([]interface{}) + comp := components[0].(map[string]interface{}) + comp["identifiers"] = []interface{}{"urn:opentelemetry:namespace/service:component/name"} + cli.MockClient.ApiMocks.SnapshotApi.QuerySnapshotResponse.Result = responseData + cli.CurrentContext.URL = baseURL + + di.ExecuteCommandWithContextUnsafe(&cli.Deps, cmd, "--type", "test type", "-o", "json") + + // Verify URL encoding in link + jsonCalls := *cli.MockPrinter.PrintJsonCalls + returnedComponents := jsonCalls[0]["components"].([]Component) + // url.PathEscape encodes / to %2F, but : is not encoded, and base URL is prefixed + expectedLink := baseURL + "/#/components/urn:opentelemetry:namespace%2Fservice:component%2Fname" + assert.Equal(t, expectedLink, returnedComponents[0].Link) +} + +func TestTopologyInspectWithEnvironment(t *testing.T) { + cli, cmd := setInspectCmd(t) + responseData := mockSnapshotResponse() + // Add environment to component + components := responseData.ViewSnapshotResponse["components"].([]interface{}) + comp := components[0].(map[string]interface{}) + comp["environment"] = float64(123) + // Add environment to metadata + metadata := responseData.ViewSnapshotResponse["metadata"].(map[string]interface{}) + metadata["environments"] = []interface{}{ + map[string]interface{}{ + "id": float64(123), + "name": "Production", + }, + } + cli.MockClient.ApiMocks.SnapshotApi.QuerySnapshotResponse.Result = responseData + cli.CurrentContext.URL = baseURL + + di.ExecuteCommandWithContextUnsafe(&cli.Deps, cmd, "--type", "test type", "-o", "json") + + // Verify environment is included in JSON + jsonCalls := *cli.MockPrinter.PrintJsonCalls + assert.Len(t, jsonCalls, 1) + jsonData := jsonCalls[0] + assert.NotNil(t, jsonData["components"]) +} + +func TestTopologyInspectTypeRequired(t *testing.T) { + cli, cmd := setInspectCmd(t) + + // Execute without --type flag should panic due to required flag + assert.Panics(t, func() { + di.ExecuteCommandWithContextUnsafe(&cli.Deps, cmd) + }, "command should panic when required --type flag is missing") +} + +func TestTopologyInspectMetadataMapping(t *testing.T) { + cli, cmd := setInspectCmd(t) + cli.MockClient.ApiMocks.SnapshotApi.QuerySnapshotResponse.Result = mockSnapshotResponse() + cli.CurrentContext.URL = baseURL + + di.ExecuteCommandWithContextUnsafe(&cli.Deps, cmd, "--type", "test type", "-o", "json") + + // Verify metadata is properly mapped to component by checking table output + // which includes resolved names + tableCalls := *cli.MockPrinter.TableCalls + assert.Len(t, tableCalls, 0) // JSON mode doesn't produce table output + + // Verify JSON output was generated + jsonCalls := *cli.MockPrinter.PrintJsonCalls + assert.Len(t, jsonCalls, 1) +} + +func TestTopologyInspectWithBaseURL(t *testing.T) { + cli, cmd := setInspectCmd(t) + cli.MockClient.ApiMocks.SnapshotApi.QuerySnapshotResponse.Result = mockSnapshotResponse() + cli.CurrentContext.URL = "https://stackstate.example.com:8080" + + di.ExecuteCommandWithContextUnsafe(&cli.Deps, cmd, "--type", "test type") + + // Verify base URL is included in the link + tableCalls := *cli.MockPrinter.TableCalls + assert.Len(t, tableCalls, 1) + + table := tableCalls[0] + row := table.Data[0] + expectedLink := "https://stackstate.example.com:8080/#/components/urn:test:component:1" + assert.Equal(t, expectedLink, row[3]) +} + +func TestTopologyInspectFetchTimeout(t *testing.T) { + cli, cmd := setInspectCmd(t) + cli.MockClient.ApiMocks.SnapshotApi.QuerySnapshotResponse.Result = sts.QuerySnapshotResult{ + Type: "QuerySnapshotResult", + ViewSnapshotResponse: map[string]interface{}{ + "_type": "ViewSnapshotFetchTimeout", + "usedTimeoutSeconds": float64(30), + }, + } + cli.CurrentContext.URL = baseURL + + _, err := di.ExecuteCommandWithContext(&cli.Deps, cmd, "--type", "test type") + + // Verify execution error is reported + assert.Error(t, err) + assert.Contains(t, err.Error(), "Query timed out after 30 seconds") +} + +func TestTopologyInspectTooManyActiveQueries(t *testing.T) { + cli, cmd := setInspectCmd(t) + cli.MockClient.ApiMocks.SnapshotApi.QuerySnapshotResponse.Result = sts.QuerySnapshotResult{ + Type: "QuerySnapshotResult", + ViewSnapshotResponse: map[string]interface{}{ + "_type": "ViewSnapshotTooManyActiveQueries", + }, + } + cli.CurrentContext.URL = baseURL + + _, err := di.ExecuteCommandWithContext(&cli.Deps, cmd, "--type", "test type") + + // Verify execution error is reported + assert.Error(t, err) + assert.Contains(t, err.Error(), "Too many active queries") +} + +func TestTopologyInspectTopologySizeOverflow(t *testing.T) { + cli, cmd := setInspectCmd(t) + cli.MockClient.ApiMocks.SnapshotApi.QuerySnapshotResponse.Result = sts.QuerySnapshotResult{ + Type: "QuerySnapshotResult", + ViewSnapshotResponse: map[string]interface{}{ + "_type": "ViewSnapshotTopologySizeOverflow", + "maxSize": float64(10000), + }, + } + cli.CurrentContext.URL = baseURL + + _, err := di.ExecuteCommandWithContext(&cli.Deps, cmd, "--type", "test type") + + // Verify execution error is reported + assert.Error(t, err) + assert.Contains(t, err.Error(), "Query result exceeded maximum size") +} + +func TestTopologyInspectDataUnavailable(t *testing.T) { + cli, cmd := setInspectCmd(t) + cli.MockClient.ApiMocks.SnapshotApi.QuerySnapshotResponse.Result = sts.QuerySnapshotResult{ + Type: "QuerySnapshotResult", + ViewSnapshotResponse: map[string]interface{}{ + "_type": "ViewSnapshotDataUnavailable", + "unavailableAtEpochMs": float64(1000000), + "availableSinceEpochMs": float64(1609459200000), + }, + } + cli.CurrentContext.URL = baseURL + + _, err := di.ExecuteCommandWithContext(&cli.Deps, cmd, "--type", "test type") + + // Verify execution error is reported + assert.Error(t, err) + assert.Contains(t, err.Error(), "Requested data is not available") +} diff --git a/generated/stackstate_api/.openapi-generator/FILES b/generated/stackstate_api/.openapi-generator/FILES index fbb5d3ff..a5ea982e 100644 --- a/generated/stackstate_api/.openapi-generator/FILES +++ b/generated/stackstate_api/.openapi-generator/FILES @@ -16,6 +16,7 @@ api_health_synchronization.go api_import.go api_kubernetes_logs.go api_layout.go +api_main_menu.go api_metric.go api_monitor.go api_monitor_check_status.go @@ -28,6 +29,7 @@ api_problem.go api_scripting.go api_server.go api_service_token.go +api_snapshot.go api_stackpack.go api_subject.go api_subscription.go @@ -205,6 +207,9 @@ docs/LockedResponse.md docs/LogLevel.md docs/LogSeverity.md docs/LogsDirection.md +docs/MainMenuApi.md +docs/MainMenuGroup.md +docs/MainMenuViewItem.md docs/Message.md docs/MessageLevel.md docs/Messages.md @@ -370,6 +375,9 @@ docs/PromSeriesEnvelope.md docs/PromVector.md docs/PromVectorResult.md docs/ProvisionResponse.md +docs/QueryMetadata.md +docs/QueryParsingFailure.md +docs/QuerySnapshotResult.md docs/QueryViewArguments.md docs/ReleaseStatus.md docs/RequestError.md @@ -393,6 +401,7 @@ docs/SlackChannelRefId.md docs/SlackChannelsChunk.md docs/SlackNotificationChannel.md docs/SlackNotificationChannelAllOf.md +docs/SnapshotApi.md docs/SourceLink.md docs/Span.md docs/SpanComponent.md @@ -488,6 +497,7 @@ docs/UserProfileApi.md docs/UserProfileSaveError.md docs/UserSessionApi.md docs/ViewCheckState.md +docs/ViewSnapshotRequest.md docs/WebhookChannelRefId.md docs/WebhookChannelWriteSchema.md docs/WebhookNotificationChannel.md @@ -646,6 +656,8 @@ model_locked_response.go model_log_level.go model_log_severity.go model_logs_direction.go +model_main_menu_group.go +model_main_menu_view_item.go model_message.go model_message_level.go model_messages.go @@ -802,6 +814,9 @@ model_prom_series_envelope.go model_prom_vector.go model_prom_vector_result.go model_provision_response.go +model_query_metadata.go +model_query_parsing_failure.go +model_query_snapshot_result.go model_query_view_arguments.go model_release_status.go model_request_error.go @@ -906,6 +921,7 @@ model_user_not_logged_in_error.go model_user_profile.go model_user_profile_save_error.go model_view_check_state.go +model_view_snapshot_request.go model_webhook_channel_ref_id.go model_webhook_channel_write_schema.go model_webhook_notification_channel.go diff --git a/generated/stackstate_api/README.md b/generated/stackstate_api/README.md index c7a1fcc3..84212dcc 100644 --- a/generated/stackstate_api/README.md +++ b/generated/stackstate_api/README.md @@ -123,6 +123,7 @@ Class | Method | HTTP request | Description *KubernetesLogsApi* | [**GetKubernetesLogsAutocomplete**](docs/KubernetesLogsApi.md#getkuberneteslogsautocomplete) | **Get** /k8s/logs/autocomplete | Get Kubernetes logs autocomplete values *KubernetesLogsApi* | [**GetKubernetesLogsHistogram**](docs/KubernetesLogsApi.md#getkuberneteslogshistogram) | **Get** /k8s/logs/histogram | Get Kubernetes logs histogram *LayoutApi* | [**GetAllLayouts**](docs/LayoutApi.md#getalllayouts) | **Get** /layouts | List layout hints +*MainMenuApi* | [**MainMenuGet**](docs/MainMenuApi.md#mainmenuget) | **Get** /main-menu | Get Main Menu *MetricApi* | [**GetExemplarsQuery**](docs/MetricApi.md#getexemplarsquery) | **Get** /metrics/query_exemplars | Experimental: Exemplars for a specific time range *MetricApi* | [**GetInstantQuery**](docs/MetricApi.md#getinstantquery) | **Get** /metrics/query | Instant query at a single point in time *MetricApi* | [**GetLabelValues**](docs/MetricApi.md#getlabelvalues) | **Get** /metrics/label/{label}/values | List of label values for a provided label name @@ -216,6 +217,7 @@ Class | Method | HTTP request | Description *ServiceTokenApi* | [**CreateNewServiceToken**](docs/ServiceTokenApi.md#createnewservicetoken) | **Post** /security/tokens | Create new service token *ServiceTokenApi* | [**DeleteServiceToken**](docs/ServiceTokenApi.md#deleteservicetoken) | **Delete** /security/tokens/{serviceTokenId} | Delete service token *ServiceTokenApi* | [**GetServiceTokens**](docs/ServiceTokenApi.md#getservicetokens) | **Get** /security/tokens | Get service tokens +*SnapshotApi* | [**QuerySnapshot**](docs/SnapshotApi.md#querysnapshot) | **Post** /snapshot | Query topology snapshot *StackpackApi* | [**ConfirmManualSteps**](docs/StackpackApi.md#confirmmanualsteps) | **Post** /stackpack/{stackPackName}/confirm-manual-steps/{stackPackInstanceId} | Confirm manual steps *StackpackApi* | [**ProvisionDetails**](docs/StackpackApi.md#provisiondetails) | **Post** /stackpack/{stackPackName}/provision | Provision API *StackpackApi* | [**ProvisionUninstall**](docs/StackpackApi.md#provisionuninstall) | **Post** /stackpack/{stackPackName}/deprovision/{stackPackInstanceId} | Provision API @@ -404,6 +406,8 @@ Class | Method | HTTP request | Description - [LogLevel](docs/LogLevel.md) - [LogSeverity](docs/LogSeverity.md) - [LogsDirection](docs/LogsDirection.md) + - [MainMenuGroup](docs/MainMenuGroup.md) + - [MainMenuViewItem](docs/MainMenuViewItem.md) - [Message](docs/Message.md) - [MessageLevel](docs/MessageLevel.md) - [Messages](docs/Messages.md) @@ -560,6 +564,9 @@ Class | Method | HTTP request | Description - [PromVector](docs/PromVector.md) - [PromVectorResult](docs/PromVectorResult.md) - [ProvisionResponse](docs/ProvisionResponse.md) + - [QueryMetadata](docs/QueryMetadata.md) + - [QueryParsingFailure](docs/QueryParsingFailure.md) + - [QuerySnapshotResult](docs/QuerySnapshotResult.md) - [QueryViewArguments](docs/QueryViewArguments.md) - [ReleaseStatus](docs/ReleaseStatus.md) - [RequestError](docs/RequestError.md) @@ -664,6 +671,7 @@ Class | Method | HTTP request | Description - [UserProfile](docs/UserProfile.md) - [UserProfileSaveError](docs/UserProfileSaveError.md) - [ViewCheckState](docs/ViewCheckState.md) + - [ViewSnapshotRequest](docs/ViewSnapshotRequest.md) - [WebhookChannelRefId](docs/WebhookChannelRefId.md) - [WebhookChannelWriteSchema](docs/WebhookChannelWriteSchema.md) - [WebhookNotificationChannel](docs/WebhookNotificationChannel.md) diff --git a/generated/stackstate_api/api/openapi.yaml b/generated/stackstate_api/api/openapi.yaml index feab99df..8f345f57 100644 --- a/generated/stackstate_api/api/openapi.yaml +++ b/generated/stackstate_api/api/openapi.yaml @@ -6374,6 +6374,67 @@ paths: required: true schema: type: string + /main-menu: + get: + description: Get Main Menu + responses: + "200": + content: + application/json: + schema: + items: + $ref: '#/components/schemas/MainMenuGroup' + type: array + description: Main Menu + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/GenericErrorsResponse' + description: Error when handling the request on the server side. + summary: Get Main Menu + tags: + - MainMenu + /snapshot: + post: + operationId: querySnapshot + parameters: + - description: Query timeout in milliseconds + in: query + name: timeout-ms + required: false + schema: + default: 30000 + format: int64 + type: integer + requestBody: + $ref: '#/components/requestBodies/viewSnapshotRequest' + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/QuerySnapshotResult' + description: Snapshot query result + "400": + content: + application/json: + schema: + $ref: '#/components/schemas/QueryParsingFailure' + description: Query parsing failed + "401": + description: User is not authorized + "403": + description: User is forbidden for the provided permission + "500": + content: + application/json: + schema: + $ref: '#/components/schemas/GenericErrorsResponse' + description: Error when handling the request on the server side. + summary: Query topology snapshot + tags: + - snapshot /dummy/dummy: get: description: "" @@ -6547,6 +6608,13 @@ components: $ref: '#/components/schemas/upsertOtelRelationMappings_request' description: Otel Relation Mapping to create/update required: true + viewSnapshotRequest: + content: + application/json: + schema: + $ref: '#/components/schemas/ViewSnapshotRequest' + description: Request body for querying a topology snapshot + required: true responses: genericErrorsResponse: content: @@ -7196,6 +7264,26 @@ components: schema: $ref: '#/components/schemas/ComponentPresentationApiError' description: Component Presentation with given identifier not found + mainMenuGroup: + content: + application/json: + schema: + items: + $ref: '#/components/schemas/MainMenuGroup' + type: array + description: Main Menu + querySnapshotResult: + content: + application/json: + schema: + $ref: '#/components/schemas/QuerySnapshotResult' + description: Snapshot query result + queryParsingFailure: + content: + application/json: + schema: + $ref: '#/components/schemas/QueryParsingFailure' + description: Query parsing failed stackElementNotFound: content: application/json: @@ -15222,6 +15310,188 @@ components: required: - message type: object + MainMenuGroup: + example: + identifier: identifier + iconbase64: iconbase64 + name: name + description: description + defaultOpen: true + items: + - viewIdentifier: viewIdentifier + - viewIdentifier: viewIdentifier + properties: + name: + type: string + identifier: + type: string + description: + type: string + defaultOpen: + type: boolean + iconbase64: + type: string + items: + items: + $ref: '#/components/schemas/MainMenuViewItem' + type: array + required: + - defaultOpen + - iconbase64 + - items + - name + MainMenuViewItem: + example: + viewIdentifier: viewIdentifier + properties: + viewIdentifier: + type: string + required: + - viewIdentifier + ViewSnapshotRequest: + example: + metadata: + minGroupSize: 0 + neighboringComponents: true + groupedByRelation: true + autoGrouping: true + groupedByLayer: true + queryTime: 6 + showFullComponent: true + showIndirectRelations: true + connectedComponents: true + groupingEnabled: true + groupedByDomain: true + viewId: 1 + query: query + _type: ViewSnapshotRequest + queryVersion: 0.0.1 + properties: + _type: + enum: + - ViewSnapshotRequest + type: string + query: + description: STQL query string + type: string + queryVersion: + example: 0.0.1 + pattern: ^\d+\.\d+\.\d+$ + type: string + metadata: + $ref: '#/components/schemas/QueryMetadata' + viewId: + format: int64 + nullable: true + type: integer + required: + - _type + - metadata + - query + - queryVersion + type: object + QueryMetadata: + description: Query execution settings + example: + minGroupSize: 0 + neighboringComponents: true + groupedByRelation: true + autoGrouping: true + groupedByLayer: true + queryTime: 6 + showFullComponent: true + showIndirectRelations: true + connectedComponents: true + groupingEnabled: true + groupedByDomain: true + properties: + groupingEnabled: + type: boolean + showIndirectRelations: + type: boolean + minGroupSize: + format: int64 + type: integer + groupedByLayer: + type: boolean + groupedByDomain: + type: boolean + groupedByRelation: + type: boolean + queryTime: + description: Unix timestamp in milliseconds + format: int64 + nullable: true + type: integer + autoGrouping: + type: boolean + connectedComponents: + type: boolean + neighboringComponents: + type: boolean + showFullComponent: + type: boolean + required: + - autoGrouping + - connectedComponents + - groupedByDomain + - groupedByLayer + - groupedByRelation + - groupingEnabled + - minGroupSize + - neighboringComponents + - showFullComponent + - showIndirectRelations + type: object + QuerySnapshotResult: + description: | + Query succeeded (or encountered a runtime error that's part of the result). + The viewSnapshotResponse uses existing DTO types for nested structures. + example: + viewId: 0 + viewSnapshotResponse: "{}" + _type: QuerySnapshotResult + properties: + _type: + description: Discriminator field + enum: + - QuerySnapshotResult + type: string + viewSnapshotResponse: + description: | + The query result or error response. This is opaque at the API level but contains one of: + - ViewSnapshot (success) + - ViewSnapshotFetchTimeout (error) + - ViewSnapshotTooManyActiveQueries (error) + - ViewSnapshotTopologySizeOverflow (error) + - ViewSnapshotDataUnavailable (error) + Use the _type field to discriminate between types. + type: object + viewId: + description: Optional view ID associated with this result + format: int64 + nullable: true + type: integer + required: + - _type + - viewSnapshotResponse + type: object + QueryParsingFailure: + description: | + Query parsing failed. The reason field contains the error message. + properties: + _type: + description: Discriminator field + enum: + - QueryParsingFailure + type: string + reason: + description: Error message describing why the query failed to parse + type: string + required: + - _type + - reason + type: object StackElementNotFound: discriminator: propertyName: _type diff --git a/generated/stackstate_api/api_main_menu.go b/generated/stackstate_api/api_main_menu.go new file mode 100644 index 00000000..f76c1287 --- /dev/null +++ b/generated/stackstate_api/api_main_menu.go @@ -0,0 +1,229 @@ +/* +StackState API + +This API documentation page describes the StackState server API. The StackState UI and CLI use the StackState server API to configure and query StackState. You can use the API for similar purposes. Each request sent to the StackState server API must be authenticated using one of the available authentication methods. *Note that the StackState receiver API, used to send topology, telemetry and traces to StackState, is not described on this page and requires a different authentication method.* For more information on StackState, refer to the [StackState documentation](https://docs.stackstate.com). + +API version: 5.2.0 +Contact: info@stackstate.com +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package stackstate_api + +import ( + "bytes" + "context" + "io/ioutil" + "net/http" + "net/url" +) + +type MainMenuApi interface { + + /* + MainMenuGet Get Main Menu + + Get Main Menu + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return ApiMainMenuGetRequest + */ + MainMenuGet(ctx context.Context) ApiMainMenuGetRequest + + // MainMenuGetExecute executes the request + // @return []MainMenuGroup + MainMenuGetExecute(r ApiMainMenuGetRequest) ([]MainMenuGroup, *http.Response, error) +} + +// MainMenuApiService MainMenuApi service +type MainMenuApiService service + +type ApiMainMenuGetRequest struct { + ctx context.Context + ApiService MainMenuApi +} + +func (r ApiMainMenuGetRequest) Execute() ([]MainMenuGroup, *http.Response, error) { + return r.ApiService.MainMenuGetExecute(r) +} + +/* +MainMenuGet Get Main Menu + +Get Main Menu + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return ApiMainMenuGetRequest +*/ +func (a *MainMenuApiService) MainMenuGet(ctx context.Context) ApiMainMenuGetRequest { + return ApiMainMenuGetRequest{ + ApiService: a, + ctx: ctx, + } +} + +// Execute executes the request +// +// @return []MainMenuGroup +func (a *MainMenuApiService) MainMenuGetExecute(r ApiMainMenuGetRequest) ([]MainMenuGroup, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue []MainMenuGroup + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "MainMenuApiService.MainMenuGet") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/main-menu" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // 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 + } + 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 == 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 +} + +// --------------------------------------------- +// ------------------ MOCKS -------------------- +// --------------------------------------------- + +type MainMenuApiMock struct { + MainMenuGetCalls *[]MainMenuGetCall + MainMenuGetResponse MainMenuGetMockResponse +} + +func NewMainMenuApiMock() MainMenuApiMock { + xMainMenuGetCalls := make([]MainMenuGetCall, 0) + return MainMenuApiMock{ + MainMenuGetCalls: &xMainMenuGetCalls, + } +} + +type MainMenuGetMockResponse struct { + Result []MainMenuGroup + Response *http.Response + Error error +} + +type MainMenuGetCall struct { +} + +func (mock MainMenuApiMock) MainMenuGet(ctx context.Context) ApiMainMenuGetRequest { + return ApiMainMenuGetRequest{ + ApiService: mock, + ctx: ctx, + } +} + +func (mock MainMenuApiMock) MainMenuGetExecute(r ApiMainMenuGetRequest) ([]MainMenuGroup, *http.Response, error) { + p := MainMenuGetCall{} + *mock.MainMenuGetCalls = append(*mock.MainMenuGetCalls, p) + return mock.MainMenuGetResponse.Result, mock.MainMenuGetResponse.Response, mock.MainMenuGetResponse.Error +} diff --git a/generated/stackstate_api/api_snapshot.go b/generated/stackstate_api/api_snapshot.go new file mode 100644 index 00000000..ecdbd0d8 --- /dev/null +++ b/generated/stackstate_api/api_snapshot.go @@ -0,0 +1,262 @@ +/* +StackState API + +This API documentation page describes the StackState server API. The StackState UI and CLI use the StackState server API to configure and query StackState. You can use the API for similar purposes. Each request sent to the StackState server API must be authenticated using one of the available authentication methods. *Note that the StackState receiver API, used to send topology, telemetry and traces to StackState, is not described on this page and requires a different authentication method.* For more information on StackState, refer to the [StackState documentation](https://docs.stackstate.com). + +API version: 5.2.0 +Contact: info@stackstate.com +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package stackstate_api + +import ( + "bytes" + "context" + "io/ioutil" + "net/http" + "net/url" +) + +type SnapshotApi interface { + + /* + QuerySnapshot Query topology snapshot + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return ApiQuerySnapshotRequest + */ + QuerySnapshot(ctx context.Context) ApiQuerySnapshotRequest + + // QuerySnapshotExecute executes the request + // @return QuerySnapshotResult + QuerySnapshotExecute(r ApiQuerySnapshotRequest) (*QuerySnapshotResult, *http.Response, error) +} + +// SnapshotApiService SnapshotApi service +type SnapshotApiService service + +type ApiQuerySnapshotRequest struct { + ctx context.Context + ApiService SnapshotApi + viewSnapshotRequest *ViewSnapshotRequest + timeoutMs *int64 +} + +// Request body for querying a topology snapshot +func (r ApiQuerySnapshotRequest) ViewSnapshotRequest(viewSnapshotRequest ViewSnapshotRequest) ApiQuerySnapshotRequest { + r.viewSnapshotRequest = &viewSnapshotRequest + return r +} + +// Query timeout in milliseconds +func (r ApiQuerySnapshotRequest) TimeoutMs(timeoutMs int64) ApiQuerySnapshotRequest { + r.timeoutMs = &timeoutMs + return r +} + +func (r ApiQuerySnapshotRequest) Execute() (*QuerySnapshotResult, *http.Response, error) { + return r.ApiService.QuerySnapshotExecute(r) +} + +/* +QuerySnapshot Query topology snapshot + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return ApiQuerySnapshotRequest +*/ +func (a *SnapshotApiService) QuerySnapshot(ctx context.Context) ApiQuerySnapshotRequest { + return ApiQuerySnapshotRequest{ + ApiService: a, + ctx: ctx, + } +} + +// Execute executes the request +// +// @return QuerySnapshotResult +func (a *SnapshotApiService) QuerySnapshotExecute(r ApiQuerySnapshotRequest) (*QuerySnapshotResult, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *QuerySnapshotResult + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "SnapshotApiService.QuerySnapshot") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/snapshot" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if r.viewSnapshotRequest == nil { + return localVarReturnValue, nil, reportError("viewSnapshotRequest is required and must be specified") + } + + if r.timeoutMs != nil { + localVarQueryParams.Add("timeout-ms", parameterToString(*r.timeoutMs, "")) + } + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // 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 + } + // body params + localVarPostBody = r.viewSnapshotRequest + 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 QueryParsingFailure + 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 +} + +// --------------------------------------------- +// ------------------ MOCKS -------------------- +// --------------------------------------------- + +type SnapshotApiMock struct { + QuerySnapshotCalls *[]QuerySnapshotCall + QuerySnapshotResponse QuerySnapshotMockResponse +} + +func NewSnapshotApiMock() SnapshotApiMock { + xQuerySnapshotCalls := make([]QuerySnapshotCall, 0) + return SnapshotApiMock{ + QuerySnapshotCalls: &xQuerySnapshotCalls, + } +} + +type QuerySnapshotMockResponse struct { + Result QuerySnapshotResult + Response *http.Response + Error error +} + +type QuerySnapshotCall struct { + PviewSnapshotRequest *ViewSnapshotRequest + PtimeoutMs *int64 +} + +func (mock SnapshotApiMock) QuerySnapshot(ctx context.Context) ApiQuerySnapshotRequest { + return ApiQuerySnapshotRequest{ + ApiService: mock, + ctx: ctx, + } +} + +func (mock SnapshotApiMock) QuerySnapshotExecute(r ApiQuerySnapshotRequest) (*QuerySnapshotResult, *http.Response, error) { + p := QuerySnapshotCall{ + PviewSnapshotRequest: r.viewSnapshotRequest, + PtimeoutMs: r.timeoutMs, + } + *mock.QuerySnapshotCalls = append(*mock.QuerySnapshotCalls, p) + return &mock.QuerySnapshotResponse.Result, mock.QuerySnapshotResponse.Response, mock.QuerySnapshotResponse.Error +} diff --git a/generated/stackstate_api/client.go b/generated/stackstate_api/client.go index f41da961..05bada00 100644 --- a/generated/stackstate_api/client.go +++ b/generated/stackstate_api/client.go @@ -76,6 +76,8 @@ type APIClient struct { LayoutApi LayoutApi + MainMenuApi MainMenuApi + MetricApi MetricApi MonitorApi MonitorApi @@ -100,6 +102,8 @@ type APIClient struct { ServiceTokenApi ServiceTokenApi + SnapshotApi SnapshotApi + StackpackApi StackpackApi SubjectApi SubjectApi @@ -152,6 +156,7 @@ func NewAPIClient(cfg *Configuration) *APIClient { c.ImportApi = (*ImportApiService)(&c.common) c.KubernetesLogsApi = (*KubernetesLogsApiService)(&c.common) c.LayoutApi = (*LayoutApiService)(&c.common) + c.MainMenuApi = (*MainMenuApiService)(&c.common) c.MetricApi = (*MetricApiService)(&c.common) c.MonitorApi = (*MonitorApiService)(&c.common) c.MonitorCheckStatusApi = (*MonitorCheckStatusApiService)(&c.common) @@ -164,6 +169,7 @@ func NewAPIClient(cfg *Configuration) *APIClient { c.ScriptingApi = (*ScriptingApiService)(&c.common) c.ServerApi = (*ServerApiService)(&c.common) c.ServiceTokenApi = (*ServiceTokenApiService)(&c.common) + c.SnapshotApi = (*SnapshotApiService)(&c.common) c.StackpackApi = (*StackpackApiService)(&c.common) c.SubjectApi = (*SubjectApiService)(&c.common) c.SubscriptionApi = (*SubscriptionApiService)(&c.common) diff --git a/generated/stackstate_api/docs/MainMenuApi.md b/generated/stackstate_api/docs/MainMenuApi.md new file mode 100644 index 00000000..ac322056 --- /dev/null +++ b/generated/stackstate_api/docs/MainMenuApi.md @@ -0,0 +1,70 @@ +# \MainMenuApi + +All URIs are relative to *http://localhost* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**MainMenuGet**](MainMenuApi.md#MainMenuGet) | **Get** /main-menu | Get Main Menu + + + +## MainMenuGet + +> []MainMenuGroup MainMenuGet(ctx).Execute() + +Get Main Menu + + + +### Example + +```go +package main + +import ( + "context" + "fmt" + "os" + openapiclient "./openapi" +) + +func main() { + + configuration := openapiclient.NewConfiguration() + apiClient := openapiclient.NewAPIClient(configuration) + resp, r, err := apiClient.MainMenuApi.MainMenuGet(context.Background()).Execute() + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `MainMenuApi.MainMenuGet``: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + // response from `MainMenuGet`: []MainMenuGroup + fmt.Fprintf(os.Stdout, "Response from `MainMenuApi.MainMenuGet`: %v\n", resp) +} +``` + +### Path Parameters + +This endpoint does not need any parameter. + +### Other Parameters + +Other parameters are passed through a pointer to a apiMainMenuGetRequest struct via the builder pattern + + +### Return type + +[**[]MainMenuGroup**](MainMenuGroup.md) + +### Authorization + +[ApiToken](../README.md#ApiToken), [ServiceBearer](../README.md#ServiceBearer), [ServiceToken](../README.md#ServiceToken) + +### HTTP request headers + +- **Content-Type**: Not defined +- **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) + diff --git a/generated/stackstate_api/docs/MainMenuGroup.md b/generated/stackstate_api/docs/MainMenuGroup.md new file mode 100644 index 00000000..a5d04102 --- /dev/null +++ b/generated/stackstate_api/docs/MainMenuGroup.md @@ -0,0 +1,166 @@ +# MainMenuGroup + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Name** | **string** | | +**Identifier** | Pointer to **string** | | [optional] +**Description** | Pointer to **string** | | [optional] +**DefaultOpen** | **bool** | | +**Iconbase64** | **string** | | +**Items** | [**[]MainMenuViewItem**](MainMenuViewItem.md) | | + +## Methods + +### NewMainMenuGroup + +`func NewMainMenuGroup(name string, defaultOpen bool, iconbase64 string, items []MainMenuViewItem, ) *MainMenuGroup` + +NewMainMenuGroup instantiates a new MainMenuGroup object +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 + +### NewMainMenuGroupWithDefaults + +`func NewMainMenuGroupWithDefaults() *MainMenuGroup` + +NewMainMenuGroupWithDefaults instantiates a new MainMenuGroup object +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 + +### GetName + +`func (o *MainMenuGroup) GetName() string` + +GetName returns the Name field if non-nil, zero value otherwise. + +### GetNameOk + +`func (o *MainMenuGroup) GetNameOk() (*string, bool)` + +GetNameOk returns a tuple with the Name field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetName + +`func (o *MainMenuGroup) SetName(v string)` + +SetName sets Name field to given value. + + +### GetIdentifier + +`func (o *MainMenuGroup) GetIdentifier() string` + +GetIdentifier returns the Identifier field if non-nil, zero value otherwise. + +### GetIdentifierOk + +`func (o *MainMenuGroup) GetIdentifierOk() (*string, bool)` + +GetIdentifierOk returns a tuple with the Identifier field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetIdentifier + +`func (o *MainMenuGroup) SetIdentifier(v string)` + +SetIdentifier sets Identifier field to given value. + +### HasIdentifier + +`func (o *MainMenuGroup) HasIdentifier() bool` + +HasIdentifier returns a boolean if a field has been set. + +### GetDescription + +`func (o *MainMenuGroup) GetDescription() string` + +GetDescription returns the Description field if non-nil, zero value otherwise. + +### GetDescriptionOk + +`func (o *MainMenuGroup) GetDescriptionOk() (*string, bool)` + +GetDescriptionOk returns a tuple with the Description field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetDescription + +`func (o *MainMenuGroup) SetDescription(v string)` + +SetDescription sets Description field to given value. + +### HasDescription + +`func (o *MainMenuGroup) HasDescription() bool` + +HasDescription returns a boolean if a field has been set. + +### GetDefaultOpen + +`func (o *MainMenuGroup) GetDefaultOpen() bool` + +GetDefaultOpen returns the DefaultOpen field if non-nil, zero value otherwise. + +### GetDefaultOpenOk + +`func (o *MainMenuGroup) GetDefaultOpenOk() (*bool, bool)` + +GetDefaultOpenOk returns a tuple with the DefaultOpen field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetDefaultOpen + +`func (o *MainMenuGroup) SetDefaultOpen(v bool)` + +SetDefaultOpen sets DefaultOpen field to given value. + + +### GetIconbase64 + +`func (o *MainMenuGroup) GetIconbase64() string` + +GetIconbase64 returns the Iconbase64 field if non-nil, zero value otherwise. + +### GetIconbase64Ok + +`func (o *MainMenuGroup) GetIconbase64Ok() (*string, bool)` + +GetIconbase64Ok returns a tuple with the Iconbase64 field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetIconbase64 + +`func (o *MainMenuGroup) SetIconbase64(v string)` + +SetIconbase64 sets Iconbase64 field to given value. + + +### GetItems + +`func (o *MainMenuGroup) GetItems() []MainMenuViewItem` + +GetItems returns the Items field if non-nil, zero value otherwise. + +### GetItemsOk + +`func (o *MainMenuGroup) GetItemsOk() (*[]MainMenuViewItem, bool)` + +GetItemsOk returns a tuple with the Items field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetItems + +`func (o *MainMenuGroup) SetItems(v []MainMenuViewItem)` + +SetItems sets Items field to given value. + + + +[[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/MainMenuViewItem.md b/generated/stackstate_api/docs/MainMenuViewItem.md new file mode 100644 index 00000000..d21d491e --- /dev/null +++ b/generated/stackstate_api/docs/MainMenuViewItem.md @@ -0,0 +1,51 @@ +# MainMenuViewItem + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**ViewIdentifier** | **string** | | + +## Methods + +### NewMainMenuViewItem + +`func NewMainMenuViewItem(viewIdentifier string, ) *MainMenuViewItem` + +NewMainMenuViewItem instantiates a new MainMenuViewItem object +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 + +### NewMainMenuViewItemWithDefaults + +`func NewMainMenuViewItemWithDefaults() *MainMenuViewItem` + +NewMainMenuViewItemWithDefaults instantiates a new MainMenuViewItem object +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 + +### GetViewIdentifier + +`func (o *MainMenuViewItem) GetViewIdentifier() string` + +GetViewIdentifier returns the ViewIdentifier field if non-nil, zero value otherwise. + +### GetViewIdentifierOk + +`func (o *MainMenuViewItem) GetViewIdentifierOk() (*string, bool)` + +GetViewIdentifierOk returns a tuple with the ViewIdentifier field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetViewIdentifier + +`func (o *MainMenuViewItem) SetViewIdentifier(v string)` + +SetViewIdentifier sets ViewIdentifier field to given value. + + + +[[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/QueryMetadata.md b/generated/stackstate_api/docs/QueryMetadata.md new file mode 100644 index 00000000..d04457aa --- /dev/null +++ b/generated/stackstate_api/docs/QueryMetadata.md @@ -0,0 +1,276 @@ +# QueryMetadata + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**GroupingEnabled** | **bool** | | +**ShowIndirectRelations** | **bool** | | +**MinGroupSize** | **int64** | | +**GroupedByLayer** | **bool** | | +**GroupedByDomain** | **bool** | | +**GroupedByRelation** | **bool** | | +**QueryTime** | Pointer to **NullableInt64** | Unix timestamp in milliseconds | [optional] +**AutoGrouping** | **bool** | | +**ConnectedComponents** | **bool** | | +**NeighboringComponents** | **bool** | | +**ShowFullComponent** | **bool** | | + +## Methods + +### NewQueryMetadata + +`func NewQueryMetadata(groupingEnabled bool, showIndirectRelations bool, minGroupSize int64, groupedByLayer bool, groupedByDomain bool, groupedByRelation bool, autoGrouping bool, connectedComponents bool, neighboringComponents bool, showFullComponent bool, ) *QueryMetadata` + +NewQueryMetadata instantiates a new QueryMetadata object +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 + +### NewQueryMetadataWithDefaults + +`func NewQueryMetadataWithDefaults() *QueryMetadata` + +NewQueryMetadataWithDefaults instantiates a new QueryMetadata object +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 + +### GetGroupingEnabled + +`func (o *QueryMetadata) GetGroupingEnabled() bool` + +GetGroupingEnabled returns the GroupingEnabled field if non-nil, zero value otherwise. + +### GetGroupingEnabledOk + +`func (o *QueryMetadata) GetGroupingEnabledOk() (*bool, bool)` + +GetGroupingEnabledOk returns a tuple with the GroupingEnabled field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetGroupingEnabled + +`func (o *QueryMetadata) SetGroupingEnabled(v bool)` + +SetGroupingEnabled sets GroupingEnabled field to given value. + + +### GetShowIndirectRelations + +`func (o *QueryMetadata) GetShowIndirectRelations() bool` + +GetShowIndirectRelations returns the ShowIndirectRelations field if non-nil, zero value otherwise. + +### GetShowIndirectRelationsOk + +`func (o *QueryMetadata) GetShowIndirectRelationsOk() (*bool, bool)` + +GetShowIndirectRelationsOk returns a tuple with the ShowIndirectRelations field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetShowIndirectRelations + +`func (o *QueryMetadata) SetShowIndirectRelations(v bool)` + +SetShowIndirectRelations sets ShowIndirectRelations field to given value. + + +### GetMinGroupSize + +`func (o *QueryMetadata) GetMinGroupSize() int64` + +GetMinGroupSize returns the MinGroupSize field if non-nil, zero value otherwise. + +### GetMinGroupSizeOk + +`func (o *QueryMetadata) GetMinGroupSizeOk() (*int64, bool)` + +GetMinGroupSizeOk returns a tuple with the MinGroupSize field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetMinGroupSize + +`func (o *QueryMetadata) SetMinGroupSize(v int64)` + +SetMinGroupSize sets MinGroupSize field to given value. + + +### GetGroupedByLayer + +`func (o *QueryMetadata) GetGroupedByLayer() bool` + +GetGroupedByLayer returns the GroupedByLayer field if non-nil, zero value otherwise. + +### GetGroupedByLayerOk + +`func (o *QueryMetadata) GetGroupedByLayerOk() (*bool, bool)` + +GetGroupedByLayerOk returns a tuple with the GroupedByLayer field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetGroupedByLayer + +`func (o *QueryMetadata) SetGroupedByLayer(v bool)` + +SetGroupedByLayer sets GroupedByLayer field to given value. + + +### GetGroupedByDomain + +`func (o *QueryMetadata) GetGroupedByDomain() bool` + +GetGroupedByDomain returns the GroupedByDomain field if non-nil, zero value otherwise. + +### GetGroupedByDomainOk + +`func (o *QueryMetadata) GetGroupedByDomainOk() (*bool, bool)` + +GetGroupedByDomainOk returns a tuple with the GroupedByDomain field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetGroupedByDomain + +`func (o *QueryMetadata) SetGroupedByDomain(v bool)` + +SetGroupedByDomain sets GroupedByDomain field to given value. + + +### GetGroupedByRelation + +`func (o *QueryMetadata) GetGroupedByRelation() bool` + +GetGroupedByRelation returns the GroupedByRelation field if non-nil, zero value otherwise. + +### GetGroupedByRelationOk + +`func (o *QueryMetadata) GetGroupedByRelationOk() (*bool, bool)` + +GetGroupedByRelationOk returns a tuple with the GroupedByRelation field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetGroupedByRelation + +`func (o *QueryMetadata) SetGroupedByRelation(v bool)` + +SetGroupedByRelation sets GroupedByRelation field to given value. + + +### GetQueryTime + +`func (o *QueryMetadata) GetQueryTime() int64` + +GetQueryTime returns the QueryTime field if non-nil, zero value otherwise. + +### GetQueryTimeOk + +`func (o *QueryMetadata) GetQueryTimeOk() (*int64, bool)` + +GetQueryTimeOk returns a tuple with the QueryTime field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetQueryTime + +`func (o *QueryMetadata) SetQueryTime(v int64)` + +SetQueryTime sets QueryTime field to given value. + +### HasQueryTime + +`func (o *QueryMetadata) HasQueryTime() bool` + +HasQueryTime returns a boolean if a field has been set. + +### SetQueryTimeNil + +`func (o *QueryMetadata) SetQueryTimeNil(b bool)` + + SetQueryTimeNil sets the value for QueryTime to be an explicit nil + +### UnsetQueryTime +`func (o *QueryMetadata) UnsetQueryTime()` + +UnsetQueryTime ensures that no value is present for QueryTime, not even an explicit nil +### GetAutoGrouping + +`func (o *QueryMetadata) GetAutoGrouping() bool` + +GetAutoGrouping returns the AutoGrouping field if non-nil, zero value otherwise. + +### GetAutoGroupingOk + +`func (o *QueryMetadata) GetAutoGroupingOk() (*bool, bool)` + +GetAutoGroupingOk returns a tuple with the AutoGrouping field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetAutoGrouping + +`func (o *QueryMetadata) SetAutoGrouping(v bool)` + +SetAutoGrouping sets AutoGrouping field to given value. + + +### GetConnectedComponents + +`func (o *QueryMetadata) GetConnectedComponents() bool` + +GetConnectedComponents returns the ConnectedComponents field if non-nil, zero value otherwise. + +### GetConnectedComponentsOk + +`func (o *QueryMetadata) GetConnectedComponentsOk() (*bool, bool)` + +GetConnectedComponentsOk returns a tuple with the ConnectedComponents field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetConnectedComponents + +`func (o *QueryMetadata) SetConnectedComponents(v bool)` + +SetConnectedComponents sets ConnectedComponents field to given value. + + +### GetNeighboringComponents + +`func (o *QueryMetadata) GetNeighboringComponents() bool` + +GetNeighboringComponents returns the NeighboringComponents field if non-nil, zero value otherwise. + +### GetNeighboringComponentsOk + +`func (o *QueryMetadata) GetNeighboringComponentsOk() (*bool, bool)` + +GetNeighboringComponentsOk returns a tuple with the NeighboringComponents field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetNeighboringComponents + +`func (o *QueryMetadata) SetNeighboringComponents(v bool)` + +SetNeighboringComponents sets NeighboringComponents field to given value. + + +### GetShowFullComponent + +`func (o *QueryMetadata) GetShowFullComponent() bool` + +GetShowFullComponent returns the ShowFullComponent field if non-nil, zero value otherwise. + +### GetShowFullComponentOk + +`func (o *QueryMetadata) GetShowFullComponentOk() (*bool, bool)` + +GetShowFullComponentOk returns a tuple with the ShowFullComponent field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetShowFullComponent + +`func (o *QueryMetadata) SetShowFullComponent(v bool)` + +SetShowFullComponent sets ShowFullComponent field to given value. + + + +[[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/QueryParsingFailure.md b/generated/stackstate_api/docs/QueryParsingFailure.md new file mode 100644 index 00000000..2c6def31 --- /dev/null +++ b/generated/stackstate_api/docs/QueryParsingFailure.md @@ -0,0 +1,72 @@ +# QueryParsingFailure + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Type** | **string** | Discriminator field | +**Reason** | **string** | Error message describing why the query failed to parse | + +## Methods + +### NewQueryParsingFailure + +`func NewQueryParsingFailure(type_ string, reason string, ) *QueryParsingFailure` + +NewQueryParsingFailure instantiates a new QueryParsingFailure object +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 + +### NewQueryParsingFailureWithDefaults + +`func NewQueryParsingFailureWithDefaults() *QueryParsingFailure` + +NewQueryParsingFailureWithDefaults instantiates a new QueryParsingFailure object +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 + +### GetType + +`func (o *QueryParsingFailure) GetType() string` + +GetType returns the Type field if non-nil, zero value otherwise. + +### GetTypeOk + +`func (o *QueryParsingFailure) GetTypeOk() (*string, bool)` + +GetTypeOk returns a tuple with the Type field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetType + +`func (o *QueryParsingFailure) SetType(v string)` + +SetType sets Type field to given value. + + +### GetReason + +`func (o *QueryParsingFailure) GetReason() string` + +GetReason returns the Reason field if non-nil, zero value otherwise. + +### GetReasonOk + +`func (o *QueryParsingFailure) GetReasonOk() (*string, bool)` + +GetReasonOk returns a tuple with the Reason field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetReason + +`func (o *QueryParsingFailure) SetReason(v string)` + +SetReason sets Reason field to given value. + + + +[[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/QuerySnapshotResult.md b/generated/stackstate_api/docs/QuerySnapshotResult.md new file mode 100644 index 00000000..f41fc08d --- /dev/null +++ b/generated/stackstate_api/docs/QuerySnapshotResult.md @@ -0,0 +1,108 @@ +# QuerySnapshotResult + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Type** | **string** | Discriminator field | +**ViewSnapshotResponse** | **map[string]interface{}** | The query result or error response. This is opaque at the API level but contains one of: - ViewSnapshot (success) - ViewSnapshotFetchTimeout (error) - ViewSnapshotTooManyActiveQueries (error) - ViewSnapshotTopologySizeOverflow (error) - ViewSnapshotDataUnavailable (error) Use the _type field to discriminate between types. | +**ViewId** | Pointer to **NullableInt64** | Optional view ID associated with this result | [optional] + +## Methods + +### NewQuerySnapshotResult + +`func NewQuerySnapshotResult(type_ string, viewSnapshotResponse map[string]interface{}, ) *QuerySnapshotResult` + +NewQuerySnapshotResult instantiates a new QuerySnapshotResult object +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 + +### NewQuerySnapshotResultWithDefaults + +`func NewQuerySnapshotResultWithDefaults() *QuerySnapshotResult` + +NewQuerySnapshotResultWithDefaults instantiates a new QuerySnapshotResult object +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 + +### GetType + +`func (o *QuerySnapshotResult) GetType() string` + +GetType returns the Type field if non-nil, zero value otherwise. + +### GetTypeOk + +`func (o *QuerySnapshotResult) GetTypeOk() (*string, bool)` + +GetTypeOk returns a tuple with the Type field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetType + +`func (o *QuerySnapshotResult) SetType(v string)` + +SetType sets Type field to given value. + + +### GetViewSnapshotResponse + +`func (o *QuerySnapshotResult) GetViewSnapshotResponse() map[string]interface{}` + +GetViewSnapshotResponse returns the ViewSnapshotResponse field if non-nil, zero value otherwise. + +### GetViewSnapshotResponseOk + +`func (o *QuerySnapshotResult) GetViewSnapshotResponseOk() (*map[string]interface{}, bool)` + +GetViewSnapshotResponseOk returns a tuple with the ViewSnapshotResponse field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetViewSnapshotResponse + +`func (o *QuerySnapshotResult) SetViewSnapshotResponse(v map[string]interface{})` + +SetViewSnapshotResponse sets ViewSnapshotResponse field to given value. + + +### GetViewId + +`func (o *QuerySnapshotResult) GetViewId() int64` + +GetViewId returns the ViewId field if non-nil, zero value otherwise. + +### GetViewIdOk + +`func (o *QuerySnapshotResult) GetViewIdOk() (*int64, bool)` + +GetViewIdOk returns a tuple with the ViewId field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetViewId + +`func (o *QuerySnapshotResult) SetViewId(v int64)` + +SetViewId sets ViewId field to given value. + +### HasViewId + +`func (o *QuerySnapshotResult) HasViewId() bool` + +HasViewId returns a boolean if a field has been set. + +### SetViewIdNil + +`func (o *QuerySnapshotResult) SetViewIdNil(b bool)` + + SetViewIdNil sets the value for ViewId to be an explicit nil + +### UnsetViewId +`func (o *QuerySnapshotResult) UnsetViewId()` + +UnsetViewId ensures that no value is present for ViewId, not even an explicit nil + +[[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/SnapshotApi.md b/generated/stackstate_api/docs/SnapshotApi.md new file mode 100644 index 00000000..5cf9a7fa --- /dev/null +++ b/generated/stackstate_api/docs/SnapshotApi.md @@ -0,0 +1,75 @@ +# \SnapshotApi + +All URIs are relative to *http://localhost* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**QuerySnapshot**](SnapshotApi.md#QuerySnapshot) | **Post** /snapshot | Query topology snapshot + + + +## QuerySnapshot + +> QuerySnapshotResult QuerySnapshot(ctx).ViewSnapshotRequest(viewSnapshotRequest).TimeoutMs(timeoutMs).Execute() + +Query topology snapshot + +### Example + +```go +package main + +import ( + "context" + "fmt" + "os" + openapiclient "./openapi" +) + +func main() { + viewSnapshotRequest := *openapiclient.NewViewSnapshotRequest("Type_example", "Query_example", "0.0.1", *openapiclient.NewQueryMetadata(false, false, int64(123), false, false, false, false, false, false, false)) // ViewSnapshotRequest | Request body for querying a topology snapshot + timeoutMs := int64(789) // int64 | Query timeout in milliseconds (optional) (default to 30000) + + configuration := openapiclient.NewConfiguration() + apiClient := openapiclient.NewAPIClient(configuration) + resp, r, err := apiClient.SnapshotApi.QuerySnapshot(context.Background()).ViewSnapshotRequest(viewSnapshotRequest).TimeoutMs(timeoutMs).Execute() + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SnapshotApi.QuerySnapshot``: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + // response from `QuerySnapshot`: QuerySnapshotResult + fmt.Fprintf(os.Stdout, "Response from `SnapshotApi.QuerySnapshot`: %v\n", resp) +} +``` + +### Path Parameters + + + +### Other Parameters + +Other parameters are passed through a pointer to a apiQuerySnapshotRequest struct via the builder pattern + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **viewSnapshotRequest** | [**ViewSnapshotRequest**](ViewSnapshotRequest.md) | Request body for querying a topology snapshot | + **timeoutMs** | **int64** | Query timeout in milliseconds | [default to 30000] + +### Return type + +[**QuerySnapshotResult**](QuerySnapshotResult.md) + +### Authorization + +[ApiToken](../README.md#ApiToken), [ServiceBearer](../README.md#ServiceBearer), [ServiceToken](../README.md#ServiceToken) + +### HTTP request headers + +- **Content-Type**: application/json +- **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) + diff --git a/generated/stackstate_api/docs/ViewSnapshotRequest.md b/generated/stackstate_api/docs/ViewSnapshotRequest.md new file mode 100644 index 00000000..693cc9ef --- /dev/null +++ b/generated/stackstate_api/docs/ViewSnapshotRequest.md @@ -0,0 +1,150 @@ +# ViewSnapshotRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Type** | **string** | | +**Query** | **string** | STQL query string | +**QueryVersion** | **string** | | +**Metadata** | [**QueryMetadata**](QueryMetadata.md) | | +**ViewId** | Pointer to **NullableInt64** | | [optional] + +## Methods + +### NewViewSnapshotRequest + +`func NewViewSnapshotRequest(type_ string, query string, queryVersion string, metadata QueryMetadata, ) *ViewSnapshotRequest` + +NewViewSnapshotRequest instantiates a new ViewSnapshotRequest object +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 + +### NewViewSnapshotRequestWithDefaults + +`func NewViewSnapshotRequestWithDefaults() *ViewSnapshotRequest` + +NewViewSnapshotRequestWithDefaults instantiates a new ViewSnapshotRequest object +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 + +### GetType + +`func (o *ViewSnapshotRequest) GetType() string` + +GetType returns the Type field if non-nil, zero value otherwise. + +### GetTypeOk + +`func (o *ViewSnapshotRequest) GetTypeOk() (*string, bool)` + +GetTypeOk returns a tuple with the Type field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetType + +`func (o *ViewSnapshotRequest) SetType(v string)` + +SetType sets Type field to given value. + + +### GetQuery + +`func (o *ViewSnapshotRequest) GetQuery() string` + +GetQuery returns the Query field if non-nil, zero value otherwise. + +### GetQueryOk + +`func (o *ViewSnapshotRequest) GetQueryOk() (*string, bool)` + +GetQueryOk returns a tuple with the Query field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetQuery + +`func (o *ViewSnapshotRequest) SetQuery(v string)` + +SetQuery sets Query field to given value. + + +### GetQueryVersion + +`func (o *ViewSnapshotRequest) GetQueryVersion() string` + +GetQueryVersion returns the QueryVersion field if non-nil, zero value otherwise. + +### GetQueryVersionOk + +`func (o *ViewSnapshotRequest) GetQueryVersionOk() (*string, bool)` + +GetQueryVersionOk returns a tuple with the QueryVersion field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetQueryVersion + +`func (o *ViewSnapshotRequest) SetQueryVersion(v string)` + +SetQueryVersion sets QueryVersion field to given value. + + +### GetMetadata + +`func (o *ViewSnapshotRequest) GetMetadata() QueryMetadata` + +GetMetadata returns the Metadata field if non-nil, zero value otherwise. + +### GetMetadataOk + +`func (o *ViewSnapshotRequest) GetMetadataOk() (*QueryMetadata, bool)` + +GetMetadataOk returns a tuple with the Metadata field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetMetadata + +`func (o *ViewSnapshotRequest) SetMetadata(v QueryMetadata)` + +SetMetadata sets Metadata field to given value. + + +### GetViewId + +`func (o *ViewSnapshotRequest) GetViewId() int64` + +GetViewId returns the ViewId field if non-nil, zero value otherwise. + +### GetViewIdOk + +`func (o *ViewSnapshotRequest) GetViewIdOk() (*int64, bool)` + +GetViewIdOk returns a tuple with the ViewId field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetViewId + +`func (o *ViewSnapshotRequest) SetViewId(v int64)` + +SetViewId sets ViewId field to given value. + +### HasViewId + +`func (o *ViewSnapshotRequest) HasViewId() bool` + +HasViewId returns a boolean if a field has been set. + +### SetViewIdNil + +`func (o *ViewSnapshotRequest) SetViewIdNil(b bool)` + + SetViewIdNil sets the value for ViewId to be an explicit nil + +### UnsetViewId +`func (o *ViewSnapshotRequest) UnsetViewId()` + +UnsetViewId ensures that no value is present for ViewId, not even an explicit nil + +[[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/model_main_menu_group.go b/generated/stackstate_api/model_main_menu_group.go new file mode 100644 index 00000000..351f2508 --- /dev/null +++ b/generated/stackstate_api/model_main_menu_group.go @@ -0,0 +1,266 @@ +/* +StackState API + +This API documentation page describes the StackState server API. The StackState UI and CLI use the StackState server API to configure and query StackState. You can use the API for similar purposes. Each request sent to the StackState server API must be authenticated using one of the available authentication methods. *Note that the StackState receiver API, used to send topology, telemetry and traces to StackState, is not described on this page and requires a different authentication method.* For more information on StackState, refer to the [StackState documentation](https://docs.stackstate.com). + +API version: 5.2.0 +Contact: info@stackstate.com +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package stackstate_api + +import ( + "encoding/json" +) + +// MainMenuGroup struct for MainMenuGroup +type MainMenuGroup struct { + Name string `json:"name" yaml:"name"` + 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"` + Items []MainMenuViewItem `json:"items" yaml:"items"` +} + +// NewMainMenuGroup instantiates a new MainMenuGroup object +// 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 { + this := MainMenuGroup{} + this.Name = name + this.DefaultOpen = defaultOpen + this.Iconbase64 = iconbase64 + this.Items = items + return &this +} + +// NewMainMenuGroupWithDefaults instantiates a new MainMenuGroup object +// 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 +func NewMainMenuGroupWithDefaults() *MainMenuGroup { + this := MainMenuGroup{} + return &this +} + +// GetName returns the Name field value +func (o *MainMenuGroup) GetName() string { + if o == nil { + var ret string + return ret + } + + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *MainMenuGroup) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value +func (o *MainMenuGroup) SetName(v string) { + o.Name = v +} + +// GetIdentifier returns the Identifier field value if set, zero value otherwise. +func (o *MainMenuGroup) GetIdentifier() string { + if o == nil || o.Identifier == nil { + var ret string + return ret + } + return *o.Identifier +} + +// GetIdentifierOk returns a tuple with the Identifier field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MainMenuGroup) GetIdentifierOk() (*string, bool) { + if o == nil || o.Identifier == nil { + return nil, false + } + return o.Identifier, true +} + +// HasIdentifier returns a boolean if a field has been set. +func (o *MainMenuGroup) HasIdentifier() bool { + if o != nil && o.Identifier != nil { + return true + } + + return false +} + +// SetIdentifier gets a reference to the given string and assigns it to the Identifier field. +func (o *MainMenuGroup) SetIdentifier(v string) { + o.Identifier = &v +} + +// GetDescription returns the Description field value if set, zero value otherwise. +func (o *MainMenuGroup) GetDescription() string { + if o == nil || o.Description == nil { + var ret string + return ret + } + return *o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MainMenuGroup) GetDescriptionOk() (*string, bool) { + if o == nil || o.Description == nil { + return nil, false + } + return o.Description, true +} + +// HasDescription returns a boolean if a field has been set. +func (o *MainMenuGroup) HasDescription() bool { + if o != nil && o.Description != nil { + return true + } + + return false +} + +// SetDescription gets a reference to the given string and assigns it to the Description field. +func (o *MainMenuGroup) SetDescription(v string) { + o.Description = &v +} + +// GetDefaultOpen returns the DefaultOpen field value +func (o *MainMenuGroup) GetDefaultOpen() bool { + if o == nil { + var ret bool + return ret + } + + return o.DefaultOpen +} + +// GetDefaultOpenOk returns a tuple with the DefaultOpen field value +// and a boolean to check if the value has been set. +func (o *MainMenuGroup) GetDefaultOpenOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.DefaultOpen, true +} + +// SetDefaultOpen sets field value +func (o *MainMenuGroup) SetDefaultOpen(v bool) { + o.DefaultOpen = v +} + +// GetIconbase64 returns the Iconbase64 field value +func (o *MainMenuGroup) GetIconbase64() string { + if o == nil { + var ret string + return ret + } + + return o.Iconbase64 +} + +// GetIconbase64Ok returns a tuple with the Iconbase64 field value +// and a boolean to check if the value has been set. +func (o *MainMenuGroup) GetIconbase64Ok() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Iconbase64, true +} + +// SetIconbase64 sets field value +func (o *MainMenuGroup) SetIconbase64(v string) { + o.Iconbase64 = v +} + +// GetItems returns the Items field value +func (o *MainMenuGroup) GetItems() []MainMenuViewItem { + if o == nil { + var ret []MainMenuViewItem + return ret + } + + return o.Items +} + +// GetItemsOk returns a tuple with the Items field value +// and a boolean to check if the value has been set. +func (o *MainMenuGroup) GetItemsOk() ([]MainMenuViewItem, bool) { + if o == nil { + return nil, false + } + return o.Items, true +} + +// SetItems sets field value +func (o *MainMenuGroup) SetItems(v []MainMenuViewItem) { + o.Items = v +} + +func (o MainMenuGroup) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if true { + toSerialize["name"] = o.Name + } + if o.Identifier != nil { + toSerialize["identifier"] = o.Identifier + } + if o.Description != nil { + toSerialize["description"] = o.Description + } + if true { + toSerialize["defaultOpen"] = o.DefaultOpen + } + if true { + toSerialize["iconbase64"] = o.Iconbase64 + } + if true { + toSerialize["items"] = o.Items + } + return json.Marshal(toSerialize) +} + +type NullableMainMenuGroup struct { + value *MainMenuGroup + isSet bool +} + +func (v NullableMainMenuGroup) Get() *MainMenuGroup { + return v.value +} + +func (v *NullableMainMenuGroup) Set(val *MainMenuGroup) { + v.value = val + v.isSet = true +} + +func (v NullableMainMenuGroup) IsSet() bool { + return v.isSet +} + +func (v *NullableMainMenuGroup) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableMainMenuGroup(val *MainMenuGroup) *NullableMainMenuGroup { + return &NullableMainMenuGroup{value: val, isSet: true} +} + +func (v NullableMainMenuGroup) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableMainMenuGroup) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/generated/stackstate_api/model_main_menu_view_item.go b/generated/stackstate_api/model_main_menu_view_item.go new file mode 100644 index 00000000..400278fa --- /dev/null +++ b/generated/stackstate_api/model_main_menu_view_item.go @@ -0,0 +1,107 @@ +/* +StackState API + +This API documentation page describes the StackState server API. The StackState UI and CLI use the StackState server API to configure and query StackState. You can use the API for similar purposes. Each request sent to the StackState server API must be authenticated using one of the available authentication methods. *Note that the StackState receiver API, used to send topology, telemetry and traces to StackState, is not described on this page and requires a different authentication method.* For more information on StackState, refer to the [StackState documentation](https://docs.stackstate.com). + +API version: 5.2.0 +Contact: info@stackstate.com +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package stackstate_api + +import ( + "encoding/json" +) + +// MainMenuViewItem struct for MainMenuViewItem +type MainMenuViewItem struct { + ViewIdentifier string `json:"viewIdentifier" yaml:"viewIdentifier"` +} + +// NewMainMenuViewItem instantiates a new MainMenuViewItem object +// 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 NewMainMenuViewItem(viewIdentifier string) *MainMenuViewItem { + this := MainMenuViewItem{} + this.ViewIdentifier = viewIdentifier + return &this +} + +// NewMainMenuViewItemWithDefaults instantiates a new MainMenuViewItem object +// 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 +func NewMainMenuViewItemWithDefaults() *MainMenuViewItem { + this := MainMenuViewItem{} + return &this +} + +// GetViewIdentifier returns the ViewIdentifier field value +func (o *MainMenuViewItem) GetViewIdentifier() string { + if o == nil { + var ret string + return ret + } + + return o.ViewIdentifier +} + +// GetViewIdentifierOk returns a tuple with the ViewIdentifier field value +// and a boolean to check if the value has been set. +func (o *MainMenuViewItem) GetViewIdentifierOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ViewIdentifier, true +} + +// SetViewIdentifier sets field value +func (o *MainMenuViewItem) SetViewIdentifier(v string) { + o.ViewIdentifier = v +} + +func (o MainMenuViewItem) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if true { + toSerialize["viewIdentifier"] = o.ViewIdentifier + } + return json.Marshal(toSerialize) +} + +type NullableMainMenuViewItem struct { + value *MainMenuViewItem + isSet bool +} + +func (v NullableMainMenuViewItem) Get() *MainMenuViewItem { + return v.value +} + +func (v *NullableMainMenuViewItem) Set(val *MainMenuViewItem) { + v.value = val + v.isSet = true +} + +func (v NullableMainMenuViewItem) IsSet() bool { + return v.isSet +} + +func (v *NullableMainMenuViewItem) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableMainMenuViewItem(val *MainMenuViewItem) *NullableMainMenuViewItem { + return &NullableMainMenuViewItem{value: val, isSet: true} +} + +func (v NullableMainMenuViewItem) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableMainMenuViewItem) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/generated/stackstate_api/model_query_metadata.go b/generated/stackstate_api/model_query_metadata.go new file mode 100644 index 00000000..51e898eb --- /dev/null +++ b/generated/stackstate_api/model_query_metadata.go @@ -0,0 +1,416 @@ +/* +StackState API + +This API documentation page describes the StackState server API. The StackState UI and CLI use the StackState server API to configure and query StackState. You can use the API for similar purposes. Each request sent to the StackState server API must be authenticated using one of the available authentication methods. *Note that the StackState receiver API, used to send topology, telemetry and traces to StackState, is not described on this page and requires a different authentication method.* For more information on StackState, refer to the [StackState documentation](https://docs.stackstate.com). + +API version: 5.2.0 +Contact: info@stackstate.com +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package stackstate_api + +import ( + "encoding/json" +) + +// QueryMetadata Query execution settings +type QueryMetadata struct { + GroupingEnabled bool `json:"groupingEnabled" yaml:"groupingEnabled"` + ShowIndirectRelations bool `json:"showIndirectRelations" yaml:"showIndirectRelations"` + MinGroupSize int64 `json:"minGroupSize" yaml:"minGroupSize"` + GroupedByLayer bool `json:"groupedByLayer" yaml:"groupedByLayer"` + GroupedByDomain bool `json:"groupedByDomain" yaml:"groupedByDomain"` + GroupedByRelation bool `json:"groupedByRelation" yaml:"groupedByRelation"` + // Unix timestamp in milliseconds + QueryTime NullableInt64 `json:"queryTime,omitempty" yaml:"queryTime,omitempty"` + AutoGrouping bool `json:"autoGrouping" yaml:"autoGrouping"` + ConnectedComponents bool `json:"connectedComponents" yaml:"connectedComponents"` + NeighboringComponents bool `json:"neighboringComponents" yaml:"neighboringComponents"` + ShowFullComponent bool `json:"showFullComponent" yaml:"showFullComponent"` +} + +// NewQueryMetadata instantiates a new QueryMetadata object +// 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 NewQueryMetadata(groupingEnabled bool, showIndirectRelations bool, minGroupSize int64, groupedByLayer bool, groupedByDomain bool, groupedByRelation bool, autoGrouping bool, connectedComponents bool, neighboringComponents bool, showFullComponent bool) *QueryMetadata { + this := QueryMetadata{} + this.GroupingEnabled = groupingEnabled + this.ShowIndirectRelations = showIndirectRelations + this.MinGroupSize = minGroupSize + this.GroupedByLayer = groupedByLayer + this.GroupedByDomain = groupedByDomain + this.GroupedByRelation = groupedByRelation + this.AutoGrouping = autoGrouping + this.ConnectedComponents = connectedComponents + this.NeighboringComponents = neighboringComponents + this.ShowFullComponent = showFullComponent + return &this +} + +// NewQueryMetadataWithDefaults instantiates a new QueryMetadata object +// 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 +func NewQueryMetadataWithDefaults() *QueryMetadata { + this := QueryMetadata{} + return &this +} + +// GetGroupingEnabled returns the GroupingEnabled field value +func (o *QueryMetadata) GetGroupingEnabled() bool { + if o == nil { + var ret bool + return ret + } + + return o.GroupingEnabled +} + +// GetGroupingEnabledOk returns a tuple with the GroupingEnabled field value +// and a boolean to check if the value has been set. +func (o *QueryMetadata) GetGroupingEnabledOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.GroupingEnabled, true +} + +// SetGroupingEnabled sets field value +func (o *QueryMetadata) SetGroupingEnabled(v bool) { + o.GroupingEnabled = v +} + +// GetShowIndirectRelations returns the ShowIndirectRelations field value +func (o *QueryMetadata) GetShowIndirectRelations() bool { + if o == nil { + var ret bool + return ret + } + + return o.ShowIndirectRelations +} + +// GetShowIndirectRelationsOk returns a tuple with the ShowIndirectRelations field value +// and a boolean to check if the value has been set. +func (o *QueryMetadata) GetShowIndirectRelationsOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.ShowIndirectRelations, true +} + +// SetShowIndirectRelations sets field value +func (o *QueryMetadata) SetShowIndirectRelations(v bool) { + o.ShowIndirectRelations = v +} + +// GetMinGroupSize returns the MinGroupSize field value +func (o *QueryMetadata) GetMinGroupSize() int64 { + if o == nil { + var ret int64 + return ret + } + + return o.MinGroupSize +} + +// GetMinGroupSizeOk returns a tuple with the MinGroupSize field value +// and a boolean to check if the value has been set. +func (o *QueryMetadata) GetMinGroupSizeOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.MinGroupSize, true +} + +// SetMinGroupSize sets field value +func (o *QueryMetadata) SetMinGroupSize(v int64) { + o.MinGroupSize = v +} + +// GetGroupedByLayer returns the GroupedByLayer field value +func (o *QueryMetadata) GetGroupedByLayer() bool { + if o == nil { + var ret bool + return ret + } + + return o.GroupedByLayer +} + +// GetGroupedByLayerOk returns a tuple with the GroupedByLayer field value +// and a boolean to check if the value has been set. +func (o *QueryMetadata) GetGroupedByLayerOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.GroupedByLayer, true +} + +// SetGroupedByLayer sets field value +func (o *QueryMetadata) SetGroupedByLayer(v bool) { + o.GroupedByLayer = v +} + +// GetGroupedByDomain returns the GroupedByDomain field value +func (o *QueryMetadata) GetGroupedByDomain() bool { + if o == nil { + var ret bool + return ret + } + + return o.GroupedByDomain +} + +// GetGroupedByDomainOk returns a tuple with the GroupedByDomain field value +// and a boolean to check if the value has been set. +func (o *QueryMetadata) GetGroupedByDomainOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.GroupedByDomain, true +} + +// SetGroupedByDomain sets field value +func (o *QueryMetadata) SetGroupedByDomain(v bool) { + o.GroupedByDomain = v +} + +// GetGroupedByRelation returns the GroupedByRelation field value +func (o *QueryMetadata) GetGroupedByRelation() bool { + if o == nil { + var ret bool + return ret + } + + return o.GroupedByRelation +} + +// GetGroupedByRelationOk returns a tuple with the GroupedByRelation field value +// and a boolean to check if the value has been set. +func (o *QueryMetadata) GetGroupedByRelationOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.GroupedByRelation, true +} + +// SetGroupedByRelation sets field value +func (o *QueryMetadata) SetGroupedByRelation(v bool) { + o.GroupedByRelation = v +} + +// GetQueryTime returns the QueryTime field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *QueryMetadata) GetQueryTime() int64 { + if o == nil || o.QueryTime.Get() == nil { + var ret int64 + return ret + } + return *o.QueryTime.Get() +} + +// GetQueryTimeOk returns a tuple with the QueryTime field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned +func (o *QueryMetadata) GetQueryTimeOk() (*int64, bool) { + if o == nil { + return nil, false + } + return o.QueryTime.Get(), o.QueryTime.IsSet() +} + +// HasQueryTime returns a boolean if a field has been set. +func (o *QueryMetadata) HasQueryTime() bool { + if o != nil && o.QueryTime.IsSet() { + return true + } + + return false +} + +// SetQueryTime gets a reference to the given NullableInt64 and assigns it to the QueryTime field. +func (o *QueryMetadata) SetQueryTime(v int64) { + o.QueryTime.Set(&v) +} + +// SetQueryTimeNil sets the value for QueryTime to be an explicit nil +func (o *QueryMetadata) SetQueryTimeNil() { + o.QueryTime.Set(nil) +} + +// UnsetQueryTime ensures that no value is present for QueryTime, not even an explicit nil +func (o *QueryMetadata) UnsetQueryTime() { + o.QueryTime.Unset() +} + +// GetAutoGrouping returns the AutoGrouping field value +func (o *QueryMetadata) GetAutoGrouping() bool { + if o == nil { + var ret bool + return ret + } + + return o.AutoGrouping +} + +// GetAutoGroupingOk returns a tuple with the AutoGrouping field value +// and a boolean to check if the value has been set. +func (o *QueryMetadata) GetAutoGroupingOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.AutoGrouping, true +} + +// SetAutoGrouping sets field value +func (o *QueryMetadata) SetAutoGrouping(v bool) { + o.AutoGrouping = v +} + +// GetConnectedComponents returns the ConnectedComponents field value +func (o *QueryMetadata) GetConnectedComponents() bool { + if o == nil { + var ret bool + return ret + } + + return o.ConnectedComponents +} + +// GetConnectedComponentsOk returns a tuple with the ConnectedComponents field value +// and a boolean to check if the value has been set. +func (o *QueryMetadata) GetConnectedComponentsOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.ConnectedComponents, true +} + +// SetConnectedComponents sets field value +func (o *QueryMetadata) SetConnectedComponents(v bool) { + o.ConnectedComponents = v +} + +// GetNeighboringComponents returns the NeighboringComponents field value +func (o *QueryMetadata) GetNeighboringComponents() bool { + if o == nil { + var ret bool + return ret + } + + return o.NeighboringComponents +} + +// GetNeighboringComponentsOk returns a tuple with the NeighboringComponents field value +// and a boolean to check if the value has been set. +func (o *QueryMetadata) GetNeighboringComponentsOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.NeighboringComponents, true +} + +// SetNeighboringComponents sets field value +func (o *QueryMetadata) SetNeighboringComponents(v bool) { + o.NeighboringComponents = v +} + +// GetShowFullComponent returns the ShowFullComponent field value +func (o *QueryMetadata) GetShowFullComponent() bool { + if o == nil { + var ret bool + return ret + } + + return o.ShowFullComponent +} + +// GetShowFullComponentOk returns a tuple with the ShowFullComponent field value +// and a boolean to check if the value has been set. +func (o *QueryMetadata) GetShowFullComponentOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.ShowFullComponent, true +} + +// SetShowFullComponent sets field value +func (o *QueryMetadata) SetShowFullComponent(v bool) { + o.ShowFullComponent = v +} + +func (o QueryMetadata) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if true { + toSerialize["groupingEnabled"] = o.GroupingEnabled + } + if true { + toSerialize["showIndirectRelations"] = o.ShowIndirectRelations + } + if true { + toSerialize["minGroupSize"] = o.MinGroupSize + } + if true { + toSerialize["groupedByLayer"] = o.GroupedByLayer + } + if true { + toSerialize["groupedByDomain"] = o.GroupedByDomain + } + if true { + toSerialize["groupedByRelation"] = o.GroupedByRelation + } + if o.QueryTime.IsSet() { + toSerialize["queryTime"] = o.QueryTime.Get() + } + if true { + toSerialize["autoGrouping"] = o.AutoGrouping + } + if true { + toSerialize["connectedComponents"] = o.ConnectedComponents + } + if true { + toSerialize["neighboringComponents"] = o.NeighboringComponents + } + if true { + toSerialize["showFullComponent"] = o.ShowFullComponent + } + return json.Marshal(toSerialize) +} + +type NullableQueryMetadata struct { + value *QueryMetadata + isSet bool +} + +func (v NullableQueryMetadata) Get() *QueryMetadata { + return v.value +} + +func (v *NullableQueryMetadata) Set(val *QueryMetadata) { + v.value = val + v.isSet = true +} + +func (v NullableQueryMetadata) IsSet() bool { + return v.isSet +} + +func (v *NullableQueryMetadata) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableQueryMetadata(val *QueryMetadata) *NullableQueryMetadata { + return &NullableQueryMetadata{value: val, isSet: true} +} + +func (v NullableQueryMetadata) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableQueryMetadata) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/generated/stackstate_api/model_query_parsing_failure.go b/generated/stackstate_api/model_query_parsing_failure.go new file mode 100644 index 00000000..393fbb06 --- /dev/null +++ b/generated/stackstate_api/model_query_parsing_failure.go @@ -0,0 +1,138 @@ +/* +StackState API + +This API documentation page describes the StackState server API. The StackState UI and CLI use the StackState server API to configure and query StackState. You can use the API for similar purposes. Each request sent to the StackState server API must be authenticated using one of the available authentication methods. *Note that the StackState receiver API, used to send topology, telemetry and traces to StackState, is not described on this page and requires a different authentication method.* For more information on StackState, refer to the [StackState documentation](https://docs.stackstate.com). + +API version: 5.2.0 +Contact: info@stackstate.com +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package stackstate_api + +import ( + "encoding/json" +) + +// QueryParsingFailure Query parsing failed. The reason field contains the error message. +type QueryParsingFailure struct { + // Discriminator field + Type string `json:"_type" yaml:"_type"` + // Error message describing why the query failed to parse + Reason string `json:"reason" yaml:"reason"` +} + +// NewQueryParsingFailure instantiates a new QueryParsingFailure object +// 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 NewQueryParsingFailure(type_ string, reason string) *QueryParsingFailure { + this := QueryParsingFailure{} + this.Type = type_ + this.Reason = reason + return &this +} + +// NewQueryParsingFailureWithDefaults instantiates a new QueryParsingFailure object +// 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 +func NewQueryParsingFailureWithDefaults() *QueryParsingFailure { + this := QueryParsingFailure{} + return &this +} + +// GetType returns the Type field value +func (o *QueryParsingFailure) GetType() string { + if o == nil { + var ret string + return ret + } + + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *QueryParsingFailure) GetTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value +func (o *QueryParsingFailure) SetType(v string) { + o.Type = v +} + +// GetReason returns the Reason field value +func (o *QueryParsingFailure) GetReason() string { + if o == nil { + var ret string + return ret + } + + return o.Reason +} + +// GetReasonOk returns a tuple with the Reason field value +// and a boolean to check if the value has been set. +func (o *QueryParsingFailure) GetReasonOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Reason, true +} + +// SetReason sets field value +func (o *QueryParsingFailure) SetReason(v string) { + o.Reason = v +} + +func (o QueryParsingFailure) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if true { + toSerialize["_type"] = o.Type + } + if true { + toSerialize["reason"] = o.Reason + } + return json.Marshal(toSerialize) +} + +type NullableQueryParsingFailure struct { + value *QueryParsingFailure + isSet bool +} + +func (v NullableQueryParsingFailure) Get() *QueryParsingFailure { + return v.value +} + +func (v *NullableQueryParsingFailure) Set(val *QueryParsingFailure) { + v.value = val + v.isSet = true +} + +func (v NullableQueryParsingFailure) IsSet() bool { + return v.isSet +} + +func (v *NullableQueryParsingFailure) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableQueryParsingFailure(val *QueryParsingFailure) *NullableQueryParsingFailure { + return &NullableQueryParsingFailure{value: val, isSet: true} +} + +func (v NullableQueryParsingFailure) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableQueryParsingFailure) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/generated/stackstate_api/model_query_snapshot_result.go b/generated/stackstate_api/model_query_snapshot_result.go new file mode 100644 index 00000000..37e923a9 --- /dev/null +++ b/generated/stackstate_api/model_query_snapshot_result.go @@ -0,0 +1,186 @@ +/* +StackState API + +This API documentation page describes the StackState server API. The StackState UI and CLI use the StackState server API to configure and query StackState. You can use the API for similar purposes. Each request sent to the StackState server API must be authenticated using one of the available authentication methods. *Note that the StackState receiver API, used to send topology, telemetry and traces to StackState, is not described on this page and requires a different authentication method.* For more information on StackState, refer to the [StackState documentation](https://docs.stackstate.com). + +API version: 5.2.0 +Contact: info@stackstate.com +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package stackstate_api + +import ( + "encoding/json" +) + +// QuerySnapshotResult Query succeeded (or encountered a runtime error that's part of the result). The viewSnapshotResponse uses existing DTO types for nested structures. +type QuerySnapshotResult struct { + // Discriminator field + Type string `json:"_type" yaml:"_type"` + // The query result or error response. This is opaque at the API level but contains one of: - ViewSnapshot (success) - ViewSnapshotFetchTimeout (error) - ViewSnapshotTooManyActiveQueries (error) - ViewSnapshotTopologySizeOverflow (error) - ViewSnapshotDataUnavailable (error) Use the _type field to discriminate between types. + ViewSnapshotResponse map[string]interface{} `json:"viewSnapshotResponse" yaml:"viewSnapshotResponse"` + // Optional view ID associated with this result + ViewId NullableInt64 `json:"viewId,omitempty" yaml:"viewId,omitempty"` +} + +// NewQuerySnapshotResult instantiates a new QuerySnapshotResult object +// 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 NewQuerySnapshotResult(type_ string, viewSnapshotResponse map[string]interface{}) *QuerySnapshotResult { + this := QuerySnapshotResult{} + this.Type = type_ + this.ViewSnapshotResponse = viewSnapshotResponse + return &this +} + +// NewQuerySnapshotResultWithDefaults instantiates a new QuerySnapshotResult object +// 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 +func NewQuerySnapshotResultWithDefaults() *QuerySnapshotResult { + this := QuerySnapshotResult{} + return &this +} + +// GetType returns the Type field value +func (o *QuerySnapshotResult) GetType() string { + if o == nil { + var ret string + return ret + } + + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *QuerySnapshotResult) GetTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value +func (o *QuerySnapshotResult) SetType(v string) { + o.Type = v +} + +// GetViewSnapshotResponse returns the ViewSnapshotResponse field value +func (o *QuerySnapshotResult) GetViewSnapshotResponse() map[string]interface{} { + if o == nil { + var ret map[string]interface{} + return ret + } + + return o.ViewSnapshotResponse +} + +// GetViewSnapshotResponseOk returns a tuple with the ViewSnapshotResponse field value +// and a boolean to check if the value has been set. +func (o *QuerySnapshotResult) GetViewSnapshotResponseOk() (map[string]interface{}, bool) { + if o == nil { + return nil, false + } + return o.ViewSnapshotResponse, true +} + +// SetViewSnapshotResponse sets field value +func (o *QuerySnapshotResult) SetViewSnapshotResponse(v map[string]interface{}) { + o.ViewSnapshotResponse = v +} + +// GetViewId returns the ViewId field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *QuerySnapshotResult) GetViewId() int64 { + if o == nil || o.ViewId.Get() == nil { + var ret int64 + return ret + } + return *o.ViewId.Get() +} + +// GetViewIdOk returns a tuple with the ViewId field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned +func (o *QuerySnapshotResult) GetViewIdOk() (*int64, bool) { + if o == nil { + return nil, false + } + return o.ViewId.Get(), o.ViewId.IsSet() +} + +// HasViewId returns a boolean if a field has been set. +func (o *QuerySnapshotResult) HasViewId() bool { + if o != nil && o.ViewId.IsSet() { + return true + } + + return false +} + +// SetViewId gets a reference to the given NullableInt64 and assigns it to the ViewId field. +func (o *QuerySnapshotResult) SetViewId(v int64) { + o.ViewId.Set(&v) +} + +// SetViewIdNil sets the value for ViewId to be an explicit nil +func (o *QuerySnapshotResult) SetViewIdNil() { + o.ViewId.Set(nil) +} + +// UnsetViewId ensures that no value is present for ViewId, not even an explicit nil +func (o *QuerySnapshotResult) UnsetViewId() { + o.ViewId.Unset() +} + +func (o QuerySnapshotResult) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if true { + toSerialize["_type"] = o.Type + } + if true { + toSerialize["viewSnapshotResponse"] = o.ViewSnapshotResponse + } + if o.ViewId.IsSet() { + toSerialize["viewId"] = o.ViewId.Get() + } + return json.Marshal(toSerialize) +} + +type NullableQuerySnapshotResult struct { + value *QuerySnapshotResult + isSet bool +} + +func (v NullableQuerySnapshotResult) Get() *QuerySnapshotResult { + return v.value +} + +func (v *NullableQuerySnapshotResult) Set(val *QuerySnapshotResult) { + v.value = val + v.isSet = true +} + +func (v NullableQuerySnapshotResult) IsSet() bool { + return v.isSet +} + +func (v *NullableQuerySnapshotResult) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableQuerySnapshotResult(val *QuerySnapshotResult) *NullableQuerySnapshotResult { + return &NullableQuerySnapshotResult{value: val, isSet: true} +} + +func (v NullableQuerySnapshotResult) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableQuerySnapshotResult) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/generated/stackstate_api/model_view_snapshot_request.go b/generated/stackstate_api/model_view_snapshot_request.go new file mode 100644 index 00000000..08052e50 --- /dev/null +++ b/generated/stackstate_api/model_view_snapshot_request.go @@ -0,0 +1,242 @@ +/* +StackState API + +This API documentation page describes the StackState server API. The StackState UI and CLI use the StackState server API to configure and query StackState. You can use the API for similar purposes. Each request sent to the StackState server API must be authenticated using one of the available authentication methods. *Note that the StackState receiver API, used to send topology, telemetry and traces to StackState, is not described on this page and requires a different authentication method.* For more information on StackState, refer to the [StackState documentation](https://docs.stackstate.com). + +API version: 5.2.0 +Contact: info@stackstate.com +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package stackstate_api + +import ( + "encoding/json" +) + +// ViewSnapshotRequest struct for ViewSnapshotRequest +type ViewSnapshotRequest struct { + Type string `json:"_type" yaml:"_type"` + // STQL query string + Query string `json:"query" yaml:"query"` + QueryVersion string `json:"queryVersion" yaml:"queryVersion"` + Metadata QueryMetadata `json:"metadata" yaml:"metadata"` + ViewId NullableInt64 `json:"viewId,omitempty" yaml:"viewId,omitempty"` +} + +// NewViewSnapshotRequest instantiates a new ViewSnapshotRequest object +// 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 NewViewSnapshotRequest(type_ string, query string, queryVersion string, metadata QueryMetadata) *ViewSnapshotRequest { + this := ViewSnapshotRequest{} + this.Type = type_ + this.Query = query + this.QueryVersion = queryVersion + this.Metadata = metadata + return &this +} + +// NewViewSnapshotRequestWithDefaults instantiates a new ViewSnapshotRequest object +// 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 +func NewViewSnapshotRequestWithDefaults() *ViewSnapshotRequest { + this := ViewSnapshotRequest{} + return &this +} + +// GetType returns the Type field value +func (o *ViewSnapshotRequest) GetType() string { + if o == nil { + var ret string + return ret + } + + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *ViewSnapshotRequest) GetTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value +func (o *ViewSnapshotRequest) SetType(v string) { + o.Type = v +} + +// GetQuery returns the Query field value +func (o *ViewSnapshotRequest) GetQuery() string { + if o == nil { + var ret string + return ret + } + + return o.Query +} + +// GetQueryOk returns a tuple with the Query field value +// and a boolean to check if the value has been set. +func (o *ViewSnapshotRequest) GetQueryOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Query, true +} + +// SetQuery sets field value +func (o *ViewSnapshotRequest) SetQuery(v string) { + o.Query = v +} + +// GetQueryVersion returns the QueryVersion field value +func (o *ViewSnapshotRequest) GetQueryVersion() string { + if o == nil { + var ret string + return ret + } + + return o.QueryVersion +} + +// GetQueryVersionOk returns a tuple with the QueryVersion field value +// and a boolean to check if the value has been set. +func (o *ViewSnapshotRequest) GetQueryVersionOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.QueryVersion, true +} + +// SetQueryVersion sets field value +func (o *ViewSnapshotRequest) SetQueryVersion(v string) { + o.QueryVersion = v +} + +// GetMetadata returns the Metadata field value +func (o *ViewSnapshotRequest) GetMetadata() QueryMetadata { + if o == nil { + var ret QueryMetadata + return ret + } + + return o.Metadata +} + +// GetMetadataOk returns a tuple with the Metadata field value +// and a boolean to check if the value has been set. +func (o *ViewSnapshotRequest) GetMetadataOk() (*QueryMetadata, bool) { + if o == nil { + return nil, false + } + return &o.Metadata, true +} + +// SetMetadata sets field value +func (o *ViewSnapshotRequest) SetMetadata(v QueryMetadata) { + o.Metadata = v +} + +// GetViewId returns the ViewId field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *ViewSnapshotRequest) GetViewId() int64 { + if o == nil || o.ViewId.Get() == nil { + var ret int64 + return ret + } + return *o.ViewId.Get() +} + +// GetViewIdOk returns a tuple with the ViewId field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned +func (o *ViewSnapshotRequest) GetViewIdOk() (*int64, bool) { + if o == nil { + return nil, false + } + return o.ViewId.Get(), o.ViewId.IsSet() +} + +// HasViewId returns a boolean if a field has been set. +func (o *ViewSnapshotRequest) HasViewId() bool { + if o != nil && o.ViewId.IsSet() { + return true + } + + return false +} + +// SetViewId gets a reference to the given NullableInt64 and assigns it to the ViewId field. +func (o *ViewSnapshotRequest) SetViewId(v int64) { + o.ViewId.Set(&v) +} + +// SetViewIdNil sets the value for ViewId to be an explicit nil +func (o *ViewSnapshotRequest) SetViewIdNil() { + o.ViewId.Set(nil) +} + +// UnsetViewId ensures that no value is present for ViewId, not even an explicit nil +func (o *ViewSnapshotRequest) UnsetViewId() { + o.ViewId.Unset() +} + +func (o ViewSnapshotRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if true { + toSerialize["_type"] = o.Type + } + if true { + toSerialize["query"] = o.Query + } + if true { + toSerialize["queryVersion"] = o.QueryVersion + } + if true { + toSerialize["metadata"] = o.Metadata + } + if o.ViewId.IsSet() { + toSerialize["viewId"] = o.ViewId.Get() + } + return json.Marshal(toSerialize) +} + +type NullableViewSnapshotRequest struct { + value *ViewSnapshotRequest + isSet bool +} + +func (v NullableViewSnapshotRequest) Get() *ViewSnapshotRequest { + return v.value +} + +func (v *NullableViewSnapshotRequest) Set(val *ViewSnapshotRequest) { + v.value = val + v.isSet = true +} + +func (v NullableViewSnapshotRequest) IsSet() bool { + return v.isSet +} + +func (v *NullableViewSnapshotRequest) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableViewSnapshotRequest(val *ViewSnapshotRequest) *NullableViewSnapshotRequest { + return &NullableViewSnapshotRequest{value: val, isSet: true} +} + +func (v NullableViewSnapshotRequest) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableViewSnapshotRequest) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/internal/di/mock_stackstate_client.go b/internal/di/mock_stackstate_client.go index e483d9e4..2c75fc96 100644 --- a/internal/di/mock_stackstate_client.go +++ b/internal/di/mock_stackstate_client.go @@ -36,6 +36,7 @@ type ApiMocks struct { AgentRegistrationsApi *stackstate_api.AgentRegistrationsApiMock DashboardsApi *stackstate_api.DashboardsApiMock OtelMappingApi *stackstate_api.OtelMappingApiMock + SnapshotApi *stackstate_api.SnapshotApiMock // Admin API: RetentionApi *stackstate_admin_api.RetentionApiMock // MISSING MOCK? You have to manually add new mocks here after generating a new API! @@ -63,6 +64,7 @@ func NewMockStackStateClient() MockStackStateClient { agentRegistrationsApi := stackstate_api.NewAgentRegistrationsApiMock() dashboardsApi := stackstate_api.NewDashboardsApiMock() otelMappingApi := stackstate_api.NewOtelMappingApiMock() + snapshotApi := stackstate_api.NewSnapshotApiMock() apiMocks := ApiMocks{ ApiTokenApi: &apiTokenApi, @@ -86,6 +88,7 @@ func NewMockStackStateClient() MockStackStateClient { AgentRegistrationsApi: &agentRegistrationsApi, DashboardsApi: &dashboardsApi, OtelMappingApi: &otelMappingApi, + SnapshotApi: &snapshotApi, } apiClient := &stackstate_api.APIClient{ @@ -109,6 +112,7 @@ func NewMockStackStateClient() MockStackStateClient { AgentRegistrationsApi: apiMocks.AgentRegistrationsApi, DashboardsApi: apiMocks.DashboardsApi, OtelMappingApi: apiMocks.OtelMappingApi, + SnapshotApi: apiMocks.SnapshotApi, } adminApiClient := &stackstate_admin_api.APIClient{ diff --git a/stackstate_openapi/openapi_version b/stackstate_openapi/openapi_version index 5913a33e..2dbc4cbc 100644 --- a/stackstate_openapi/openapi_version +++ b/stackstate_openapi/openapi_version @@ -1 +1 @@ -5bb2b5d01cc20d25322e38d5731875804d31692b +616bb4295a3ad419eebf4cae7a30e4570900cbaf