# ![cliffy](assets/cliffy.jpeg) [![build](https://github.com/davepmiller/cliflare/actions/workflows/ci.yml/badge.svg?branch=main)]() [![publish](https://github.com/davepmiller/cliflare/actions/workflows/publish.yml/badge.svg?branch=main)]() [![Coverage Status](https://coveralls.io/repos/github/davepmiller/cliflare/badge.svg)](https://coveralls.io/github/davepmiller/cliflare) [![crates.io](https://img.shields.io/crates/v/cliflare.svg)]() [![downloads](https://img.shields.io/crates/d/cliflare)]() [![license](https://img.shields.io/badge/license-MIT-green.svg)]() * πŸ›  CLI️ to interact with Cloudflare APIs * πŸ₯³ An excuse to write some Rust * πŸ‘· Under heavy development ## Setup ### [Install Rust πŸ“](https://www.rust-lang.org/tools/install) ```bash curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh ``` ### Install ```bash cargo install cliflare ``` ### [Generate a Cloudflare API token πŸ“](https://developers.cloudflare.com/cloudflare-one/api-terraform/scoped-api-tokens/) ### [Grab Account And Zone IDs πŸ“](https://developers.cloudflare.com/fundamentals/setup/find-account-and-zone-ids/) ### Environment ```bash # add your token value to a startup script echo CLOUDFLARE_ENDPOINT=https://api.cloudflare.com/client/v4 >> ~/.zshrc echo CLOUDFLARE_TOKEN=abcd1234**API_TOKEN**4321dcba >> ~/.zshrc echo CLOUDFLARE_ACCOUNT_ID=abcd1234**ACCOUNT_ID**4321dcba >> ~/.zshrc ``` ## Examples ### [Token Verify πŸ“](https://developers.cloudflare.com/api/operations/user-api-tokens-verify-token) ```bash cliflare token verify ``` ### [Zone List πŸ“](https://developers.cloudflare.com/api/operations/zones-get) ```bash # print out all zone info cliflare zone list # print only zone "name" field -- i.e. domains cliflare zone list --domains ``` ### [Create a Zone πŸ“](https://developers.cloudflare.com/api/operations/zones-post) ```bash cliflare zone create newzone.com ``` ### [Delete a Zone πŸ“](https://developers.cloudflare.com/api/operations/zones-0-delete) ```bash cliflare zone delete newzone.com ``` ### [List DNS Records For A Zone πŸ“](https://developers.cloudflare.com/api/operations/dns-records-for-a-zone-list-dns-records) ```bash cliflare dns list --zone_id cliflare dns list --zone_name ``` ### [Export DNS Records For A Zone πŸ“](https://developers.cloudflare.com/api/operations/dns-records-for-a-zone-export-dns-records) ```bash cliflare dns export --zone_id cliflare dns export --zone_name ``` ### [Import DNS Records For A Zone πŸ“](https://developers.cloudflare.com/api/operations/dns-records-for-a-zone-import-dns-records) ```bash cliflare dns import --file --zone_id cliflare dns import -file --zone_name ``` ### [Delete All DNS Records For A Zone πŸ“](https://developers.cloudflare.com/api/operations/dns-records-for-a-zone-delete-dns-record) ```bash cliflare dns clear --zone_id cliflare dns clear --zone_name ``` ### [List All Settings For A Zone πŸ“](https://developers.cloudflare.com/api/operations/zone-settings-get-all-zone-settings) ```bash cliflare settings list --zone_id cliflare settings list --zone_name ``` ## Coming Soon * [Create DNS Record For A Zone](https://developers.cloudflare.com/api/operations/dns-records-for-a-zone-create-dns-record) * Parameterize [Pagination Options](https://developers.cloudflare.com/fundamentals/api/how-to/make-api-calls/#pagination) ## Feature Requests Fill out [this form](https://docs.google.com/forms/d/e/1FAIpQLSfDBhmvtRn1C3Vzi_nplHV9QyBVbPUfdqhziUj_sWYyi-XIFw/viewform?usp=sf_link) and I'll get back to you.