Metadata-Version: 2.4
Name: infrahouse-core
Version: 0.18.0
Summary: Lightweight Python library with AWS and other general purpose classes.
Author-email: "InfraHouse Inc." <aleks@infrahouse.com>
Maintainer-email: Oleksandr Kuzminskyi <aleks@infrahouse.com>
License: Apache Software License 2.0
Project-URL: bugs, https://github.com/infrahouse/infrahouse-core/issues
Project-URL: changelog, https://github.com/infrahouse/infrahouse-core/commits/main/
Project-URL: homepage, https://github.com/infrahouse/infrahouse-core
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Testing
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: License :: OSI Approved :: Apache Software License
Requires-Python: >=3.10
Description-Content-Type: text/x-rst
License-File: LICENSE
License-File: AUTHORS.rst
Requires-Dist: boto3~=1.36
Requires-Dist: cached-property~=2.0
Requires-Dist: diskcache~=5.6
Requires-Dist: ec2-metadata~=2.13
Requires-Dist: PyGithub~=2.4
Provides-Extra: dev
Requires-Dist: black~=25.1; extra == "dev"
Requires-Dist: build~=1.2; extra == "dev"
Requires-Dist: bump2version~=1.0; extra == "dev"
Requires-Dist: mdformat~=0.7; extra == "dev"
Requires-Dist: pytest~=8.3; extra == "dev"
Requires-Dist: pytest-cov~=7.0; extra == "dev"
Requires-Dist: pylint~=4.0; extra == "dev"
Provides-Extra: doc
Requires-Dist: Sphinx~=8.1; extra == "doc"
Dynamic: license-file

===============
InfraHouse Core
===============


.. image:: https://img.shields.io/pypi/v/infrahouse_core.svg
        :target: https://pypi.python.org/pypi/infrahouse_core

.. image:: https://readthedocs.org/projects/infrahouse-core/badge/?version=latest
        :target: https://infrahouse-core.readthedocs.io/en/latest/?version=latest
        :alt: Documentation Status




Lightweight Python library with AWS and other general purpose classes.


* Free software: Apache Software License 2.0
* Documentation: https://infrahouse-core.readthedocs.io.


Installation
------------

.. code-block:: bash

    pip install infrahouse-core


Features
--------

AWS Classes
~~~~~~~~~~~

* **EC2Instance** - Manage EC2 instances with SSM command execution support
* **ASG** - AutoScaling Group lifecycle management (instance refresh, lifecycle hooks)
* **DynamoDBTable** - DynamoDB operations with distributed locking support
* **Route53 Zone** - DNS record management (add/delete A records)
* **AWS Session Management** - SSO login, role assumption, credential handling

GitHub Integration
~~~~~~~~~~~~~~~~~~

* **GitHubActions** - Manage self-hosted GitHub Actions runners
* **GitHubActionsRunner** - Query runner status, labels, and metadata
* Token generation from GitHub App credentials stored in AWS Secrets Manager


Usage Examples
--------------

EC2 Instance with SSM Command Execution
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: python

    from infrahouse_core.aws.ec2_instance import EC2Instance

    # Connect to an instance (optionally assume a role for cross-account access)
    instance = EC2Instance(
        instance_id="i-0123456789abcdef0",
        region="us-east-1",
        role_arn="arn:aws:iam::123456789012:role/MyRole"  # optional
    )

    # Execute a command via SSM
    exit_code, stdout, stderr = instance.execute_command("hostname")

    # Access instance properties
    print(instance.private_ip)
    print(instance.hostname)
    print(instance.tags)

DynamoDB Distributed Lock
~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: python

    from infrahouse_core.aws.dynamodb import DynamoDBTable

    table = DynamoDBTable("my-lock-table", region="us-east-1")

    with table.lock("my-resource", timeout=30):
        # Critical section - only one process can hold this lock
        do_exclusive_work()

Route53 DNS Management
~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: python

    from infrahouse_core.aws.route53.zone import Zone

    zone = Zone(zone_name="example.com")

    # Add an A record
    zone.add_record("myhost", "10.0.0.1", ttl=300)

    # Delete an A record
    zone.delete_record("myhost", "10.0.0.1")

GitHub Actions Runner Management
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: python

    from infrahouse_core.github import GitHubActions, GitHubAuth

    github = GitHubAuth(token="ghp_...", org="my-org")
    actions = GitHubActions(github)

    # List all runners
    for runner in actions.runners:
        print(f"{runner.name}: {runner.status}")

    # Find runners by label
    runners = actions.find_runners_by_label("self-hosted")


Credits
-------

This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.

.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
