Skip to content
This repository was archived by the owner on Jun 29, 2022. It is now read-only.

Commit 1fe760e

Browse files
authored
Merge pull request #5 from Stewart86/refine-documentations
Refine documentations
2 parents 74e891c + 5a55ac7 commit 1fe760e

File tree

5 files changed

+62
-19
lines changed

5 files changed

+62
-19
lines changed

.gitignore

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,6 @@ cover/
5353
*.mo
5454
*.pot
5555

56-
# pipenv
57-
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
58-
# However, in case of collaboration, if having platform-specific dependencies or dependencies
59-
# having no cross-platform support, pipenv may install dependencies that don't work, or not
60-
# install all needed dependencies.
61-
#Pipfile.lock
62-
6356
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
6457
__pypackages__/
6558

@@ -75,7 +68,7 @@ __pypackages__/
7568
dmypy.json
7669

7770
# vscode
78-
vscode/
71+
.vscode/
7972
.vscode/settings.json
8073
.vscode/launch.json
8174

CONTRIBUTING.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ welcomes contributions in the form of bug reports, feature requests, and pull re
88
Here is a list of important resources for contributors:
99

1010
- `Source Code`_
11-
- `Documentation`_
1211
- `Issue Tracker`_
1312
- `Code of Conduct`_
1413

@@ -57,11 +56,6 @@ Install the package with development requirements:
5756
You can now run an interactive Python session,
5857
or the command-line interface:
5958

60-
.. code:: console
61-
62-
$ poetry run python
63-
$ poetry run aiocloudflare
64-
6559
.. _Poetry: https://python-poetry.org/
6660
.. _Nox: https://nox.thea.codes/
6761
.. _nox-poetry: https://nox-poetry.readthedocs.io/

README.rst

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ aioCloudflare
3232
:target: https://github.com/psf/black
3333
:alt: Black
3434

35-
Inspired by the offical `python-cloudflare` library developed by `Cloudflare`_. This project is created to be competible to use with `asyncio` for non-blocking IO.
35+
Inspired by the offical ``python-cloudflare`` library developed by `Cloudflare`_. This project is created to be compatible with ``asyncio`` for non-blocking IO.
3636

37-
For sync code, it is recommanded to use `python-cloudflare` via `pip install python-cloudflare` as it is used by hundreds and offically maintained by cloudflare. This ensure that APIs are always updated according to Cloudflare API release.
37+
For sync code, it is recommanded to use ``python-cloudflare`` via ``pip install python-cloudflare`` as it is used by hundreds and offically maintained by Cloudflare. This ensure that APIs are always updated according to Cloudflare API release.
3838

3939
*NOTE:* This library is in Pre-Alpha, this means things might break. Do not use it in Production unless you have tested on the API route specific to your use case and that would be at your own risk.
4040

@@ -47,6 +47,13 @@ Features
4747
* Autocompletion on IDE.
4848
* Fully type hinted.
4949

50+
Feature Roadmap
51+
---------------
52+
53+
* to support cert token
54+
* to support sync API client
55+
* to get to 100% test coverage
56+
5057

5158
Requirements
5259
------------
@@ -86,6 +93,18 @@ Full configuration can be done using `Config()` class.
8693
async with Cloudflare(config=config) as cf:
8794
result = await cf.zones.get()
8895
96+
Configuration can also be stored in a ``.env`` file for a "global configuration without needing to create a ``Config()`` class. Keys available are:
97+
98+
.. code:: console
99+
100+
CF_API_EMAIL=""
101+
CF_API_KEY=""
102+
CF_API_CERTKEY=""
103+
CF_API_URL=""
104+
DEBUG=false
105+
CF_PROFILE=""
106+
USER_AGENT=""
107+
89108
90109
Contributing
91110
------------
@@ -112,6 +131,6 @@ please `file an issue`_ along with a detailed description.
112131
.. _PyPI: https://pypi.org/
113132
.. _file an issue: https://github.com/stewart86/aiocloudflare/issues
114133
.. _pip: https://pip.pypa.io/
134+
.. _Cloudflare: https://github.com/cloudflare/python-cloudflare
115135
.. github-only
116136
.. _Contributor Guide: CONTRIBUTING.rst
117-
.. _Cloudflare: https://cloudflare.com

aiocloudflare/cloudflare.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class ClientState(Enum):
3232

3333

3434
class Cloudflare:
35+
"""Cloudflare API Client, a main entry point to all API endpoints."""
36+
3537
def __init__(
3638
self,
3739
email: Optional[str] = None,
@@ -46,6 +48,42 @@ def __init__(
4648
logger: Optional[Logger] = None,
4749
config: Optional[Config] = None,
4850
) -> None:
51+
"""To initalise with async context manager for async calls.
52+
This Class currently only support async operations. To use sync operations,
53+
please use Cloudflare offical Python library `python-cloudflare`
54+
55+
>>> async with Cloudflare() as cf:
56+
>>> result = await cf.zones.get()
57+
58+
An optional `Config()` class can also be use to configure the Cloudflare
59+
instance. When initialised with the config class parameter, all other
60+
parameters will be ignored.
61+
62+
>>> from aiocloudflare import Cloudflare, Config
63+
>>>
64+
>>>
65+
>>> config = Config(email="[email protected]", token="<secret>")
66+
>>> async with Cloudflare(config=config) as cf:
67+
>>> result = await cf.zones.get()
68+
69+
Args:
70+
email (Optional[str], optional):
71+
Registered email to Cloudflare API. Defaults to None.
72+
token (Optional[str], optional):
73+
API token from Cloudflare. Defaults to None.
74+
certtoken (Optional[str], optional):
75+
To use Cert Token **current not implemented**. Defaults to None.
76+
raw (Optional[str], optional): Not Implemented. Defaults to None.
77+
base_url (Optional[str], optional): If not provided, it will
78+
defaults to cloudflare's v4 API. Defaults to None.
79+
debug (Optional[bool], optional): To set debug as true, logs will
80+
be more verbose. Defaults to False.
81+
test (Optional[bool], optional): If True, config will ignore all
82+
args in the init method and use a seperate config must be
83+
provided. Defaults to None.
84+
config (Optional[Config], optional): An optional config class
85+
include all settings. Defaults to None.
86+
"""
4987
if config:
5088
self._config = config
5189
else:

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "aiocloudflare"
3-
version = "0.1.2-alpha"
3+
version = "0.1.3-alpha"
44
description = "A Cloudflare API wrapper for Python with asyncio support"
55
authors = ["Stewart Wong <[email protected]>"]
66
license = "MIT"
@@ -11,7 +11,6 @@ classifiers = [
1111
"Development Status :: 2 - Pre-Alpha",
1212
"Intended Audience :: Developers",
1313
"Programming Language :: Python :: 3.9",
14-
"Programming Language :: Python :: 3.8",
1514
"Topic :: Software Development :: Libraries :: Python Modules",
1615
]
1716

0 commit comments

Comments
 (0)