Skip to content

Latest commit

 

History

History
366 lines (283 loc) · 24.4 KB

README.md

File metadata and controls

366 lines (283 loc) · 24.4 KB

Dns

Overview

Available Operations

getRecords

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 "@vercel/sdk";

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

async function run() {
  const result = await vercel.dns.getRecords({
    domain: "example.com",
    limit: "20",
    since: "1609499532000",
    until: "1612264332000",
    teamId: "team_1a2b3c4d5e6f7g8h9i0j1k2l",
    slug: "my-team-url-slug",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { VercelCore } from "@vercel/sdk/core.js";
import { dnsGetRecords } from "@vercel/sdk/funcs/dnsGetRecords.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 dnsGetRecords(vercel, {
    domain: "example.com",
    limit: "20",
    since: "1609499532000",
    until: "1612264332000",
    teamId: "team_1a2b3c4d5e6f7g8h9i0j1k2l",
    slug: "my-team-url-slug",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("dnsGetRecords failed:", res.error);
  }
}

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.GetRecordsResponseBody>

Errors

Error Type Status Code Content Type
models.SDKError 4XX, 5XX */*

createRecord

Creates a DNS record for a domain.

Example Usage

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

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

async function run() {
  const result = await vercel.dns.createRecord({
    domain: "example.com",
    teamId: "team_1a2b3c4d5e6f7g8h9i0j1k2l",
    slug: "my-team-url-slug",
    requestBody: {
      type: "NS",
      ttl: 60,
      srv: {
        priority: 10,
        weight: 10,
        port: 5000,
        target: "host.example.com",
      },
      comment: "used to verify ownership of domain",
    },
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { VercelCore } from "@vercel/sdk/core.js";
import { dnsCreateRecord } from "@vercel/sdk/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, {
    domain: "example.com",
    teamId: "team_1a2b3c4d5e6f7g8h9i0j1k2l",
    slug: "my-team-url-slug",
    requestBody: {
      type: "NS",
      ttl: 60,
      srv: {
        priority: 10,
        weight: 10,
        port: 5000,
        target: "host.example.com",
      },
      comment: "used to verify ownership of domain",
    },
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("dnsCreateRecord failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request models.CreateRecordRequest ✔️ 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.CreateRecordResponseBody>

Errors

Error Type Status Code Content Type
models.SDKError 4XX, 5XX */*

updateRecord

Updates an existing DNS record for a domain name.

Example Usage

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

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

async function run() {
  const result = await vercel.dns.updateRecord({
    recordId: "rec_2qn7pzrx89yxy34vezpd31y9",
    teamId: "team_1a2b3c4d5e6f7g8h9i0j1k2l",
    slug: "my-team-url-slug",
    requestBody: {
      name: "example-1",
      value: "google.com",
      type: "A",
      ttl: 60,
      srv: null,
      https: null,
      comment: "used to verify ownership of domain",
    },
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { VercelCore } from "@vercel/sdk/core.js";
import { dnsUpdateRecord } from "@vercel/sdk/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, {
    recordId: "rec_2qn7pzrx89yxy34vezpd31y9",
    teamId: "team_1a2b3c4d5e6f7g8h9i0j1k2l",
    slug: "my-team-url-slug",
    requestBody: {
      name: "example-1",
      value: "google.com",
      type: "A",
      ttl: 60,
      srv: null,
      https: null,
      comment: "used to verify ownership of domain",
    },
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("dnsUpdateRecord failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request models.UpdateRecordRequest ✔️ 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.UpdateRecordResponseBody>

Errors

Error Type Status Code Content Type
models.SDKError 4XX, 5XX */*

removeRecord

Removes an existing DNS record from a domain name.

Example Usage

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

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

async function run() {
  const result = await vercel.dns.removeRecord({
    domain: "example.com",
    recordId: "rec_V0fra8eEgQwEpFhYG2vTzC3K",
    teamId: "team_1a2b3c4d5e6f7g8h9i0j1k2l",
    slug: "my-team-url-slug",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { VercelCore } from "@vercel/sdk/core.js";
import { dnsRemoveRecord } from "@vercel/sdk/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, {
    domain: "example.com",
    recordId: "rec_V0fra8eEgQwEpFhYG2vTzC3K",
    teamId: "team_1a2b3c4d5e6f7g8h9i0j1k2l",
    slug: "my-team-url-slug",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("dnsRemoveRecord failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request models.RemoveRecordRequest ✔️ 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.RemoveRecordResponseBody>

Errors

Error Type Status Code Content Type
models.SDKError 4XX, 5XX */*