type Jira = {
username: string;
password: string;
domain: string;
};
/**
* Delete user property
* Deletes a property from a user.
Note: This operation does not access the [user properties](https://confluence.atlassian.com/x/8YxjL) created and maintained in Jira.
**[Permissions](#permissions) required:**
* *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg), to delete a property from any user.
* Access to Jira, to delete a property from the calling user's record.
*/
export async function main(
auth: Jira,
propertyKey: string,
accountId: string | undefined,
userKey: string | undefined,
username: string | undefined
) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/2/user/properties/${propertyKey}`
);
for (const [k, v] of [
["accountId", accountId],
["userKey", userKey],
["username", username],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "DELETE",
headers: {
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 396 days ago
type Jira = {
username: string;
password: string;
domain: string;
};
/**
* Delete user property
* Deletes a property from a user.
Note: This operation does not access the [user properties](https://confluence.atlassian.com/x/8YxjL) created and maintained in Jira.
**[Permissions](#permissions) required:**
* *Administer Jira* [global permission](https://confluence.atlassian.com/x/x4dKLg), to delete a property from any user.
* Access to Jira, to delete a property from the calling user's record.
*/
export async function main(
auth: Jira,
propertyKey: string,
accountId: string | undefined,
userKey: string | undefined,
username: string | undefined
) {
const url = new URL(
`https://${auth.domain}.atlassian.net/rest/api/2/user/properties/${propertyKey}`
);
for (const [k, v] of [
["accountId", accountId],
["userKey", userKey],
["username", username],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "DELETE",
headers: {
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 948 days ago