LogoLogo
HomeBlogGet a Demo
  • Introduction
  • Install Lunar
  • Learn the basics
  • 📖Docs
    • Key concepts
    • Component JSON
    • Catalog JSON
    • Lunar CLI Reference
  • 📝Configuration
    • lunar-config.yml
      • catalogers
      • catalogers/hooks
      • domains
      • components
      • collectors
      • collectors/hooks
      • policies
    • lunar.yml
  • 🛠️Plugin SDKs
    • Plugins configuration
      • lunar-cataloger.yml
      • lunar-collector.yml
      • lunar-policy.yml
    • Bash SDK
      • Cataloger
      • Collector
    • Python SDK
      • Collector
      • Policy
        • Check
        • Path
        • ComponentData
        • NoDataError
        • Utility Functions
  • ⚙️SQL API
    • Overview
    • Views
      • domains
      • components
      • component_deltas
      • initiatives
      • policies
      • checks
      • prs
      • catalog
Powered by GitBook

©️ Earthly Technologies

On this page
  • Constructor
  • Usage
  1. Plugin SDKs
  2. Python SDK
  3. Policy

Path

The Path class is used to pass JSONPath expressions to assertion methods of the Check class. It enables automatic handling of non-existent paths by raising NoDataError when the specified path doesn't exist in the component data.

Constructor

Path(json_path)
  • json_path (str): A JSONPath expression to query component data

Usage

The primary use of the Path class is to provide a wrapper around JSONPath expressions that will be automatically evaluated by assertion methods in the Check class.

from lunar_policy import Check, Path

with Check("my-check") as check:
    # Using Path in assertions
    check.assert_true(Path(".api.requires_auth"))
    check.assert_equals(Path(".api.version"), "v1")
    check.assert_contains(Path(".tags"), "security")
PreviousCheckNextComponentData

Last updated 19 hours ago

🛠️