diff options
author | CoprDistGit <infra@openeuler.org> | 2023-05-31 07:53:38 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-05-31 07:53:38 +0000 |
commit | 2741e2d34bed2b5a3539fdff7730d1fe885ce004 (patch) | |
tree | 8f8e73ead544de66d7eef237380f8919685f530b | |
parent | f5f867b83bff6ab7a606a8754e8e71ba51f337f5 (diff) |
automatic import of python-cloudflare-api
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-cloudflare-api.spec | 646 | ||||
-rw-r--r-- | sources | 1 |
3 files changed, 648 insertions, 0 deletions
@@ -0,0 +1 @@ +/cloudflare-api-2.1.0.tar.gz diff --git a/python-cloudflare-api.spec b/python-cloudflare-api.spec new file mode 100644 index 0000000..c05b8b1 --- /dev/null +++ b/python-cloudflare-api.spec @@ -0,0 +1,646 @@ +%global _empty_manifest_terminate_build 0 +Name: python-cloudflare-api +Version: 2.1.0 +Release: 1 +Summary: Python client for the Cloudflare v4 API +License: MIT +URL: https://github.com/nikhiljohn10/cloudflare-api +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/0c/5f/43d5ae97e950f855286098ab4a0240d8e180cbc7f4f3c83fc5d5eaa3e489/cloudflare-api-2.1.0.tar.gz +BuildArch: noarch + +Requires: python3-requests + +%description +<p align="center"><img src="https://raw.githubusercontent.com/nikhiljohn10/cloudflare-api/main/assets/images/logo.svg?sanitize=true" height="130"></p> + +[](https://github.com/nikhiljohn10/cloudflare-api/actions/workflows/publish.yml) [](https://pypi.org/project/cloudflare-api) [](https://github.com/nikhiljohn10/cloudflare-api/releases) [](https://pypi.org/project/cloudflare-api) [](https://www.codefactor.io/repository/github/nikhiljohn10/cloudflare-api) [](https://github.com/nikhiljohn10/cloudflare-api/blob/main/LICENSE) + +Python client for Cloudflare API v4 + +> Require Python 3.9+ + +## Usage + +### Python Package + +```bash +pip install cloudflare-api +``` + +Sample code can be found inside [/test.py](https://github.com/nikhiljohn10/cloudflare-api/blob/main/test.py) + +### Source Code + +```bash +git clone https://github.com/nikhiljohn10/cloudflare-api +cd cloudflare-api +``` + +### Instructions to get new API Token +1. Go to [Dashboard](https://dash.cloudflare.com/profile/api-tokens) +2. Create Token +3. Use `Edit Cloudflare Workers` template +4. Select one account from **Account Resources** +5. Select `All Zones` or specific zones under **Zone Resources** +6. Continue to summary +7. Create Token +8. Copy the token and save it somewhere secret & secure. + +Then run the following command in terminal: +```bash +make init +. venv/bin/activate +make test +``` + +If it is running for first time, you will be asked to enter API Token. Paste the api token copied from Dashboard. + +## Example + +For this example, `poetry` is used for easy setup. +```bash +python3 -m pip install --user poetry +mkdir -p myapp && cd myapp +poetry init -n +poetry add cloudflare-api +``` + +Copy the code below in to a new file `./myapp/app.py`. +```python +#!/usr/bin/env python3 + +from CloudflareAPI import Cloudflare + +def main(): + cf = Cloudflare() + + print(cf.account.list()) + print(cf.user.details()) + print(cf.worker.list()) + print(cf.store.list()) + +if __name__ == "__main__": + main() +``` + +You can now run the program using following command: +```bash +poetry run python app.py +``` + +If it is running for first time, you will be asked to enter API Token. Paste the api token copied from Dashboard. This will create `cf-config.ini` file in your current working directory for future reference of the api token. + +You can find more examples in [`examples`](https://github.com/nikhiljohn10/cloudflare-api/tree/main/examples) directory + +## Default Permissions + +**1. Account** + - Workers Tail ( Read ) + - Workers KV Storage ( Edit ) + - Workers Scripts ( Edit ) + - Account Settings ( Read ) + +**2. Zones** + - Workers Routes ( Edit ) + +**3. Users** + - User Details ( Read ) + +## Available endpoints + +### Account + +- `list` - List all accounts where given token have access +- `get_id` - Return account id if only one account exists. Otherwise display all accounts availabe and exit. +- `details` - Display details of an account +- `rename`__*__ - Rename an existing account + + ### AccountData + + ### AccountSettings + +### User + +- `details` - Display details of the account's user + + ### UserData + +### Worker + +- `list` - List all existing workers +- `upload` - Upload a new worker with binding if given + - Upload file along as javascript + - Upload file along with metadata as multipart form-data + - KV Bindings + - Environment variables + - Secrets +- `download` - Download an existing worker +- `deploy` - Deploy an existing worker using the subdomain +- `undeploy` - Undeploy an existing worker +- `delete` - Delete an existing worker + + ### Subdomain + + - `create` - Create a new subdomain if none exists + - `get` - Get the current subdomain from cloudflare account + + ### Cron + + - `update` - Update an existing cron or create new cron for a worker + - `get` - Get the cron task list of specified worker + +### Store(Workers KV) + +- `list` - List all existing Namespaces +- `get_ns` - Returns requested Namespace object +- `create` - Create a new namespace +- `rename` - Rename an existing namespace +- `delete` - Delete an existing namespace + + ### Namespace + + - `keys` - Display all the keys in the Namespace + - `read` - Read the value of given key in the Namespace + - `write` - Write given key-value pair to the Namespace + - `bulk_write` - Write given key-value pairs in bulk to the Namespace + - `delete` - Delete given key from the Namespace + - `bulk_delete` - Delete given keys in bulk from the Namespace + + ### Metadata + + ### NSKey + + ### NSBundler + + - `add` - Add key-value pair with metadata to bundler + +**( * : Not accessable with default Worker permissions )** + +## Development + +### Version Bump + +To display current version: +``` +make version +``` + +To bump to new version, where x.y.z is major,minor & patch versions respectively: +``` +make VERSION=x.y.z bump +``` + +The above command does the following: + +1. Update version in `__version__.py` inside package +2. Create a commit for the above change +3. Tag the commit with VERSION +4. Push the content in to main branch with tags +5. Python publish workflow action activates +6. Release the version pushed +7. Build python package +8. Publish python package in to pypi.org + + + + +%package -n python3-cloudflare-api +Summary: Python client for the Cloudflare v4 API +Provides: python-cloudflare-api +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-cloudflare-api +<p align="center"><img src="https://raw.githubusercontent.com/nikhiljohn10/cloudflare-api/main/assets/images/logo.svg?sanitize=true" height="130"></p> + +[](https://github.com/nikhiljohn10/cloudflare-api/actions/workflows/publish.yml) [](https://pypi.org/project/cloudflare-api) [](https://github.com/nikhiljohn10/cloudflare-api/releases) [](https://pypi.org/project/cloudflare-api) [](https://www.codefactor.io/repository/github/nikhiljohn10/cloudflare-api) [](https://github.com/nikhiljohn10/cloudflare-api/blob/main/LICENSE) + +Python client for Cloudflare API v4 + +> Require Python 3.9+ + +## Usage + +### Python Package + +```bash +pip install cloudflare-api +``` + +Sample code can be found inside [/test.py](https://github.com/nikhiljohn10/cloudflare-api/blob/main/test.py) + +### Source Code + +```bash +git clone https://github.com/nikhiljohn10/cloudflare-api +cd cloudflare-api +``` + +### Instructions to get new API Token +1. Go to [Dashboard](https://dash.cloudflare.com/profile/api-tokens) +2. Create Token +3. Use `Edit Cloudflare Workers` template +4. Select one account from **Account Resources** +5. Select `All Zones` or specific zones under **Zone Resources** +6. Continue to summary +7. Create Token +8. Copy the token and save it somewhere secret & secure. + +Then run the following command in terminal: +```bash +make init +. venv/bin/activate +make test +``` + +If it is running for first time, you will be asked to enter API Token. Paste the api token copied from Dashboard. + +## Example + +For this example, `poetry` is used for easy setup. +```bash +python3 -m pip install --user poetry +mkdir -p myapp && cd myapp +poetry init -n +poetry add cloudflare-api +``` + +Copy the code below in to a new file `./myapp/app.py`. +```python +#!/usr/bin/env python3 + +from CloudflareAPI import Cloudflare + +def main(): + cf = Cloudflare() + + print(cf.account.list()) + print(cf.user.details()) + print(cf.worker.list()) + print(cf.store.list()) + +if __name__ == "__main__": + main() +``` + +You can now run the program using following command: +```bash +poetry run python app.py +``` + +If it is running for first time, you will be asked to enter API Token. Paste the api token copied from Dashboard. This will create `cf-config.ini` file in your current working directory for future reference of the api token. + +You can find more examples in [`examples`](https://github.com/nikhiljohn10/cloudflare-api/tree/main/examples) directory + +## Default Permissions + +**1. Account** + - Workers Tail ( Read ) + - Workers KV Storage ( Edit ) + - Workers Scripts ( Edit ) + - Account Settings ( Read ) + +**2. Zones** + - Workers Routes ( Edit ) + +**3. Users** + - User Details ( Read ) + +## Available endpoints + +### Account + +- `list` - List all accounts where given token have access +- `get_id` - Return account id if only one account exists. Otherwise display all accounts availabe and exit. +- `details` - Display details of an account +- `rename`__*__ - Rename an existing account + + ### AccountData + + ### AccountSettings + +### User + +- `details` - Display details of the account's user + + ### UserData + +### Worker + +- `list` - List all existing workers +- `upload` - Upload a new worker with binding if given + - Upload file along as javascript + - Upload file along with metadata as multipart form-data + - KV Bindings + - Environment variables + - Secrets +- `download` - Download an existing worker +- `deploy` - Deploy an existing worker using the subdomain +- `undeploy` - Undeploy an existing worker +- `delete` - Delete an existing worker + + ### Subdomain + + - `create` - Create a new subdomain if none exists + - `get` - Get the current subdomain from cloudflare account + + ### Cron + + - `update` - Update an existing cron or create new cron for a worker + - `get` - Get the cron task list of specified worker + +### Store(Workers KV) + +- `list` - List all existing Namespaces +- `get_ns` - Returns requested Namespace object +- `create` - Create a new namespace +- `rename` - Rename an existing namespace +- `delete` - Delete an existing namespace + + ### Namespace + + - `keys` - Display all the keys in the Namespace + - `read` - Read the value of given key in the Namespace + - `write` - Write given key-value pair to the Namespace + - `bulk_write` - Write given key-value pairs in bulk to the Namespace + - `delete` - Delete given key from the Namespace + - `bulk_delete` - Delete given keys in bulk from the Namespace + + ### Metadata + + ### NSKey + + ### NSBundler + + - `add` - Add key-value pair with metadata to bundler + +**( * : Not accessable with default Worker permissions )** + +## Development + +### Version Bump + +To display current version: +``` +make version +``` + +To bump to new version, where x.y.z is major,minor & patch versions respectively: +``` +make VERSION=x.y.z bump +``` + +The above command does the following: + +1. Update version in `__version__.py` inside package +2. Create a commit for the above change +3. Tag the commit with VERSION +4. Push the content in to main branch with tags +5. Python publish workflow action activates +6. Release the version pushed +7. Build python package +8. Publish python package in to pypi.org + + + + +%package help +Summary: Development documents and examples for cloudflare-api +Provides: python3-cloudflare-api-doc +%description help +<p align="center"><img src="https://raw.githubusercontent.com/nikhiljohn10/cloudflare-api/main/assets/images/logo.svg?sanitize=true" height="130"></p> + +[](https://github.com/nikhiljohn10/cloudflare-api/actions/workflows/publish.yml) [](https://pypi.org/project/cloudflare-api) [](https://github.com/nikhiljohn10/cloudflare-api/releases) [](https://pypi.org/project/cloudflare-api) [](https://www.codefactor.io/repository/github/nikhiljohn10/cloudflare-api) [](https://github.com/nikhiljohn10/cloudflare-api/blob/main/LICENSE) + +Python client for Cloudflare API v4 + +> Require Python 3.9+ + +## Usage + +### Python Package + +```bash +pip install cloudflare-api +``` + +Sample code can be found inside [/test.py](https://github.com/nikhiljohn10/cloudflare-api/blob/main/test.py) + +### Source Code + +```bash +git clone https://github.com/nikhiljohn10/cloudflare-api +cd cloudflare-api +``` + +### Instructions to get new API Token +1. Go to [Dashboard](https://dash.cloudflare.com/profile/api-tokens) +2. Create Token +3. Use `Edit Cloudflare Workers` template +4. Select one account from **Account Resources** +5. Select `All Zones` or specific zones under **Zone Resources** +6. Continue to summary +7. Create Token +8. Copy the token and save it somewhere secret & secure. + +Then run the following command in terminal: +```bash +make init +. venv/bin/activate +make test +``` + +If it is running for first time, you will be asked to enter API Token. Paste the api token copied from Dashboard. + +## Example + +For this example, `poetry` is used for easy setup. +```bash +python3 -m pip install --user poetry +mkdir -p myapp && cd myapp +poetry init -n +poetry add cloudflare-api +``` + +Copy the code below in to a new file `./myapp/app.py`. +```python +#!/usr/bin/env python3 + +from CloudflareAPI import Cloudflare + +def main(): + cf = Cloudflare() + + print(cf.account.list()) + print(cf.user.details()) + print(cf.worker.list()) + print(cf.store.list()) + +if __name__ == "__main__": + main() +``` + +You can now run the program using following command: +```bash +poetry run python app.py +``` + +If it is running for first time, you will be asked to enter API Token. Paste the api token copied from Dashboard. This will create `cf-config.ini` file in your current working directory for future reference of the api token. + +You can find more examples in [`examples`](https://github.com/nikhiljohn10/cloudflare-api/tree/main/examples) directory + +## Default Permissions + +**1. Account** + - Workers Tail ( Read ) + - Workers KV Storage ( Edit ) + - Workers Scripts ( Edit ) + - Account Settings ( Read ) + +**2. Zones** + - Workers Routes ( Edit ) + +**3. Users** + - User Details ( Read ) + +## Available endpoints + +### Account + +- `list` - List all accounts where given token have access +- `get_id` - Return account id if only one account exists. Otherwise display all accounts availabe and exit. +- `details` - Display details of an account +- `rename`__*__ - Rename an existing account + + ### AccountData + + ### AccountSettings + +### User + +- `details` - Display details of the account's user + + ### UserData + +### Worker + +- `list` - List all existing workers +- `upload` - Upload a new worker with binding if given + - Upload file along as javascript + - Upload file along with metadata as multipart form-data + - KV Bindings + - Environment variables + - Secrets +- `download` - Download an existing worker +- `deploy` - Deploy an existing worker using the subdomain +- `undeploy` - Undeploy an existing worker +- `delete` - Delete an existing worker + + ### Subdomain + + - `create` - Create a new subdomain if none exists + - `get` - Get the current subdomain from cloudflare account + + ### Cron + + - `update` - Update an existing cron or create new cron for a worker + - `get` - Get the cron task list of specified worker + +### Store(Workers KV) + +- `list` - List all existing Namespaces +- `get_ns` - Returns requested Namespace object +- `create` - Create a new namespace +- `rename` - Rename an existing namespace +- `delete` - Delete an existing namespace + + ### Namespace + + - `keys` - Display all the keys in the Namespace + - `read` - Read the value of given key in the Namespace + - `write` - Write given key-value pair to the Namespace + - `bulk_write` - Write given key-value pairs in bulk to the Namespace + - `delete` - Delete given key from the Namespace + - `bulk_delete` - Delete given keys in bulk from the Namespace + + ### Metadata + + ### NSKey + + ### NSBundler + + - `add` - Add key-value pair with metadata to bundler + +**( * : Not accessable with default Worker permissions )** + +## Development + +### Version Bump + +To display current version: +``` +make version +``` + +To bump to new version, where x.y.z is major,minor & patch versions respectively: +``` +make VERSION=x.y.z bump +``` + +The above command does the following: + +1. Update version in `__version__.py` inside package +2. Create a commit for the above change +3. Tag the commit with VERSION +4. Push the content in to main branch with tags +5. Python publish workflow action activates +6. Release the version pushed +7. Build python package +8. Publish python package in to pypi.org + + + + +%prep +%autosetup -n cloudflare-api-2.1.0 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-cloudflare-api -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Wed May 31 2023 Python_Bot <Python_Bot@openeuler.org> - 2.1.0-1 +- Package Spec generated @@ -0,0 +1 @@ +45b796b8fd141c15fa49b8b7de29b9cf cloudflare-api-2.1.0.tar.gz |