cloudflare
Version:
The official TypeScript library for the Cloudflare API
124 lines • 4.89 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Subdomains = exports.BaseSubdomains = void 0;
const tslib_1 = require("../../../internal/tslib.js");
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
const resource_1 = require("../../../core/resource.js");
const DNSAPI = tslib_1.__importStar(require("./dns.js"));
const dns_1 = require("./dns.js");
const pagination_1 = require("../../../core/pagination.js");
const path_1 = require("../../../internal/utils/path.js");
var BaseSubdomains = /* @__PURE__ */ (() => {
class BaseSubdomains extends resource_1.APIResource {
/**
* Creates a new sending subdomain or re-enables sending on an existing subdomain
* that had it disabled. If zone-level Email Sending has not been enabled yet, the
* zone flag is automatically set when the entitlement is present. A leftmost
* wildcard such as `*.example.com` is accepted only for accounts with wildcard
* Email Sending enabled. Wildcard senders share the base domain's DKIM signing
* identity and `cf-bounce.<base>` return path.
*
* @example
* ```ts
* const subdomain =
* await client.emailSending.subdomains.create({
* zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
* name: 'sub.example.com',
* });
* ```
*/
create(params, options) {
const { zone_id, ...body } = params;
return this._client.post((0, path_1.path) `/zones/${zone_id}/email/sending/subdomains`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Lists all sending-enabled subdomains for the zone.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const subdomainListResponse of client.emailSending.subdomains.list(
* { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* )) {
* // ...
* }
* ```
*/
list(params, options) {
const { zone_id } = params;
return this._client.getAPIList((0, path_1.path) `/zones/${zone_id}/email/sending/subdomains`, (pagination_1.SinglePage), options);
}
/**
* Disables sending on a subdomain and removes its DNS records. If routing is still
* active on the subdomain, only sending is disabled.
*
* @example
* ```ts
* const subdomain =
* await client.emailSending.subdomains.delete(
* 'aabbccdd11223344aabbccdd11223344',
* { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
delete(subdomainID, params, options) {
const { zone_id } = params;
return this._client.delete((0, path_1.path) `/zones/${zone_id}/email/sending/subdomains/${subdomainID}`, options);
}
/**
* Updates the activity-log preview preference for a sending subdomain.
*
* @example
* ```ts
* const response = await client.emailSending.subdomains.edit(
* 'aabbccdd11223344aabbccdd11223344',
* { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
edit(subdomainID, params, options) {
const { zone_id, ...body } = params;
return this._client.patch((0, path_1.path) `/zones/${zone_id}/email/sending/subdomains/${subdomainID}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Gets information for a specific sending subdomain.
*
* @example
* ```ts
* const subdomain = await client.emailSending.subdomains.get(
* 'aabbccdd11223344aabbccdd11223344',
* { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' },
* );
* ```
*/
get(subdomainID, params, options) {
const { zone_id } = params;
return this._client.get((0, path_1.path) `/zones/${zone_id}/email/sending/subdomains/${subdomainID}`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseSubdomains._key = Object.freeze([
'emailSending',
'subdomains',
]);
return BaseSubdomains;
})();
exports.BaseSubdomains = BaseSubdomains;
var Subdomains = /* @__PURE__ */ (() => {
class Subdomains extends BaseSubdomains {
constructor() {
super(...arguments);
this.dns = new DNSAPI.DNS(this._client);
}
}
Subdomains.DNS = dns_1.DNS;
Subdomains.BaseDNS = dns_1.BaseDNS;
return Subdomains;
})();
exports.Subdomains = Subdomains;
//# sourceMappingURL=subdomains.js.map