semvec/pypi-packages huggingface dataset:
auto-dns 0.1.2
A DNS Python Library.
Requires Python: >=3.10,<4.0

===================
Auto DNS Python CLI
===================

Auto DNS is a Python command line application which automatically updates the DNS records of your domain using various DNS providers.

Supported DNS providers:

- Arvan
- Cloudflare [coming soon]

This library is intended to be used on a system with a dynamic public IP that you want to map to a static domain name.

Installation
============

The package can be installed using pip:

.. code-block:: shell

   $ pip install auto-dns

Or if you prefer, you can use Poetry:

.. code-block:: shell

   $ poetry add auto-dns

Configuration
=============

To configure a DNS provider API key, use the following command:

.. code-block:: shell

   $ autodns set_api_key <provider> <api_key>

Usage
=====

To create a DNS record:

.. code-block:: shell

   $ autodns create <domain> <record_type> <name> <provider> --ip <ip_address>

To update a DNS record with your current public IP, use the following command:

.. code-block:: shell

   $ autodns update <domain> <record_type> <name> <provider> --ip <ip_address>

To delete a DNS record:

.. code-block:: shell

   $ autodns delete <domain> <record_type> <name> <provider>

To get DNS records:

.. code-block:: shell

   $ autodns get_record <domain> <provider> --record-type <record_type> --name <name>

Contributing
============

Contributions are welcome! Please feel free to submit a Pull Request.

License
=======

Auto DNS is released under the MIT License.
app-toggles 0.1.2
A library to manage app toggles
Requires Python: >=3.10,<4.0

# App toggles library

![CI](https://github.com/eguezgustavo/app_toggles/actions/workflows/cicd.yaml/badge.svg?branch=main)

This library has been created taking into account the work done by [Pete Hodgson](https://thepete.net/) published in [https://martinfowler.com/](https://martinfowler.com/articles/feature-toggles.html).

## How to use it
The example below uses a sample feature to include a cancellation link in a email so the user can cancel the sales order.

1. Create the /tmp/test_app_toggles.json file with the following content:
``` json
{
    "isOrderCancellationEnabled": true,
    "isAutoRefundEnable": false
}
```
2. Run the app

``` python
import app_toggles

provider = app_toggles.JsonToggleProvider("/tmp/test_app_toggles.json")
toggles = app_toggles.Toggles(provider=provider)


@toggles.toggle_decision
def usage_of_order_cancellation_email(get_toggles, when_on, when_off):
    order_cancellation_enabled, auto_refund_enabled = get_toggles(
        ["isOrderCancellationEnabled", "isAutoRefundEnable"]
    )
    if order_cancellation_enabled and auto_refund_enabled:
        return when_on
    return when_off


def create_email_body(client_name: str, sales_order_number: str) -> str:
    header = f"""
    Dear {client_name},

    Your order number {sales_order_number} has bee approved.
    """

    footer = """
    Cheers,

    Your company team
    """

    cancellation_text = usage_of_order_cancellation_email(
        when_on=f"To cancel your order follow this link: http://cancel/{sales_order_number}",
        when_off="",
    )

    return f"""
    {header}
    {cancellation_text}
    {footer}
    """

body = create_email_body("Gustavo", "2342937")
print(body)
```

3. Feel free to change the value of the toggles in the JSON file and see how the email body changes

## How to extend this library
The library exposes a "Provider" interface. You can create your own interface to interact with external services that manage feature flags. Below you' ll find a sample code used to retrieve toggles stored in memory.

DON'T FORGET TO CREATE A PR SO WE CAN ADD THE IMPLEMENTATION YOU'VE CREATED!

```python
import typing

import app_toggles


class InMemoryProvider(app_toggles.Provider):
    toggles = {
        "isOrderCancellationEnabled": True,
        "isAutoRefundEnable": True
    }

    def get_toggles(self, toggle_names: typing.List[str]) -> typing.Tuple[bool]:
        missing_toogles = [toggle for toggle in toggle_names if toggle not in InMemoryProvider.toggles]

        if missing_toogles:
            raise app_toggles.ToggleNotFoundError(f"The follwing toggles where not found: {', '.join(missing_toogles)}")

        return [
            toggle_value
            for toggle_name, toggle_value in InMemoryProvider.toggles.items()
            if toggle_name in toggle_names
        ]

```