2022-09-27 17:23:20 +00:00
|
|
|
import * as plugins from './cloudflare.plugins.js';
|
|
|
|
import * as interfaces from './interfaces/index.js';
|
|
|
|
import { CloudflareAccount } from './cloudflare.classes.account.js';
|
|
|
|
import { CloudflareZone } from './cloudflare.classes.zone.js';
|
2019-07-18 09:51:56 +00:00
|
|
|
|
|
|
|
export class ZoneManager {
|
2019-07-18 12:44:45 +00:00
|
|
|
public cfAccount: CloudflareAccount;
|
2019-07-18 09:51:56 +00:00
|
|
|
public zoneName: string;
|
|
|
|
|
|
|
|
constructor(cfAccountArg: CloudflareAccount) {
|
|
|
|
this.cfAccount = cfAccountArg;
|
|
|
|
}
|
2020-02-10 11:26:13 +00:00
|
|
|
|
2020-02-28 14:24:36 +00:00
|
|
|
public async getZones(zoneName: string) {
|
|
|
|
let requestRoute = `/zones?per_page=50`;
|
|
|
|
// may be optionally filtered by domain name
|
2020-06-10 05:34:47 +00:00
|
|
|
|
2020-02-28 14:24:36 +00:00
|
|
|
if (zoneName) {
|
|
|
|
requestRoute = `${requestRoute}&name=${zoneName}`;
|
|
|
|
}
|
|
|
|
|
|
|
|
const response: any = await this.cfAccount.request('GET', requestRoute);
|
|
|
|
const apiObjects: interfaces.ICflareZone[] = response.result;
|
2020-06-10 05:34:47 +00:00
|
|
|
|
2020-02-28 14:24:36 +00:00
|
|
|
const cloudflareZoneArray = [];
|
|
|
|
for (const apiObject of apiObjects) {
|
|
|
|
cloudflareZoneArray.push(CloudflareZone.createFromApiObject(apiObject));
|
|
|
|
}
|
|
|
|
|
|
|
|
return cloudflareZoneArray;
|
|
|
|
}
|
2019-07-18 09:51:56 +00:00
|
|
|
}
|