//native
type Segment = {
token: string;
baseUrl: string;
};
/**
* Create Cloud Source Regulation
* Creates a Source-scoped regulation.
Please Note: Suppression rules at the Workspace level take precedence over those at the Source level. If a user has been suppressed at the Workspace level, any attempt to un-suppress at the Source level is not supported and the processing of the request will fail in Segment
Config API omitted fields:
- `attributes`,
- `userAgent`
*/
export async function main(
auth: Segment,
sourceId: string,
body: {
regulationType:
| "DELETE_INTERNAL"
| "DELETE_ONLY"
| "SUPPRESS_ONLY"
| "SUPPRESS_WITH_DELETE"
| "SUPPRESS_WITH_DELETE_INTERNAL"
| "UNSUPPRESS";
subjectType: "OBJECT_ID";
subjectIds: string[];
collection: string;
},
) {
const url = new URL(
`${auth.baseUrl}/regulations/cloudsources/${sourceId}`,
);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago