pyawsopstoolkit.validators


Namepyawsopstoolkit.validators JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/coldsofttech/pyawsopstoolkit.validators
SummaryThis package provides a comprehensive set of validation classes specifically crafted for use with AWS
upload_time2024-05-12 20:36:02
maintainerNone
docs_urlNone
authorcoldsofttech
requires_pythonNone
licenseMIT
keywords aws toolkit operations validators validations amazon-web-services
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # pyawsopstoolkit.validators

The **pyawsopstoolkit.validators** package provides a comprehensive set of validation classes specifically crafted for
use with AWS (Amazon Web Services). These validators are meticulously designed to cater to the unique requirements
within the AWS ecosystem, covering a wide array of aspects such as AWS Resource Names (ARNs), Policy Statements, and
more. By leveraging these validators, developers can ensure that their AWS-related inputs and configurations adhere to
the necessary standards and formats, thereby enhancing the reliability and security of their applications deployed on
AWS.

## Getting Started

Let's get started with **pyawsopstoolkit.validators**!

### Installation

Install **pyawsopstoolkit.validators** via pip:

```bash
pip install pyawsopstoolkit.validators
```

### Usage

Import the package in your Python script:

```python
import pyawsopstoolkit.validators
```

Now you're all set to harness the power of **pyawsopstoolkit.validators**!

# Documentation

## pyawsopstoolkit.validators

### AccountValidator

The **AccountValidator** class provides methods to validate AWS account information, ensuring accuracy and consistency
in account details. It includes constants and methods for validating account numbers.

#### Constants

- `NUMBER_PATTERN (str)`: Regular expression pattern for validating account numbers. The pattern ensures that the
  account number consists of exactly 12 digits.

#### Methods

- `number(cls, value: str, raise_error: Optional[bool] = True, custom_error_message: Optional[str] = None) -> bool`:
  Validate the account number.

#### Usage

```python
from pyawsopstoolkit.validators import AccountValidator

# Validate account number
print(AccountValidator.number('123456789012'))  # Output: True
print(AccountValidator.number('123'))  # Output: False
```

#### References

- [AWS Documentation: DescribeAccount](https://docs.aws.amazon.com/organizations/latest/APIReference/API_DescribeAccount.html)

### ArnValidator

The **ArnValidator** class validates AWS ARNs (Amazon Resource Names) according to the AWS ARN format. This class
provides methods to validate various aspects of ARNs, including the partition, service, region, account ID, and resource
ID.

#### Constants

- `ARN_PATTERN (str)`: Regular expression pattern for AWS ARNs.

#### Methods

- `arn(cls, value: Union[str, list], raise_error: Optional[bool] = True, custom_error_message: Optional[str] = None) -> bool`:
  Validates if the given ARN(s) match the ARN pattern.

#### Usage

```python
from pyawsopstoolkit.validators import ArnValidator

# Validate ARNs
print(ArnValidator.arn('arn:aws:ec2:us-east-1:123456789012:vpc/vpc-0e9801d129EXAMPLE', False))  # Output: True
print(ArnValidator.arn('arn::iam:us-east-1:123456789012:user', False))  # Output: False
```

#### References

- [AWS Documentation: ARNs](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference-arns.html)

### PolicyValidator

The **PolicyValidator** class validates AWS IAM policy documents. This class provides methods to validate various
aspects of IAM policies, ensuring their correctness and compliance.

#### Constants

- `VERSION_PATTERN (str)`: Regular expression pattern for validating version strings in policies.
- `EFFECT_PATTERN (str)`: Regular expression pattern for validating effect strings in policies.
- `PRINCIPAL_PATTERN (str)`: Regular expression pattern for validating principal strings in policies.

#### Methods

- `policy(cls, value: dict, raise_error: Optional[bool] = True, custom_error_message: Optional[str] = None) -> bool`:
  Validates a policy dictionary.

#### Usage

```python
from pyawsopstoolkit.validators import PolicyValidator

# Validate IAM policy document
print(PolicyValidator.policy(
    {
        "Version": "2012-10-17",
        "Id": "1",
        "Statement": {
            "Sid": "1",
            "Principal": "*",
            "Effect": "Allow",
            "Action": "*",
            "Resource": "*",
            "Condition": {
                "Bool": {
                    "aws:SecureTransport": "true"
                }
            }
        }
    }, False
))  # Output: True

print(PolicyValidator.policy(
    {
        "Version": "2012-10-17",
        "Id": "1"
    }, False
))  # Output: False
```

#### References

- [AWS Documentation: IAM Policy Grammar](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_grammar.html)

### TagValidator

The **TagValidator** class validates tags according to predefined patterns. This class provides methods to validate keys
and values of tags in dictionaries or lists of dictionaries.

#### Constants

- `KEY_PATTERN (str)`: Regular expression pattern used to validate keys in a dictionary of tags.
- `VALUE_PATTERN (str)`: Regular expression pattern used to validate values in a dictionary of tags.

#### Methods

- `tag(cls, value: Union[dict, list], raise_error: Optional[bool] = True, custom_error_message: Optional[str] = None) -> bool`:
  Validates a dictionary or a list of dictionaries of tags.

#### Usage

```python
from pyawsopstoolkit.validators import TagValidator

# Validate tag dictionary
print(TagValidator.tag(
    {
        'Key': 'sample',
        'Value': 'sample-test'
    }, False
))  # Output: True

print(TagValidator.tag(
    {
        'Key': 1,
        1: 'sample-test'
    }, False
))  # Output: False
```

#### References

- [AWS Documentation: Tagging](https://docs.aws.amazon.com/tag-editor/latest/userguide/tagging.html)

### Validator

The **Validator** class validates according to predefined patterns. This class provides methods to validate various
aspects of AWS, such as region code.

#### Constants

- `REGION_PATTERN (str)`: Regular expression pattern used to validate region codes.

#### Methods

- `region(cls, value: str, raise_error: Optional[bool] = True, custom_error_message: Optional[str] = None) -> bool`:
  Validates a region value.

#### Usage

```python
from pyawsopstoolkit.validators import Validator

# Validate region code
print(Validator.region('eu-west-1', False))  # Output: True
print(Validator.region('Ohio', False))  # Output: False
```

#### References

- [AWS Documentation: DescribeAccount](https://docs.aws.amazon.com/organizations/latest/APIReference/API_DescribeAccount.html)

# License

Please refer to the [MIT license](LICENSE) within the project for more information.

# Contributing

We welcome contributions from the community! Whether you have ideas for new features, bug fixes, or enhancements, feel
free to open an issue or submit a pull request on [GitHub](https://github.com/coldsofttech/pyawsopstoolkit.validators).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/coldsofttech/pyawsopstoolkit.validators",
    "name": "pyawsopstoolkit.validators",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "aws, toolkit, operations, validators, validations, amazon-web-services",
    "author": "coldsofttech",
    "author_email": null,
    "download_url": null,
    "platform": null,
    "description": "# pyawsopstoolkit.validators\n\nThe **pyawsopstoolkit.validators** package provides a comprehensive set of validation classes specifically crafted for\nuse with AWS (Amazon Web Services). These validators are meticulously designed to cater to the unique requirements\nwithin the AWS ecosystem, covering a wide array of aspects such as AWS Resource Names (ARNs), Policy Statements, and\nmore. By leveraging these validators, developers can ensure that their AWS-related inputs and configurations adhere to\nthe necessary standards and formats, thereby enhancing the reliability and security of their applications deployed on\nAWS.\n\n## Getting Started\n\nLet's get started with **pyawsopstoolkit.validators**!\n\n### Installation\n\nInstall **pyawsopstoolkit.validators** via pip:\n\n```bash\npip install pyawsopstoolkit.validators\n```\n\n### Usage\n\nImport the package in your Python script:\n\n```python\nimport pyawsopstoolkit.validators\n```\n\nNow you're all set to harness the power of **pyawsopstoolkit.validators**!\n\n# Documentation\n\n## pyawsopstoolkit.validators\n\n### AccountValidator\n\nThe **AccountValidator** class provides methods to validate AWS account information, ensuring accuracy and consistency\nin account details. It includes constants and methods for validating account numbers.\n\n#### Constants\n\n- `NUMBER_PATTERN (str)`: Regular expression pattern for validating account numbers. The pattern ensures that the\n  account number consists of exactly 12 digits.\n\n#### Methods\n\n- `number(cls, value: str, raise_error: Optional[bool] = True, custom_error_message: Optional[str] = None) -> bool`:\n  Validate the account number.\n\n#### Usage\n\n```python\nfrom pyawsopstoolkit.validators import AccountValidator\n\n# Validate account number\nprint(AccountValidator.number('123456789012'))  # Output: True\nprint(AccountValidator.number('123'))  # Output: False\n```\n\n#### References\n\n- [AWS Documentation: DescribeAccount](https://docs.aws.amazon.com/organizations/latest/APIReference/API_DescribeAccount.html)\n\n### ArnValidator\n\nThe **ArnValidator** class validates AWS ARNs (Amazon Resource Names) according to the AWS ARN format. This class\nprovides methods to validate various aspects of ARNs, including the partition, service, region, account ID, and resource\nID.\n\n#### Constants\n\n- `ARN_PATTERN (str)`: Regular expression pattern for AWS ARNs.\n\n#### Methods\n\n- `arn(cls, value: Union[str, list], raise_error: Optional[bool] = True, custom_error_message: Optional[str] = None) -> bool`:\n  Validates if the given ARN(s) match the ARN pattern.\n\n#### Usage\n\n```python\nfrom pyawsopstoolkit.validators import ArnValidator\n\n# Validate ARNs\nprint(ArnValidator.arn('arn:aws:ec2:us-east-1:123456789012:vpc/vpc-0e9801d129EXAMPLE', False))  # Output: True\nprint(ArnValidator.arn('arn::iam:us-east-1:123456789012:user', False))  # Output: False\n```\n\n#### References\n\n- [AWS Documentation: ARNs](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference-arns.html)\n\n### PolicyValidator\n\nThe **PolicyValidator** class validates AWS IAM policy documents. This class provides methods to validate various\naspects of IAM policies, ensuring their correctness and compliance.\n\n#### Constants\n\n- `VERSION_PATTERN (str)`: Regular expression pattern for validating version strings in policies.\n- `EFFECT_PATTERN (str)`: Regular expression pattern for validating effect strings in policies.\n- `PRINCIPAL_PATTERN (str)`: Regular expression pattern for validating principal strings in policies.\n\n#### Methods\n\n- `policy(cls, value: dict, raise_error: Optional[bool] = True, custom_error_message: Optional[str] = None) -> bool`:\n  Validates a policy dictionary.\n\n#### Usage\n\n```python\nfrom pyawsopstoolkit.validators import PolicyValidator\n\n# Validate IAM policy document\nprint(PolicyValidator.policy(\n    {\n        \"Version\": \"2012-10-17\",\n        \"Id\": \"1\",\n        \"Statement\": {\n            \"Sid\": \"1\",\n            \"Principal\": \"*\",\n            \"Effect\": \"Allow\",\n            \"Action\": \"*\",\n            \"Resource\": \"*\",\n            \"Condition\": {\n                \"Bool\": {\n                    \"aws:SecureTransport\": \"true\"\n                }\n            }\n        }\n    }, False\n))  # Output: True\n\nprint(PolicyValidator.policy(\n    {\n        \"Version\": \"2012-10-17\",\n        \"Id\": \"1\"\n    }, False\n))  # Output: False\n```\n\n#### References\n\n- [AWS Documentation: IAM Policy Grammar](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_grammar.html)\n\n### TagValidator\n\nThe **TagValidator** class validates tags according to predefined patterns. This class provides methods to validate keys\nand values of tags in dictionaries or lists of dictionaries.\n\n#### Constants\n\n- `KEY_PATTERN (str)`: Regular expression pattern used to validate keys in a dictionary of tags.\n- `VALUE_PATTERN (str)`: Regular expression pattern used to validate values in a dictionary of tags.\n\n#### Methods\n\n- `tag(cls, value: Union[dict, list], raise_error: Optional[bool] = True, custom_error_message: Optional[str] = None) -> bool`:\n  Validates a dictionary or a list of dictionaries of tags.\n\n#### Usage\n\n```python\nfrom pyawsopstoolkit.validators import TagValidator\n\n# Validate tag dictionary\nprint(TagValidator.tag(\n    {\n        'Key': 'sample',\n        'Value': 'sample-test'\n    }, False\n))  # Output: True\n\nprint(TagValidator.tag(\n    {\n        'Key': 1,\n        1: 'sample-test'\n    }, False\n))  # Output: False\n```\n\n#### References\n\n- [AWS Documentation: Tagging](https://docs.aws.amazon.com/tag-editor/latest/userguide/tagging.html)\n\n### Validator\n\nThe **Validator** class validates according to predefined patterns. This class provides methods to validate various\naspects of AWS, such as region code.\n\n#### Constants\n\n- `REGION_PATTERN (str)`: Regular expression pattern used to validate region codes.\n\n#### Methods\n\n- `region(cls, value: str, raise_error: Optional[bool] = True, custom_error_message: Optional[str] = None) -> bool`:\n  Validates a region value.\n\n#### Usage\n\n```python\nfrom pyawsopstoolkit.validators import Validator\n\n# Validate region code\nprint(Validator.region('eu-west-1', False))  # Output: True\nprint(Validator.region('Ohio', False))  # Output: False\n```\n\n#### References\n\n- [AWS Documentation: DescribeAccount](https://docs.aws.amazon.com/organizations/latest/APIReference/API_DescribeAccount.html)\n\n# License\n\nPlease refer to the [MIT license](LICENSE) within the project for more information.\n\n# Contributing\n\nWe welcome contributions from the community! Whether you have ideas for new features, bug fixes, or enhancements, feel\nfree to open an issue or submit a pull request on [GitHub](https://github.com/coldsofttech/pyawsopstoolkit.validators).\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "This package provides a comprehensive set of validation classes specifically crafted for use with AWS",
    "version": "0.1.0",
    "project_urls": {
        "Homepage": "https://github.com/coldsofttech/pyawsopstoolkit.validators"
    },
    "split_keywords": [
        "aws",
        " toolkit",
        " operations",
        " validators",
        " validations",
        " amazon-web-services"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fad2c7ef6b60fa6d976fe57ff74e6ec444b8af926106001a11668da2556b0832",
                "md5": "a422e03fc506df43178ab7812a4a9eca",
                "sha256": "da26248ee10490542ae074304233c3215727b242d11142f933e26e138931a456"
            },
            "downloads": -1,
            "filename": "pyawsopstoolkit.validators-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a422e03fc506df43178ab7812a4a9eca",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 8292,
            "upload_time": "2024-05-12T20:36:02",
            "upload_time_iso_8601": "2024-05-12T20:36:02.832599Z",
            "url": "https://files.pythonhosted.org/packages/fa/d2/c7ef6b60fa6d976fe57ff74e6ec444b8af926106001a11668da2556b0832/pyawsopstoolkit.validators-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-12 20:36:02",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "coldsofttech",
    "github_project": "pyawsopstoolkit.validators",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "pyawsopstoolkit.validators"
}
        
Elapsed time: 0.45681s