python3-cyberfusion-external-providers-ip-ranges 2.1.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,54 @@
1
+ Metadata-Version: 2.1
2
+ Name: python3-cyberfusion-external-providers-ip-ranges
3
+ Version: 2.1.1.1
4
+ Summary: Scripts to add IP ranges of external providers to ferm.
5
+ Home-page: https://github.com/CyberfusionIO/python3-cyberfusion-external-providers-ip-ranges
6
+ Author: Cyberfusion
7
+ Author-email: support@cyberfusion.io
8
+ Platform: linux
9
+ Description-Content-Type: text/markdown
10
+
11
+ # python3-cyberfusion-external-providers-ip-ranges
12
+
13
+ Scripts to add IP ranges of external providers to [ferm](http://ferm.foo-projects.org/) variables.
14
+
15
+ ## Supported providers
16
+
17
+ * Google Cloud
18
+ * Atlassian
19
+ * [Buddy](https://buddy.works/)
20
+
21
+ # Install
22
+
23
+ ## PyPI
24
+
25
+ Run the following command to install the package from PyPI:
26
+
27
+ pip3 install python3-cyberfusion-external-providers-ip-ranges
28
+
29
+ ## Generic
30
+
31
+ Run the following command to create a source distribution:
32
+
33
+ python3 setup.py sdist
34
+
35
+ ## Debian
36
+
37
+ Run the following commands to build a Debian package:
38
+
39
+ mk-build-deps -i -t 'apt -o Debug::pkgProblemResolver=yes --no-install-recommends -y'
40
+ dpkg-buildpackage -us -uc
41
+
42
+ # Configure
43
+
44
+ No configuration is supported.
45
+
46
+ # Usage
47
+
48
+ Run the following command for help:
49
+
50
+ external-providers-ip-ranges-cli -h
51
+
52
+ ## Cron
53
+
54
+ The Debian package installs a cron. This cron runs the command above per supported provider.
@@ -0,0 +1,44 @@
1
+ # python3-cyberfusion-external-providers-ip-ranges
2
+
3
+ Scripts to add IP ranges of external providers to [ferm](http://ferm.foo-projects.org/) variables.
4
+
5
+ ## Supported providers
6
+
7
+ * Google Cloud
8
+ * Atlassian
9
+ * [Buddy](https://buddy.works/)
10
+
11
+ # Install
12
+
13
+ ## PyPI
14
+
15
+ Run the following command to install the package from PyPI:
16
+
17
+ pip3 install python3-cyberfusion-external-providers-ip-ranges
18
+
19
+ ## Generic
20
+
21
+ Run the following command to create a source distribution:
22
+
23
+ python3 setup.py sdist
24
+
25
+ ## Debian
26
+
27
+ Run the following commands to build a Debian package:
28
+
29
+ mk-build-deps -i -t 'apt -o Debug::pkgProblemResolver=yes --no-install-recommends -y'
30
+ dpkg-buildpackage -us -uc
31
+
32
+ # Configure
33
+
34
+ No configuration is supported.
35
+
36
+ # Usage
37
+
38
+ Run the following command for help:
39
+
40
+ external-providers-ip-ranges-cli -h
41
+
42
+ ## Cron
43
+
44
+ The Debian package installs a cron. This cron runs the command above per supported provider.
@@ -0,0 +1,21 @@
1
+ [tool.isort]
2
+ profile = "black"
3
+ line_length = 79
4
+ known_first_party = ["cyberfusion"]
5
+ default_section = "THIRDPARTY"
6
+
7
+ [tool.black]
8
+ line-length = 79
9
+ exclude = '''
10
+ (
11
+ /(
12
+ \.eggs # exclude a few common directories in the
13
+ | \.git # root of the project
14
+ | \.hg
15
+ | \.mypy_cache
16
+ | \.tox
17
+ | \.venv
18
+ | venv
19
+ )/
20
+ )
21
+ '''
@@ -0,0 +1,12 @@
1
+ [aliases]
2
+ test = pytest
3
+
4
+ [tool:pytest]
5
+ norecursedirs = .git build dist *.egg __pycache__ .cache
6
+ testpaths = tests
7
+ junit_suite_name = python3-cyberfusion-external-providers-ip-ranges
8
+
9
+ [egg_info]
10
+ tag_build =
11
+ tag_date = 0
12
+
@@ -0,0 +1,28 @@
1
+ """A setuptools based setup module."""
2
+
3
+ from setuptools import setup
4
+
5
+ with open("README.md", "r", encoding="utf-8") as fh:
6
+ long_description = fh.read()
7
+
8
+ setup(
9
+ name="python3-cyberfusion-external-providers-ip-ranges",
10
+ version="2.1.1.1",
11
+ description="Scripts to add IP ranges of external providers to ferm.",
12
+ long_description=long_description,
13
+ long_description_content_type="text/markdown",
14
+ author="Cyberfusion",
15
+ author_email="support@cyberfusion.io",
16
+ url="https://github.com/CyberfusionIO/python3-cyberfusion-external-providers-ip-ranges",
17
+ platforms=["linux"],
18
+ packages=[
19
+ "cyberfusion.ExternalProvidersIPRanges",
20
+ ],
21
+ package_dir={"": "src"},
22
+ data_files=[],
23
+ entry_points={
24
+ "console_scripts": [
25
+ "external-providers-ip-ranges-cli=cyberfusion.ExternalProvidersIPRanges:main",
26
+ ]
27
+ },
28
+ )
@@ -0,0 +1,131 @@
1
+ """Empty file to turn this into a package."""
2
+
3
+ import os
4
+ from abc import ABCMeta, abstractmethod
5
+ from typing import List
6
+
7
+ import requests
8
+
9
+ from cyberfusion.FermSupport.configuration import Configuration
10
+
11
+
12
+ def get_ferm_base_path() -> str:
13
+ """Get ferm base path."""
14
+ return os.path.join(
15
+ os.path.sep,
16
+ "etc",
17
+ "ferm",
18
+ "vars.d",
19
+ )
20
+
21
+
22
+ class ExternalProviderIPRangeHandlerInterface(metaclass=ABCMeta):
23
+ """Interface for external provider IP range handlers."""
24
+
25
+ def __init__( # noqa: B027
26
+ self,
27
+ ) -> None:
28
+ """Do nothing."""
29
+
30
+ @property
31
+ @abstractmethod
32
+ def name(self) -> str:
33
+ """Get external provider name."""
34
+
35
+ @property
36
+ @abstractmethod
37
+ def ip_ranges(self) -> List[str]:
38
+ """Get IP ranges."""
39
+
40
+
41
+ class AtlassianIPRangeHandler(ExternalProviderIPRangeHandlerInterface):
42
+ """Class for external provider IP range handler."""
43
+
44
+ @property
45
+ def name(self) -> str:
46
+ """Get external provider name."""
47
+ return "atlassian"
48
+
49
+ @property
50
+ def ip_ranges(self) -> List[str]:
51
+ """Get IP ranges."""
52
+ result = []
53
+
54
+ request = requests.get("https://ip-ranges.atlassian.com/")
55
+ request.raise_for_status()
56
+ data = request.json()
57
+
58
+ for item in data["items"]:
59
+ result.append(item["cidr"])
60
+
61
+ return result
62
+
63
+
64
+ class GoogleCloudIPRangeHandler(ExternalProviderIPRangeHandlerInterface):
65
+ """Class for external provider IP range handler."""
66
+
67
+ @property
68
+ def name(self) -> str:
69
+ """Get external provider name."""
70
+ return "google_cloud"
71
+
72
+ @property
73
+ def ip_ranges(self) -> List[str]:
74
+ """Get IP ranges."""
75
+ result = []
76
+
77
+ request = requests.get("https://www.gstatic.com/ipranges/cloud.json")
78
+ request.raise_for_status()
79
+ data = request.json()
80
+
81
+ for item in data["prefixes"]:
82
+ if "ipv6Prefix" in item:
83
+ result.append(item["ipv6Prefix"])
84
+ else:
85
+ result.append(item["ipv4Prefix"])
86
+
87
+ return result
88
+
89
+
90
+ class BuddyIPRangeHandler(ExternalProviderIPRangeHandlerInterface):
91
+ """Class for external provider IP range handler."""
92
+
93
+ @property
94
+ def name(self) -> str:
95
+ """Get external provider name."""
96
+ return "buddy"
97
+
98
+ @property
99
+ def ip_ranges(self) -> List[str]:
100
+ """Get IP ranges."""
101
+ result = []
102
+
103
+ request = requests.get("https://buddy.works/api/ips")
104
+ request.raise_for_status()
105
+ data = request.json()
106
+
107
+ for item in data["buddy"] + data["windows"] + data["ios"]:
108
+ result.append(item)
109
+
110
+ return result
111
+
112
+
113
+ def main() -> None:
114
+ """Spawn relevant class for CLI function."""
115
+ configuration = Configuration(
116
+ path=os.path.join(
117
+ get_ferm_base_path(),
118
+ "external-providers-ip-ranges.conf",
119
+ )
120
+ )
121
+
122
+ handlers = [
123
+ BuddyIPRangeHandler(),
124
+ GoogleCloudIPRangeHandler(),
125
+ AtlassianIPRangeHandler(),
126
+ ]
127
+
128
+ for handler in handlers:
129
+ configuration.add_variable(name=handler.name, values=handler.ip_ranges)
130
+
131
+ configuration.save()
@@ -0,0 +1,54 @@
1
+ Metadata-Version: 2.1
2
+ Name: python3-cyberfusion-external-providers-ip-ranges
3
+ Version: 2.1.1.1
4
+ Summary: Scripts to add IP ranges of external providers to ferm.
5
+ Home-page: https://github.com/CyberfusionIO/python3-cyberfusion-external-providers-ip-ranges
6
+ Author: Cyberfusion
7
+ Author-email: support@cyberfusion.io
8
+ Platform: linux
9
+ Description-Content-Type: text/markdown
10
+
11
+ # python3-cyberfusion-external-providers-ip-ranges
12
+
13
+ Scripts to add IP ranges of external providers to [ferm](http://ferm.foo-projects.org/) variables.
14
+
15
+ ## Supported providers
16
+
17
+ * Google Cloud
18
+ * Atlassian
19
+ * [Buddy](https://buddy.works/)
20
+
21
+ # Install
22
+
23
+ ## PyPI
24
+
25
+ Run the following command to install the package from PyPI:
26
+
27
+ pip3 install python3-cyberfusion-external-providers-ip-ranges
28
+
29
+ ## Generic
30
+
31
+ Run the following command to create a source distribution:
32
+
33
+ python3 setup.py sdist
34
+
35
+ ## Debian
36
+
37
+ Run the following commands to build a Debian package:
38
+
39
+ mk-build-deps -i -t 'apt -o Debug::pkgProblemResolver=yes --no-install-recommends -y'
40
+ dpkg-buildpackage -us -uc
41
+
42
+ # Configure
43
+
44
+ No configuration is supported.
45
+
46
+ # Usage
47
+
48
+ Run the following command for help:
49
+
50
+ external-providers-ip-ranges-cli -h
51
+
52
+ ## Cron
53
+
54
+ The Debian package installs a cron. This cron runs the command above per supported provider.
@@ -0,0 +1,10 @@
1
+ README.md
2
+ pyproject.toml
3
+ setup.cfg
4
+ setup.py
5
+ src/cyberfusion/ExternalProvidersIPRanges/__init__.py
6
+ src/python3_cyberfusion_external_providers_ip_ranges.egg-info/PKG-INFO
7
+ src/python3_cyberfusion_external_providers_ip_ranges.egg-info/SOURCES.txt
8
+ src/python3_cyberfusion_external_providers_ip_ranges.egg-info/dependency_links.txt
9
+ src/python3_cyberfusion_external_providers_ip_ranges.egg-info/entry_points.txt
10
+ src/python3_cyberfusion_external_providers_ip_ranges.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ external-providers-ip-ranges-cli = cyberfusion.ExternalProvidersIPRanges:main