type Bitbucket = {
username: string;
password: string;
};
/**
* Get a repository deploy key
* Returns the deploy key belonging to a specific key.
*/
export async function main(
auth: Bitbucket,
key_id: string,
repo_slug: string,
workspace: string
) {
const url = new URL(
`https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/deploy-keys/${key_id}`
);
const response = await fetch(url, {
method: "GET",
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.json();
}
Submitted by hugo697 375 days ago
type Bitbucket = {
username: string;
password: string;
};
/**
* Get a repository deploy key
* Returns the deploy key belonging to a specific key.
*/
export async function main(
auth: Bitbucket,
key_id: string,
repo_slug: string,
workspace: string
) {
const url = new URL(
`https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/deploy-keys/${key_id}`
);
const response = await fetch(url, {
method: "GET",
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.json();
}
Submitted by hugo697 935 days ago
type Bitbucket = {
username: string;
password: string;
};
/**
* Get a repository deploy key
* Returns the deploy key belonging to a specific key.
Example:
```
$ curl -H "Authorization <auth header>" \
https://api.bitbucket.org/2.0/repositories/mleu/test/deploy-key/1234
Output:
{
"comment": "mleu@C02W454JHTD8",
"last_used": null,
"links": {
"self": {
"href": https://api.bitbucket.org/2.0/repositories/mleu/test/deploy-key/1234"
}
},
"repository": {
"full_name": "mleu/test",
"name": "test",
"type": "repository",
"uuid": "{85d08b4e-571d-44e9-a507-fa476535aa98}"
},
"label": "mykey",
"created_on": "2018-08-15T23:50:59.993890+00:00",
"key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDAK/b1cHHDr/TEV1JGQl+WjCwStKG6Bhrv0rFpEsYlyTBm1fzN0VOJJYn4ZOPCPJwqse6fGbXntEs+BbXiptR+++HycVgl65TMR0b5ul5AgwrVdZdT7qjCOCgaSV74/9xlHDK8oqgGnfA7ZoBBU+qpVyaloSjBdJfLtPY/xqj4yHnXKYzrtn/uFc4Kp9Tb7PUg9Io3qohSTGJGVHnsVblq/rToJG7L5xIo0OxK0SJSQ5vuId93ZuFZrCNMXj8JDHZeSEtjJzpRCBEXHxpOPhAcbm4MzULgkFHhAVgp4JbkrT99/wpvZ7r9AdkTg7HGqL3rlaDrEcWfL7Lu6TnhBdq5",
"id": 1234,
"type": "deploy_key"
}
```
*/
export async function main(
auth: Bitbucket,
key_id: string,
repo_slug: string,
workspace: string
) {
const url = new URL(
`https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_slug}/deploy-keys/${key_id}`
);
const response = await fetch(url, {
method: "GET",
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.json();
}
Submitted by hugo697 935 days ago