Skip to main content

Azure Resources Graph client

Project description

llamazure.azgraph : Azure Resources Graph client

The llamazure.azgraph package provides a usable client for the Azure Resource Graph.

Benefits:

  • automatically queries all your subscriptions
  • no boilerplate
  • easily navigate paginated queries

azgraph

Usage

Create a Graph with the from_credential and any of the standard Azure credentials.

from azure.identity import DefaultAzureCredential

from llamazure.azgraph.azgraph import Graph

g = Graph.from_credential(DefaultAzureCredential())

Querying

Make a simple query with the q method, which will return your data directly:

>>> g.q("Resources | project id, name, type, location | limit 5")
[{'id': '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg0/providers/Microsoft.Storage/storageAccounts/sa0', 'name': 'sa0', 'type': 'microsoft.storage/storageaccounts', 'location': 'canadacentral'}]

Or specify options with the query method, which will return the full result object:

>>> from llamazure.azgraph.models import Req

>>> g.query(Req(query="Resources | project id, name, type, location | limit 1", subscriptions=g.subscriptions, options={"$skip": 1},))
Res(req=Req(query='Resources | project id, name, type, location | limit 1', subscriptions=('00000000-0000-0000-0000-000000000000',), facets=(), managementGroupId=None, options={'$skip': 1}), totalRecords=1, count=1, resultTruncated='false', facets=[], data=[{'id': '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/NetworkWatcherRG/providers/Microsoft.Network/networkWatchers/NetworkWatcher_canadacentral', 'name': 'NetworkWatcher_canadacentral', 'type': 'microsoft.network/networkwatchers', 'location': 'canadacentral'}], skipToken=None)

Retries

Every query can be automatically retried by the retry policy. You can modify this by setting the Graph.retry_policy attribute:

g.retry_policy = RetryPolicy(retries=10)

Pagination

Pagination is handled automatically. If you want to manually paginate, you can manually walk the pages:

req = Req(query="Resources | project id, name, type, location | limit 5", subscriptions=g.subscriptions)

res0 = g.query_single(req)
res1 = g.query_next(req, res0)
res2 = g.query_next(req, res1)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llamazure.azgraph-0.1.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

llamazure.azgraph-0.1.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file llamazure.azgraph-0.1.0.tar.gz.

File metadata

  • Download URL: llamazure.azgraph-0.1.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.12

File hashes

Hashes for llamazure.azgraph-0.1.0.tar.gz
Algorithm Hash digest
SHA256 94e8922b38bf97729bfc1c28b58715469ffebd17ad138398e5fe43ee3b3a206d
MD5 2168966336a5fe1e0ab4326e2e858888
BLAKE2b-256 c09492e1d79d56ca0c0ff9684f963313355f4f0f2c6dafa2328c2534eccf8e21

See more details on using hashes here.

File details

Details for the file llamazure.azgraph-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for llamazure.azgraph-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4e67dcbc1e3eb05b424e0d34e32c528c4462d86c0bf8a4c6c6e77aa250cafd60
MD5 bd3f4cb4798834a7f5b27dfc937f09f3
BLAKE2b-256 c6e78341306e4b4455619850f8d66d64c095268505c1151dbad3c51b7a8bae7a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page