type Bitbucket = {
username: string;
password: string;
};
/**
* Update an installed app
* Updates the application installation for the user.
*/
export async function main(auth: Bitbucket) {
const url = new URL(`https://api.bitbucket.org/2.0/addon`);
const response = await fetch(url, {
method: "PUT",
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 375 days ago
type Bitbucket = {
username: string;
password: string;
};
/**
* Update an installed app
* Updates the application installation for the user.
*/
export async function main(auth: Bitbucket) {
const url = new URL(`https://api.bitbucket.org/2.0/addon`);
const response = await fetch(url, {
method: "PUT",
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 935 days ago
type Bitbucket = {
username: string;
password: string;
};
/**
* Update an installed app
* Updates the application installation for the user.
This endpoint is intended to be used by Bitbucket Connect apps
and only supports JWT authentication -- that is how Bitbucket
identifies the particular installation of the app. Developers
with applications registered in the "Develop Apps" section
of Bitbucket need not use this endpoint as updates for those
applications can be sent out via the UI of that section.
Passing an empty body will update the installation using the
existing descriptor URL.
```
$ curl -X PUT https://api.bitbucket.org/2.0/addon \
-H "Authorization: JWT <JWT Token>" \
--header "Content-Type: application/json" \
--data '{}'
```
The new `descriptor` for the installation can be also provided
in the body directly.
```
$ curl -X PUT https://api.bitbucket.org/2.0/addon \
-H "Authorization: JWT <JWT Token>" \
--header "Content-Type: application/json" \
--data '{"descriptor": $NEW_DESCRIPTOR}'
```
In both these modes the URL of the descriptor cannot be changed. To
change the descriptor location and upgrade an installation
the request must be made exclusively with a `descriptor_url`.
```
$ curl -X PUT https://api.bitbucket.org/2.0/addon \
-H "Authorization: JWT <JWT Token>" \
--header "Content-Type: application/json" \
--data '{"descriptor_url": $NEW_URL}'
```
The `descriptor_url` must exactly match the marketplace registration
that Atlassian has for the application. Contact your Atlassian
developer advocate to update this registration. Once the registration
has been updated you may call this resource for each installation.
Note that the scopes of the application cannot be increased
in the new descriptor nor reduced to none.
*/
export async function main(auth: Bitbucket) {
const url = new URL(`https://api.bitbucket.org/2.0/addon`);
const response = await fetch(url, {
method: "PUT",
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 935 days ago