type Bitbucket = {
username: string;
password: string;
};
/**
* Update a user application property
* Update an application property value stored against a user.
*/
export async function main(
auth: Bitbucket,
selected_user: string,
app_key: string,
property_name: string,
body: { _attributes?: ("public" | "read_only")[]; [k: string]: unknown }
) {
const url = new URL(
`https://api.bitbucket.org/2.0/users/${selected_user}/properties/${app_key}/${property_name}`
);
const response = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 352 days ago
type Bitbucket = {
username: string;
password: string;
};
/**
* Update a user application property
* Update an [application property](/cloud/bitbucket/application-properties/) value stored against a user.
*/
export async function main(
auth: Bitbucket,
selected_user: string,
app_key: string,
property_name: string,
body: { _attributes?: ("public" | "read_only")[]; [k: string]: unknown }
) {
const url = new URL(
`https://api.bitbucket.org/2.0/users/${selected_user}/properties/${app_key}/${property_name}`
);
const response = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 407 days ago