cloudflare
Version:
The official TypeScript library for the Cloudflare API
133 lines • 5.24 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../core/resource.mjs";
import { CursorPagination } from "../../core/pagination.mjs";
import { path } from "../../internal/utils/path.mjs";
export var BaseSuppressions = /* @__PURE__ */ (() => {
class BaseSuppressions extends APIResource {
/**
* Creates a suppression for every sending domain of the account (default) or for
* one sending domain (`scope.type = sending_domain`). Creating an existing active
* suppression returns its identifier. If a mutable legacy zone-linked account row
* already exists, it is promoted without changing its identifier.
*
* @example
* ```ts
* const suppression =
* await client.emailSending.suppressions.create({
* account_id: '12345678',
* email: 'user@example.com',
* });
* ```
*/
create(params, options) {
const { account_id, ...body } = params;
return this._client.post(path `/accounts/${account_id}/email/sending/suppressions`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Lists every active Email Sending suppression owned by the account:
* sending-domain suppressions first, then account-wide suppressions (including
* legacy rows with internal zone memberships). Each group is newest first.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const suppressionListResponse of client.emailSending.suppressions.list(
* { account_id: '12345678' },
* )) {
* // ...
* }
* ```
*/
list(params, options) {
const { account_id, ...query } = params;
return this._client.getAPIList(path `/accounts/${account_id}/email/sending/suppressions`, (CursorPagination), { query, ...options });
}
/**
* Deletes the suppression, its note, and every legacy internal zone membership,
* allowing future delivery attempts to the address.
*
* @example
* ```ts
* const suppression =
* await client.emailSending.suppressions.delete(
* '396a5436-d4b0-42a6-b3fc-48e8fa522321',
* { account_id: '12345678' },
* );
* ```
*/
delete(suppressionID, params, options) {
const { account_id } = params;
return this._client.delete(path `/accounts/${account_id}/email/sending/suppressions/${suppressionID}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Updates expiry or advisory note fields without changing legacy internal zone
* memberships. Scope cannot be changed.
*
* @example
* ```ts
* const response =
* await client.emailSending.suppressions.edit(
* '396a5436-d4b0-42a6-b3fc-48e8fa522321',
* { account_id: '12345678' },
* );
* ```
*/
edit(suppressionID, params, options) {
const { account_id, ...body } = params;
return this._client.patch(path `/accounts/${account_id}/email/sending/suppressions/${suppressionID}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Gets an Email Sending suppression owned by the account.
*
* @example
* ```ts
* const suppression =
* await client.emailSending.suppressions.get(
* '396a5436-d4b0-42a6-b3fc-48e8fa522321',
* { account_id: '12345678' },
* );
* ```
*/
get(suppressionID, params, options) {
const { account_id } = params;
return this._client.get(path `/accounts/${account_id}/email/sending/suppressions/${suppressionID}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Imports up to 1,000 Email Sending suppressions in one request. Each item applies
* to every sending domain of the account (default) or to one sending domain.
*
* @example
* ```ts
* const response =
* await client.emailSending.suppressions.import({
* account_id: '12345678',
* items: [
* { email: 'user@example.com' },
* { email: 'other@example.com' },
* ],
* });
* ```
*/
import(params, options) {
const { account_id, ...body } = params;
return this._client.post(path `/accounts/${account_id}/email/sending/suppressions/bulk`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
}
BaseSuppressions._key = Object.freeze([
'emailSending',
'suppressions',
]);
return BaseSuppressions;
})();
export class Suppressions extends BaseSuppressions {
}
//# sourceMappingURL=suppressions.mjs.map