Skip to content

Latest commit

 

History

History
319 lines (221 loc) · 33.3 KB

README.md

File metadata and controls

319 lines (221 loc) · 33.3 KB

Dns

(dns)

Overview

Available Operations

listRecords

Retrieves a list of DNS records created for a domain name. By default it returns 20 records if no limit is provided. The rest can be retrieved using the pagination options.

Example Usage

import { Vercel } from "@simplesagar/vercel";

const vercel = new Vercel({
  bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await vercel.dns.listRecords({
    domain: "example.com",
  });
  
  for await (const page of result) {
    // Handle the page
    console.log(page);
  }
}

run();

Standalone function

The standalone function version of this method:

import { VercelCore } from "@simplesagar/vercel/core.js";
import { dnsListRecords } from "@simplesagar/vercel/funcs/dnsListRecords.js";

// Use `VercelCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const vercel = new VercelCore({
  bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await dnsListRecords(vercel, {
    domain: "example.com",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  for await (const page of result) {
    // Handle the page
    console.log(page);
  }
}

run();

Parameters

Parameter Type Required Description
request models.GetRecordsRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<models.GetRecordsResponse>

Errors

Error Object Status Code Content Type
models.SDKError 4xx-5xx /

createRecord

Creates a DNS record for a domain.

Example Usage

import { Vercel } from "@simplesagar/vercel";

const vercel = new Vercel({
  bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await vercel.dns.createRecord("example.com");
  
  // Handle the result
  console.log(result)
}

run();

Standalone function

The standalone function version of this method:

import { VercelCore } from "@simplesagar/vercel/core.js";
import { dnsCreateRecord } from "@simplesagar/vercel/funcs/dnsCreateRecord.js";

// Use `VercelCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const vercel = new VercelCore({
  bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await dnsCreateRecord(vercel, "example.com");

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description Example
domain string ✔️ The domain used to create the DNS record. [object Object]
teamId string The Team identifier to perform the request on behalf of.
slug string The Team slug to perform the request on behalf of.
requestBody models.CreateRecordRequestBody N/A
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<models.CreateRecordResponseBody>

Errors

Error Object Status Code Content Type
models.SDKError 4xx-5xx /

updateRecord

Updates an existing DNS record for a domain name.

Example Usage

import { Vercel } from "@simplesagar/vercel";

const vercel = new Vercel({
  bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await vercel.dns.updateRecord("rec_2qn7pzrx89yxy34vezpd31y9");
  
  // Handle the result
  console.log(result)
}

run();

Standalone function

The standalone function version of this method:

import { VercelCore } from "@simplesagar/vercel/core.js";
import { dnsUpdateRecord } from "@simplesagar/vercel/funcs/dnsUpdateRecord.js";

// Use `VercelCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const vercel = new VercelCore({
  bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await dnsUpdateRecord(vercel, "rec_2qn7pzrx89yxy34vezpd31y9");

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description Example
recordId string ✔️ The id of the DNS record [object Object]
teamId string The Team identifier to perform the request on behalf of.
slug string The Team slug to perform the request on behalf of.
requestBody models.UpdateRecordRequestBody N/A
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<models.UpdateRecordResponseBody>

Errors

Error Object Status Code Content Type
models.SDKError 4xx-5xx /

removeRecord

Removes an existing DNS record from a domain name.

Example Usage

import { Vercel } from "@simplesagar/vercel";

const vercel = new Vercel({
  bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await vercel.dns.removeRecord("example.com", "rec_V0fra8eEgQwEpFhYG2vTzC3K");
  
  // Handle the result
  console.log(result)
}

run();

Standalone function

The standalone function version of this method:

import { VercelCore } from "@simplesagar/vercel/core.js";
import { dnsRemoveRecord } from "@simplesagar/vercel/funcs/dnsRemoveRecord.js";

// Use `VercelCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const vercel = new VercelCore({
  bearerToken: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await dnsRemoveRecord(vercel, "example.com", "rec_V0fra8eEgQwEpFhYG2vTzC3K");

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description Example
domain string ✔️ N/A [object Object]
recordId string ✔️ N/A [object Object]
teamId string The Team identifier to perform the request on behalf of.
slug string The Team slug to perform the request on behalf of.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<models.RemoveRecordResponseBody>

Errors

Error Object Status Code Content Type
models.SDKError 4xx-5xx /