UNPKG

@google-cloud/dns

Version:
108 lines (107 loc) 3.4 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 { Change, CreateChangeCallback } from './change'; import { Zone } from './zone'; import { Metadata } from '@google-cloud/common'; export interface RecordObject { rrdatas?: string[]; rrdata?: {}; data?: string | string[]; type?: string; } export interface RecordMetadata { name: string; data?: string | string[]; ttl: number; type?: string; rrdatas?: string[]; signatureRrdatas?: string[]; } /** * @typedef {array} DeleteRecordResponse * @property {Change} 0 A {@link Change} object. * @property {object} 1 The full API response. */ export type DeleteRecordResponse = [Change, Metadata]; /** * @callback DeleteRecordCallback * @param {?Error} err Request error, if any. * @param {?Change} change A {@link Change} object. * @param {object} apiResponse The full API response. */ export interface DeleteRecordCallback { (err: Error | null, change?: Change, apiResponse?: Metadata): void; } /** * Create a Resource Record object. * * @class * * @param {string} type The record type, e.g. `A`, `AAAA`, `MX`. * @param {object} metadata The metadata of this record. * @param {string} metadata.name The name of the record, e.g. * `www.example.com.`. * @param {string[]} metadata.data Defined in * [RFC 1035, section 5](https://goo.gl/9EiM0e) and * [RFC 1034, section 3.6.1](https://goo.gl/Hwhsu9). * @param {number} metadata.ttl Seconds that the resource is cached by * resolvers. * * @example * const {DNS} = require('@google-cloud/dns'); * const dns = new DNS(); * const zone = dns.zone('my-awesome-zone'); * * const record = zone.record('a', { * name: 'example.com.', * ttl: 86400, * data: '1.2.3.4' * }); */ export declare class Record implements RecordObject { zone_: Zone; type: string; metadata: RecordMetadata; rrdatas?: string[]; data?: string[]; constructor(zone: Zone, type: string, metadata: RecordMetadata); delete(): Promise<DeleteRecordResponse>; delete(callback: CreateChangeCallback): void; /** * Serialize the record instance to the format the API expects. * * @returns {object} */ toJSON(): RecordObject; /** * Convert the record to a string, formatted for a zone file. * * @returns {string} */ toString(): string; /** * Create a Record instance from a resource record set in a zone file. * * @private * * @param {Zone} zone The zone. * @param {string} type The record type, e.g. `A`, `AAAA`, `MX`. * @param {object} bindData Metadata parsed from dns-zonefile. Properties vary * based on the type of record. * @returns {Record} */ static fromZoneRecord_(zone: Zone, type: string, bindData: RecordMetadata): Record; }