Skip to main content

iot-edge-validator

python version pre-commit Keep a Changelog CI_CD GitHub_Actions package PyPI azure-iot-device

This package is a wrapper around the azure-iot-device SDK to provide standardized exception handling and direct method request validation.

Official Documentation | Source code | Package PyPI

Table of Contents

Versioning

This repository adheres to Semantic Versioning. It will be maintained through the CHANGELOG.md and in GitHub Releases. It's important to note that you must maintain the version with your releases in iot/edge/validator/_version.py, otherwise a new package version will fail to get published.

Getting Started

This section provides basic examples with the iot-edge-validator.

Prerequisites

  • Python 3.7 or later is required to use this package.

  • You must have an Azure subscription and Azure IoT Edge Device to use this package.

Basic Examples

  1. Install via pip:

    pip install iot-edge-validator
    
  2. Import and say hello:

    from iot.edge.validator import __version__
    
    
    print(f"hello world from iot-edge-validator version: {__version__}")
    
  3. Basic usage:

    from typing import Any, Dict, Union
    
    from azure.iot.device.iothub.models.methods import MethodRequest, MethodResponse
    
    from iot.edge.validator import (
       format_exception_error,
       generate_error_response,
       compare_dictionary,
     )
    
    EXPECTED_METHOD_NAME: str = "some_method_name"
    
    EXPECTED_METHOD_PAYLOAD: Dict[str, Any] = {
        "some": {},
        "expected": {},
        "payload": {},
    }
    
    
    def validate_method_requests(method_request: MethodRequest) -> Union[MethodResponse, None]:
        """validation handler for some_method_name listener"""
        if method_request.name == EXPECTED_METHOD_NAME:
            pass
        else:
            return generate_error_response(method_request,
                f"received unknown method request for {method_request.name}",
                400,
            )
    
    
    def validate_some_method_name_request(method_request: MethodRequest) -> Union[MethodResponse, None]:
        """validation for expected payload of some_method_name direct method request"""
        # top level basic format validation
        error_msg = compare_dictionary(
            d1=method_request.payload,
            d2=EXPECTED_METHOD_PAYLOAD,
            value_match=False,
            recurse=False,
        )
        if error_msg:
            return generate_error_response(
                method_request, f"error parsing payload: {error_msg}", 400
            )
        return None
    

Metadata

Release files for iot-edge-validator 1.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for iot-edge-validator 1.0.6
File Size Uploaded Provenance
iot-edge-validator-1.0.6.tar.gz 4.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for iot-edge-validator 1.0.6
File Interpreter ABI Platform
iot_edge_validator-1.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 9.6 kB

Release files / iot-edge-validator-1.0.6.tar.gz

Download URL iot-edge-validator-1.0.6.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c1ef1a7319e55bfc0c8faacaf18817719c460312a08777a7c41fe663f5d2531d
BLAKE2b-256 checksum
How to use checksums
f89c53d18fdc86a98db5d25c6601b81edff9589c452381772bb5ab59d76485bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release files / iot_edge_validator-1.0.6-py3-none-any.whl

Download URL iot_edge_validator-1.0.6-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
81c4eabb7a7eaf0cd4b1080cde25ca9639c52d60f0f2435cc008ed933d94f992
BLAKE2b-256 checksum
How to use checksums
2fdcfa7637cc949eb03b15192ac85ec561518bfdd62bee0d0a62bd554efbdb7f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Security for iot-edge-validator 1.0.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page