@@ -98,6 +98,19 @@ export interface GetRecordsRequest {
98
98
filterByTypes_ ?: { [ index : string ] : boolean } ;
99
99
}
100
100
101
+ /**
102
+ * Query object for listing changes.
103
+ *
104
+ * @typedef {object } GetChangesRequest
105
+ * @property {boolean } [autoPaginate=true] Have pagination handled automatically.
106
+ * @property {number } [maxApiCalls] Maximum number of API calls to make.
107
+ * @property {number } [maxResults] Maximum number of items plus prefixes to
108
+ * return.
109
+ * @property {string } [pageToken] A previously-returned page token
110
+ * representing part of the larger set of results to view.
111
+ * @property {string } [sort] Set to 'asc' for ascending, and 'desc' for
112
+ * descending or omit for no sorting.
113
+ */
101
114
export interface GetChangesRequest {
102
115
autoPaginate ?: boolean ;
103
116
maxApiCalls ?: number ;
@@ -107,6 +120,20 @@ export interface GetChangesRequest {
107
120
sortOrder ?: string ;
108
121
}
109
122
123
+ /**
124
+ * @typedef {array } GetChangesResponse
125
+ * @property {Change[] } 0 Array of {@link Change} instances.
126
+ * @property {object } 1 The full API response.
127
+ */
128
+ export type GetChangesResponse = [ Change [ ] , r . Response ] ;
129
+
130
+ /**
131
+ * @callback GetChangesCallback
132
+ * @param {?Error } err Request error, if any.
133
+ * @param {Change[] } changes Array of {@link Change} instances.
134
+ * @param {object } apiResponse The full API response.
135
+ */
136
+
110
137
export interface GetChangesCallback {
111
138
( err : Error | null , changes ?: Change [ ] | null , nextQuery ?: { } | null ,
112
139
apiResponse ?: r . Response ) : void ;
@@ -678,30 +705,6 @@ class Zone extends ServiceObject {
678
705
} ) ;
679
706
} ) ;
680
707
}
681
- /**
682
- * Query object for listing changes.
683
- *
684
- * @typedef {object } GetChangesRequest
685
- * @property {boolean } [autoPaginate=true] Have pagination handled automatically.
686
- * @property {number } [maxApiCalls] Maximum number of API calls to make.
687
- * @property {number } [maxResults] Maximum number of items plus prefixes to
688
- * return.
689
- * @property {string } [pageToken] A previously-returned page token
690
- * representing part of the larger set of results to view.
691
- * @property {string } [sort] Set to 'asc' for ascending, and 'desc' for
692
- * descending or omit for no sorting.
693
- */
694
- /**
695
- * @typedef {array } GetChangesResponse
696
- * @property {Change[] } 0 Array of {@link Change} instances.
697
- * @property {object } 1 The full API response.
698
- */
699
- /**
700
- * @callback GetChangesCallback
701
- * @param {?Error } err Request error, if any.
702
- * @param {Change[] } changes Array of {@link Change} instances.
703
- * @param {object } apiResponse The full API response.
704
- */
705
708
/**
706
709
* Get the list of changes associated with this zone. A change is an atomic
707
710
* update to a collection of records.
@@ -741,11 +744,12 @@ class Zone extends ServiceObject {
741
744
* const changes = data[0];
742
745
* });
743
746
*/
747
+ getChanges ( query ?: GetChangesRequest ) : Promise < GetChangesResponse > ;
744
748
getChanges ( callback : GetChangesCallback ) : void ;
745
749
getChanges ( query : GetChangesRequest , callback : GetChangesCallback ) : void ;
746
750
getChanges (
747
- queryOrCallback : GetChangesRequest | GetChangesCallback ,
748
- callback ?: GetChangesCallback ) {
751
+ queryOrCallback ? : GetChangesRequest | GetChangesCallback ,
752
+ callback ?: GetChangesCallback ) : void | Promise < GetChangesResponse > {
749
753
let query = queryOrCallback as GetChangesRequest ;
750
754
if ( typeof query === 'function' ) {
751
755
callback = query ;
@@ -926,25 +930,14 @@ class Zone extends ServiceObject {
926
930
callback ! ( null , records , nextQuery , resp ) ;
927
931
} ) ;
928
932
}
929
- /**
930
- * @typedef {array } ZoneImportResponse
931
- * @property {Change } 0 A {@link Change} object.
932
- * @property {object } 1 The full API response.
933
- */
934
- /**
935
- * @callback ZoneImportCallback
936
- * @param {?Error } err Request error, if any.
937
- * @param {?Change } change A {@link Change} object.
938
- * @param {object } apiResponse The full API response.
939
- */
940
933
/**
941
934
* Copy the records from a zone file into this zone.
942
935
*
943
936
* @see [ManagedZones: create API Documentation]{@link https://cloud.google.com/dns/api/v1/managedZones/create}
944
937
*
945
938
* @param {string } localPath The fully qualified path to the zone file.
946
- * @param {ZoneImportCallback } [callback] Callback function.
947
- * @returns {Promise<ZoneImportResponse > }
939
+ * @param {CreateChangeCallback } [callback] Callback function.
940
+ * @returns {Promise<CreateChangeResponse > }
948
941
* @example
949
942
* const {DNS} = require('@google-cloud/dns');
950
943
* const dns = new DNS();
@@ -966,9 +959,11 @@ class Zone extends ServiceObject {
966
959
* const apiResponse = data[1];
967
960
* });
968
961
*/
969
- import ( localPath : string , callback : CreateChangeCallback ) { fs . readFile ( localPath , 'utf-8' , ( err , file ) => {
962
+ import ( localPath : string ) : Promise < CreateChangeResponse > ;
963
+ import ( localPath : string , callback : CreateChangeCallback ) : void ;
964
+ import ( localPath : string , callback ?: CreateChangeCallback ) : void | Promise < CreateChangeResponse > { fs . readFile ( localPath , 'utf-8' , ( err , file ) => {
970
965
if ( err ) {
971
- callback ( err ) ;
966
+ callback ! ( err ) ;
972
967
return ;
973
968
}
974
969
const parsedZonefile = zonefile . parse ( file ) ;
@@ -983,7 +978,7 @@ import(localPath: string, callback: CreateChangeCallback) {fs.readFile(localPath
983
978
recordsToCreate . push ( Record . fromZoneRecord_ ( this , recordType , record ) ) ;
984
979
} ) ;
985
980
} ) ;
986
- this . addRecords ( recordsToCreate , callback ) ;
981
+ this . addRecords ( recordsToCreate , callback ! ) ;
987
982
} ) ; }
988
983
/**
989
984
* A {@link Record} object can be used to construct a record you want to
0 commit comments