resourcegraph

package
v1.6.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 24, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package resourcegraph serves Azure Resource Graph (armresourcegraph) REST requests against a *resourcediscovery.Engine.

Resource Graph queries use Kusto Query Language (KQL), a rich data-analytics grammar. This handler implements a documented subset that covers the queries real callers make for inventory/discovery:

Resources
| where type == 'microsoft.compute/virtualmachines'
| where type =~ 'microsoft.network/virtualnetworks'
| where resourceGroup == 'rg-prod'
| where location == 'eastus'
| where tags['env'] == 'prod'
| where tags.env == 'prod'
| project id, type, name              (column selection: ignored, full
                                        records returned)
| limit 100                           (also: | take 100)

Unknown tokens and unsupported clauses are tolerated: the parser logs them away and continues with the constraints it did understand. Real Resource Graph would reject malformed queries; the stub favors returning some result over a 400 so SDK callers that probe with unknown queries don't blow up.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler serves Azure Resource Graph ARM-JSON requests.

func New

func New(engine *resourcediscovery.Engine, subscriptionID string) *Handler

New returns a Resource Graph handler backed by engine. subscriptionID is validated against the request's subscriptions list (a request whose subscriptions field is set but does not include this ID returns an empty result rather than an error). If subscriptionID is empty, the engine's own AccountID is used — that's the same value the engine was built with when it constructed Azure-shaped resource IDs, so the two stay aligned without callers having to pass the ID twice.

func (*Handler) Matches

func (*Handler) Matches(r *http.Request) bool

Matches accepts ARM requests targeting Microsoft.ResourceGraph. Uses exact path equality, not prefix match, so /resources cannot shadow /resourcesHistory (the longer path starts with the shorter one). r.URL.Path strips the query string, so api-version is not in the way.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL