Giter Site home page Giter Site logo

node-cloudflare's Introduction

CloudFlare API Client for Node.js

An edible "BREAD" (Browse, Read, Edit, Add, and Delete) API Client for the CloudFlare v4 Client API.

With this API client, you'll get the following features:

  • Promise-based API, allowing for easy async/await usage in harmony JavaScript engines, and with JavaScript transpilers.
  • Effortlessly connects over HTTP/2.
  • Automatic handling of Gzip/Deflate compression.
  • Expontential backoff and retry in the presence of error.

Node.js Support

This CloudFlare API client supports Node.js v4 and greater.

Usage

Creating a Client

var CFClient = require('cloudflare');
var client = new CFClient({
    email: '[email protected]',
    key: 'deadbeef'
});

Zones

Zone

A normalized representation of a CloudFlare Zone. Properties that were snake_cased have been aliased to camelCased. TODO: document all the known properties.

Zone.create(properties): Zone

  • properties: The properties to set on the new Zone object.
  • Returns: A new Zone object.

Creates a new Zone object with the provided properties. The returned object can be used with the below methods that accept a Zone object.

Zone.is(z): boolean

  • z: The other object that may, or may not, be a Zone object.
  • Returns: true if the parameter is a Zone object, otherwise false.

browseZones([query, [options]]): Promise<PaginatedResponse<Zone[]>>

  • query: An object to pass filter and sorting parameters to the API
  • options: see Request Options
  • Returns: A Promise that resolves to a list of Zone objects wrapped in a PaginatedResponse
  • API Reference: List zones

Retrives the list of Zone objects, optionally filtered and sorted by query options.

readZone(z_id, [options]): Promise<Zone>

  • z_id: The string Zone id
  • options: see Request Options
  • Returns: A Promise that resolves to a Zone
  • API Reference: Zone details

Retrives the Zone for the zone identifier z_id.

editZone(z, [options]): Promise<Zone>

  • z: Zone object
  • options: see Request Options
  • Returns: A Promise that resolves to a Zone.
  • API Reference: Edit Zone Properties

Saves the modifications to the Zone object.

Note: The CloudFlare API currently doesn't support patching multiple properties at once. This method executes the modifications in series, but if an error occurs, there are no guarantees which properties would have been applied.

addZone(z, [jumpstart, [options]]): Promise<Zone>

  • z: Zone object
  • jumpstart: true to automatically fetch existing DNS records (default). false to disable this behavior.
  • options: see Request Options
  • API Reference: Create a zone

Add a zone to an account or organization.

checkZoneActivation(z): Promise<{id: string}>

Initiate another zone activation check.

deleteZone(z, [options]): Promise<{id: string}>

  • z: Zone object or string zone id
  • options: see Request Options
  • Returns: A Promise that resolves to a tombstone stub
  • API Reference: Delete a zone

Deletes the Zone from CloudFlare. A tombstone stub is returned.

deleteCache(z, query, [options]): Promise<bool>

  • z: Zone object or string zone id
  • query: The (required) purge options for the API:
    • purge_everything: Delete all of the zone's content from the CloudFlare cache. Note: This may cause an increase in connections to your server after performing this action.
    • files: An array of URLs that should be removed from cache.
    • tags: Removes assets from cache that were served with a Cache-Tag header that matches a string in this array.
  • options: see Request Options
  • Returns: A Promise that resolves to true.
  • API Reference: Purge all files and Purge individual files by URL and Cache-Tags

Purges content from CloudFlare's cache. Please note that query is required for this API call.

DNS

The CloudFlare API client makes it easy to manage DNS records for domains on CloudFlare.

DNSRecord

A normalized representation of a CloudFlare DNS Record type. Properties that were snake_cased have been aliased to be camelCased.

DNSRecord.create(properties): DNSRecord

  • properties: The properties to set on the new DNSRecord object.
  • Returns: A new DNSRecord object.

Creates a new DNSRecord object with the provided properties. The returned object can be used with the below methods that accept a DNSRecord object.

DNSRecord.is(rr): boolean

  • rr: The other object that may, or may not, be a DNSRecord object.
  • Returns: true if the parameter is a DNSRecord object, otherwise false.

browseDNS(z, [query, [options]]): Promise<PaginatedResponse<DNSRecord[]>>

  • z: Zone object or string zone id
  • query: An object to pass filter and sorting parameters to the API
  • options: see Request Options
  • Returns: A Promise that resolves to a list of DNSRecord objects wrapped in a PaginatedResponse
  • API Reference: List DNS Records

Retrives the listing of DNSRecord objects for a Zone (or zone id).

readDNS(dns_id, z, [options]): Promise<DNSRecord>

  • dns_id: The string DNS record id
  • z: Zone object or string zone id
  • options: see Request Options
  • Returns: A Promise that resolves to a DNSRecord
  • API Reference: DNS record details

Retrive the DNSRecord for an identifier did from Zone (or zone id).

editDNS(d, [options]): Promise<DNSRecord>

  • d: The DNSRecord to be saved
  • options: see Request Options
  • Returns: A Promise that resolves to a new DNSRecord
  • API Reference: Update DNS record

Save the modifications to the DNSRecord.

addDNS(d, [options]): Promise<DNSRecord>

  • d: The DNSRecord to be added
  • options: see Request Options
  • Returns: A Promise that resolves to a new DNSRecord
  • API Reference: Create DNS record

Create a DNS Record corresponding to the provided DNSRecord. A new DNSRecord with an id field is returned.

deleteDNS(d, [options]): Promise<{id: string}>

  • d: The DNSRecord to be deleted
  • options: see Request Options
  • Returns: A Promise that resolves to a tombstone stub
  • API Reference: Delete DNS record

Deletes the DNSRecord from the DNS. A tombstone stub is returned.

CloudFlare IPs

IPRanges

Normalized representation of the CloudFlare IP Ranges.

IPRanges{
    IPv4CIDRs: [
        '199.27.128.0/21'
    ],
    IPv6CIDRs: [
        '2400:cb00::/32'
    ]
}

IPRanges.is(ip): boolean

  • ip: The other object that may, or may not, be an IPRanges object.
  • Returns: true if the parameter is a IPRanges object, otherwise false.

readIPs(): Promise<IPRanges>

  • Returns: A Promise that resolves to IPRanges
  • API Reference: CloudFlare IPs

Retrieves the CloudFlare Edge IP addresses. These are the IP addresses used by CloudFlare to connect to your server.

node-cloudflare's People

Contributors

anttileppa avatar freewil avatar greenkeeperio-bot avatar justinrainbow avatar kfatehi avatar matiboy avatar ratson avatar terinjokes avatar vinnl avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.