UNPKG

@google-cloud/dns

Version:
204 lines (203 loc) 8.08 kB
/*! * Copyright 2014 Google Inc. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { GoogleAuthOptions, Metadata, Service } from '@google-cloud/common'; import { Stream } from 'stream'; import { Zone } from './zone'; export { Record, RecordMetadata } from './record'; export interface GetZonesRequest { autoPaginate?: boolean; maxApiCalls?: number; maxResults?: number; pageToken?: string; } export interface DNSConfig extends GoogleAuthOptions { autoRetry?: boolean; maxRetries?: number; } export interface GetZonesCallback { (err: Error | null, zones: Zone[] | null, nextQuery?: GetZonesRequest | null, apiResponse?: Metadata): void; } export type GetZonesResponse = [Zone[], GetZonesRequest | null, Metadata]; export interface GetZoneCallback { (err: Error | null, zone?: Zone | null, apiResponse?: Metadata): void; } export interface CreateZoneRequest { dnsName: string; description?: string; name?: string; dnssecConfig?: ManagedZoneDnsSecConfig; } export interface ManagedZoneDnsSecConfig { /** * Specifies parameters for generating initial DnsKeys for this ManagedZone. Can only be changed while the state is OFF. */ defaultKeySpecs?: DnsKeySpec[]; kind?: string | null; /** * Specifies the mechanism for authenticated denial-of-existence responses. Can only be changed while the state is OFF. */ nonExistence?: string | null; /** * Specifies whether DNSSEC is enabled, and what mode it is in. */ state?: 'on' | 'off' | null; } export interface DnsKeySpec { /** * String mnemonic specifying the DNSSEC algorithm of this key. */ algorithm?: string | null; /** * Length of the keys in bits. */ keyLength?: number | null; /** * Specifies whether this is a key signing key (KSK) or a zone signing key (ZSK). Key signing keys have the Secure Entry Point flag set and, when active, will only be used to sign resource record sets of type DNSKEY. Zone signing keys do not have the Secure Entry Point flag set and will be used to sign all other types of resource record sets. */ keyType?: string | null; kind?: string | null; } export type CreateZoneResponse = [Zone, Metadata]; export type CreateZoneCallback = GetZoneCallback; export interface DNSOptions extends GoogleAuthOptions { /** * The API endpoint of the service used to make requests. * Defaults to `dns.googleapis.com`. */ apiEndpoint?: string; } /** * @typedef {object} ClientConfig * @property {string} [projectId] The project ID from the Google Developer's * Console, e.g. 'grape-spaceship-123'. We will also check the environment * variable `GCLOUD_PROJECT` for your project ID. If your app is running in * an environment which supports {@link * https://cloud.google.com/docs/authentication/production#providing_credentials_to_your_application * Application Default Credentials}, your project ID will be detected * automatically. * @property {string} [keyFilename] Full path to the a .json, .pem, or .p12 key * downloaded from the Google Developers Console. If you provide a path to a * JSON file, the `projectId` option above is not necessary. NOTE: .pem and * .p12 require you to specify the `email` option as well. * @property {string} [email] Account email address. Required when using a .pem * or .p12 keyFilename. * @property {object} [credentials] Credentials object. * @property {string} [credentials.client_email] * @property {string} [credentials.private_key] * @property {boolean} [autoRetry=true] Automatically retry requests if the * response is related to rate limits or certain intermittent server errors. * We will exponentially backoff subsequent requests by default. * @property {number} [maxRetries=3] Maximum number of automatic retries * attempted before returning the error. * @property {Constructor} [promise] Custom promise module to use instead of * native Promises. */ /** * [Cloud DNS](https://cloud.google.com/dns/what-is-cloud-dns) is a * high-performance, resilient, global DNS service that provides a * cost-effective way to make your applications and services available to your * users. This programmable, authoritative DNS service can be used to easily * publish and manage DNS records using the same infrastructure relied upon by * Google. * * @class * * @see [What is Cloud DNS?]{@link https://cloud.google.com/dns/what-is-cloud-dns} * * @param {ClientConfig} [options] Configuration options. * * @example <caption>Import the client library</caption> * const {DNS} = require('@google-cloud/dns'); * * @example <caption>Create a client that uses <a * href="https://cloud.google.com/docs/authentication/production#providing_credentials_to_your_application">Application * Default Credentials (ADC)</a>:</caption> const dns = new DNS(); * * @example <caption>Create a client with <a * href="https://cloud.google.com/docs/authentication/production#obtaining_and_providing_service_account_credentials_manually">explicit * credentials</a>:</caption> const dns = new DNS({ projectId: * 'your-project-id', keyFilename: '/path/to/keyfile.json' * }); * * @example <caption>include:samples/quickstart.js</caption> * region_tag:dns_quickstart * Full quickstart example: */ declare class DNS extends Service { getZonesStream: (query: GetZonesRequest) => Stream; constructor(options?: DNSOptions); createZone(name: string, config: CreateZoneRequest): Promise<CreateZoneResponse>; createZone(name: string, config: CreateZoneRequest, callback: GetZoneCallback): void; getZones(query?: GetZonesRequest): Promise<GetZonesResponse>; getZones(callback: GetZonesCallback): void; getZones(query: GetZonesRequest, callback: GetZonesCallback): void; /** * Get a reference to a Zone. * * @param {string} name The unique name of the zone. * @returns {Zone} * @see Zone * * @throws {error} If a zone name is not provided. * * @example * const {DNS} = require('@google-cloud/dns'); * const dns = new DNS(); * * const zone = dns.zone('my-zone'); */ zone(name: string): Zone; } /** * {@link Zone} class. * * @name DNS.Zone * @see Zone * @type {Constructor} */ export { Zone }; /** * The default export of the `@google-cloud/dns` package is the {@link DNS} * class. * * See {@link DNS} and {@link ClientConfig} for client methods and * configuration options. * * @module {DNS} @google-cloud/dns * @alias nodejs-dns * * @example <caption>Install the client library with <a * href="https://www.npmjs.com/">npm</a>:</caption> npm install --save * @google-cloud/dns * * @example <caption>Import the client library</caption> * const {DNS} = require('@google-cloud/dns'); * * @example <caption>Create a client that uses <a * href="https://cloud.google.com/docs/authentication/production#providing_credentials_to_your_application">Application * Default Credentials (ADC)</a>:</caption> const dns = new DNS(); * * @example <caption>Create a client with <a * href="https://cloud.google.com/docs/authentication/production#obtaining_and_providing_service_account_credentials_manually">explicit * credentials</a>:</caption> const dns = new DNS({ projectId: * 'your-project-id', keyFilename: '/path/to/keyfile.json' * }); * * @example <caption>include:samples/quickstart.js</caption> * region_tag:dns_quickstart * Full quickstart example: */ export { DNS };