Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cmd/topology/topology_inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ func RunInspectCommand(
true,
)

request := stackstate_api.NewSnapshotRequest(
request := stackstate_api.NewViewSnapshotRequest(
"SnapshotRequest",
query,
"0.0.1",
*metadata,
)

result, resp, err := api.SnapshotApi.QuerySnapshot(cli.Context).
SnapshotRequest(*request).
ViewSnapshotRequest(*request).
Execute()
if err != nil {
return common.NewResponseError(err, resp)
Expand All @@ -104,7 +104,7 @@ func RunInspectCommand(
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 := handleSnapshotError(result.SnapshotResponse, resp); typedErr != nil {
if typedErr := handleSnapshotError(result.ViewSnapshotResponse, resp); typedErr != nil {
return typedErr
}
return common.NewExecutionError(parseErr)
Expand Down Expand Up @@ -219,7 +219,7 @@ func parseSnapshotResponse(
baseURL string,
) ([]Component, error) {
// SnapshotResponse is already typed as map[string]interface{} from the generated API
respMap := result.SnapshotResponse
respMap := result.ViewSnapshotResponse
if respMap == nil {
return nil, fmt.Errorf("response data is nil")
}
Expand Down
24 changes: 12 additions & 12 deletions cmd/topology/topology_inspect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func setInspectCmd(t *testing.T) (*di.MockDeps, *cobra.Command) {
func mockSnapshotResponse() sts.QuerySnapshotResult {
return sts.QuerySnapshotResult{
Type: "QuerySnapshotResult",
SnapshotResponse: map[string]interface{}{
ViewSnapshotResponse: map[string]interface{}{
"_type": "ViewSnapshot",
"components": []interface{}{
map[string]interface{}{
Expand Down Expand Up @@ -121,7 +121,7 @@ func TestTopologyInspectWithTags(t *testing.T) {

// Verify query contains both tags ANDed
call := calls[0]
request := call.PsnapshotRequest
request := call.PviewSnapshotRequest
expectedQuery := `type = "test type" AND label = "service.namespace:test" AND label = "service.name:myservice"`
assert.Equal(t, expectedQuery, request.Query)
}
Expand All @@ -141,7 +141,7 @@ func TestTopologyInspectWithIdentifiers(t *testing.T) {

// Verify query contains identifiers in IN clause
call := calls[0]
request := call.PsnapshotRequest
request := call.PviewSnapshotRequest
expectedQuery := `type = "test type" AND identifier IN ("urn:test:1", "urn:test:2")`
assert.Equal(t, expectedQuery, request.Query)
}
Expand All @@ -150,7 +150,7 @@ func TestTopologyInspectNoResults(t *testing.T) {
cli, cmd := setInspectCmd(t)
cli.MockClient.ApiMocks.SnapshotApi.QuerySnapshotResponse.Result = sts.QuerySnapshotResult{
Type: "QuerySnapshotResult",
SnapshotResponse: map[string]interface{}{
ViewSnapshotResponse: map[string]interface{}{
"_type": "ViewSnapshot",
"components": []interface{}{},
"metadata": map[string]interface{}{
Expand Down Expand Up @@ -178,7 +178,7 @@ func TestTopologyInspectMultipleIdentifiers(t *testing.T) {
cli, cmd := setInspectCmd(t)
responseData := mockSnapshotResponse()
// Modify to include multiple identifiers
components := responseData.SnapshotResponse["components"].([]interface{})
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
Expand All @@ -199,7 +199,7 @@ func TestTopologyInspectURLEncoding(t *testing.T) {
cli, cmd := setInspectCmd(t)
responseData := mockSnapshotResponse()
// Set identifier with special characters
components := responseData.SnapshotResponse["components"].([]interface{})
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
Expand All @@ -219,11 +219,11 @@ func TestTopologyInspectWithEnvironment(t *testing.T) {
cli, cmd := setInspectCmd(t)
responseData := mockSnapshotResponse()
// Add environment to component
components := responseData.SnapshotResponse["components"].([]interface{})
components := responseData.ViewSnapshotResponse["components"].([]interface{})
comp := components[0].(map[string]interface{})
comp["environment"] = float64(123)
// Add environment to metadata
metadata := responseData.SnapshotResponse["metadata"].(map[string]interface{})
metadata := responseData.ViewSnapshotResponse["metadata"].(map[string]interface{})
metadata["environments"] = []interface{}{
map[string]interface{}{
"id": float64(123),
Expand Down Expand Up @@ -292,7 +292,7 @@ func TestTopologyInspectFetchTimeout(t *testing.T) {
cli, cmd := setInspectCmd(t)
cli.MockClient.ApiMocks.SnapshotApi.QuerySnapshotResponse.Result = sts.QuerySnapshotResult{
Type: "QuerySnapshotResult",
SnapshotResponse: map[string]interface{}{
ViewSnapshotResponse: map[string]interface{}{
"_type": "ViewSnapshotFetchTimeout",
"usedTimeoutSeconds": float64(30),
},
Expand All @@ -310,7 +310,7 @@ func TestTopologyInspectTooManyActiveQueries(t *testing.T) {
cli, cmd := setInspectCmd(t)
cli.MockClient.ApiMocks.SnapshotApi.QuerySnapshotResponse.Result = sts.QuerySnapshotResult{
Type: "QuerySnapshotResult",
SnapshotResponse: map[string]interface{}{
ViewSnapshotResponse: map[string]interface{}{
"_type": "ViewSnapshotTooManyActiveQueries",
},
}
Expand All @@ -327,7 +327,7 @@ func TestTopologyInspectTopologySizeOverflow(t *testing.T) {
cli, cmd := setInspectCmd(t)
cli.MockClient.ApiMocks.SnapshotApi.QuerySnapshotResponse.Result = sts.QuerySnapshotResult{
Type: "QuerySnapshotResult",
SnapshotResponse: map[string]interface{}{
ViewSnapshotResponse: map[string]interface{}{
"_type": "ViewSnapshotTopologySizeOverflow",
"maxSize": float64(10000),
},
Expand All @@ -345,7 +345,7 @@ func TestTopologyInspectDataUnavailable(t *testing.T) {
cli, cmd := setInspectCmd(t)
cli.MockClient.ApiMocks.SnapshotApi.QuerySnapshotResponse.Result = sts.QuerySnapshotResult{
Type: "QuerySnapshotResult",
SnapshotResponse: map[string]interface{}{
ViewSnapshotResponse: map[string]interface{}{
"_type": "ViewSnapshotDataUnavailable",
"unavailableAtEpochMs": float64(1000000),
"availableSinceEpochMs": float64(1609459200000),
Expand Down
Loading