Description
Bug Report
- What happened?
As recommended we are now migrating to use resourcegraph API. The API seems to work fine when i just print out theClientResourcesResponse.Data
but if i now want to iterate over rows/JsonObjectArray then i am currently not able to find a way or an example to do just that. The data type ofData
isany
.
I have checked the documentation links and each and every example is incomplete.
Example (the list is not comprehensive):
- https://learn.microsoft.com/en-us/azure/governance/resource-graph/first-query-go
- https://learn.microsoft.com/en-us/samples/azure-samples/azure-cxp-developer-support/this-sample-code-uses-the-armresourcegraph-go-sdk-package-to-list-the-azure-mysql-db-resource-properties/
- All examples in https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourcegraph/[email protected]#example-Client.Resources-BasicQuery
- There are also no unit tests which i could refer to (https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/resourcegraph/armresourcegraph). Only examples are given which does not contain code on how to even consume
Data
All the examples fall short of how to extract values from Data
. You cannot range over it because its not an iterable. You cannot cast it to a slice as that is not allowed and is also incorrect. I even tried to change the options via:
Options: &armresourcegraph.QueryRequestOptions{
ResultFormat: to.Ptr(armresourcegraph.ResultFormatObjectArray),
},
But since type of Data
is any
it becomes difficult to consume it.
-
What did you expect or want to happen?
At least give one complete example on how to iterate either over table rows (if ResultFormat is set toResultFormatTable
) or consumeResultFormatObjectArray
. -
How can we reproduce it?
Just use the resource graph query to return a result which has more than 1 rows. -
Anything we should know about your environment.
Testing on MacOs Version 13.4
Golang Version 1.20.5
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourcegraph/armresourcegraph v0.7.1