Netzo Logo

cloudflare

Cloudflare is a web performance and security company.

Usage

import { cloudflare } from 'netzo/apis/cloudflare.ts'

const api = cloudflare({
  apiKey: Deno.env.get('CLOUDFLARE_API_KEY')
})

Configuration

The cloudfare factory function expects an object with the following, and returns an object with an API client api.

ParamTypeDefaultDescription
apiKeystringDeno.env.get('CLOUDFLARE_API_KEY')the api key to use for authentication
Refer to the API documentation to get the required information.

Examples

The following examples assume you have created an api client instance.

Find organizations

Find all organizations the user is associated with that match the query.

const query: QueryOrganizations = {}
const result = await api.user.organizations.get<Organizations>(query)
const resultData = result.result

Find zones

Find all your zones that match the query.

const query: QueryZones = {}
const result = await api.zones.get<Zones>(query)
const resultData = result.result

Add zone

Add a new zone.

const data: DataAddZone = {
  account: { id: ZONE_ID },
  name: DOMAIN_NAME
}
const result = await api.zones.post<Zone>(data)
const resultData = result.result

Delete zone

Delete a zone by id.

const result = await api.zones[ZONE_ID].delete<DeleteResult>()
const resultData = result.result

References