type Bitbucket = {
username: string;
password: string;
};
/**
* Update a SSH key
* Updates a specific SSH public key on a user's account
Note: Only the 'comment' field can be updated using this API. To modify the key or comment values, you must delete and add the key again.
Example:
```
$ curl -X PUT -H "Content-Type: application/json" -d '{"label": "Work key"}' https://api.bitbucket.org/2.0/users/{ed08f5e1-605b-4f4a-aee4-6c97628a673e}/ssh-keys/{b15b6026-9c02-4626-b4ad-b905f99f763a}
```
*/
export async function main(
auth: Bitbucket,
key_id: string,
selected_user: string,
body: ({ type: string; [k: string]: unknown } & {
uuid?: string;
key?: string;
comment?: string;
label?: string;
created_on?: string;
last_used?: string;
links?: { self?: { href?: string; name?: string } };
[k: string]: unknown;
}) & {
owner?: { type: string; [k: string]: unknown } & {
links?: {
avatar?: { href?: string; name?: string };
[k: string]: unknown;
};
created_on?: string;
display_name?: string;
username?: string;
uuid?: string;
[k: string]: unknown;
};
[k: string]: unknown;
}
) {
const url = new URL(
`https://api.bitbucket.org/2.0/users/${selected_user}/ssh-keys/${key_id}`
);
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.json();
}
Submitted by hugo697 2 days ago
type Bitbucket = {
username: string;
password: string;
};
/**
* Update a SSH key
* Updates a specific SSH public key on a user's account
Note: Only the 'comment' field can be updated using this API. To modify the key or comment values, you must delete and add the key again.
Example:
```
$ curl -X PUT -H "Content-Type: application/json" -d '{"label": "Work key"}' https://api.bitbucket.org/2.0/users/{ed08f5e1-605b-4f4a-aee4-6c97628a673e}/ssh-keys/{b15b6026-9c02-4626-b4ad-b905f99f763a}
```
*/
export async function main(
auth: Bitbucket,
key_id: string,
selected_user: string,
body: ({ type: string; [k: string]: unknown } & {
uuid?: string;
key?: string;
comment?: string;
label?: string;
created_on?: string;
last_used?: string;
links?: { self?: { href?: string; name?: string } };
[k: string]: unknown;
}) & {
owner?: { type: string; [k: string]: unknown } & {
links?: {
avatar?: { href?: string; name?: string };
[k: string]: unknown;
};
created_on?: string;
display_name?: string;
username?: string;
uuid?: string;
[k: string]: unknown;
};
[k: string]: unknown;
}
) {
const url = new URL(
`https://api.bitbucket.org/2.0/users/${selected_user}/ssh-keys/${key_id}`
);
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.json();
}
Submitted by hugo697 557 days ago
type Bitbucket = {
username: string;
password: string;
};
/**
* Update a SSH key
* Updates a specific SSH public key on a user's account
Note: Only the 'comment' field can be updated using this API.
*/
export async function main(
auth: Bitbucket,
key_id: string,
selected_user: string,
body: ({ type: string; [k: string]: unknown } & {
uuid?: string;
key?: string;
comment?: string;
label?: string;
created_on?: string;
last_used?: string;
links?: { self?: { href?: string; name?: string } };
[k: string]: unknown;
}) & {
owner?: { type: string; [k: string]: unknown } & {
links?: {
avatar?: { href?: string; name?: string };
[k: string]: unknown;
};
created_on?: string;
display_name?: string;
username?: string;
uuid?: string;
[k: string]: unknown;
};
[k: string]: unknown;
}
) {
const url = new URL(
`https://api.bitbucket.org/2.0/users/${selected_user}/ssh-keys/${key_id}`
);
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.json();
}
Submitted by hugo697 562 days ago
type Bitbucket = {
username: string;
password: string;
};
/**
* Update a SSH key
* Updates a specific SSH public key on a user's account
Note: Only the 'comment' field can be updated using this API. To modify the key or comment values, you must delete and add the key again.
Example:
```
$ curl -X PUT -H "Content-Type: application/json" -d '{"label": "Work key"}' https://api.bitbucket.org/2.0/users/{ed08f5e1-605b-4f4a-aee4-6c97628a673e}/ssh-keys/{b15b6026-9c02-4626-b4ad-b905f99f763a}
{
"comment": "",
"created_on": "2018-03-14T13:17:05.196003+00:00",
"key": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKqP3Cr632C2dNhhgKVcon4ldUSAeKiku2yP9O9/bDtY",
"label": "Work key",
"last_used": "2018-03-20T13:18:05.196003+00:00",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/users/{ed08f5e1-605b-4f4a-aee4-6c97628a673e}/ssh-keys/b15b6026-9c02-4626-b4ad-b905f99f763a"
}
},
"owner": {
"display_name": "Mark Adams",
"links": {
"avatar": {
"href": "https://bitbucket.org/account/markadams-atl/avatar/32/"
},
"html": {
"href": "https://bitbucket.org/markadams-atl/"
},
"self": {
"href": "https://api.bitbucket.org/2.0/users/{ed08f5e1-605b-4f4a-aee4-6c97628a673e}"
}
},
"type": "user",
"username": "markadams-atl",
"nickname": "markadams-atl",
"uuid": "{d7dd0e2d-3994-4a50-a9ee-d260b6cefdab}"
},
"type": "ssh_key",
"uuid": "{b15b6026-9c02-4626-b4ad-b905f99f763a}"
}
```
*/
export async function main(
auth: Bitbucket,
key_id: string,
selected_user: string,
body: ({ type: string; [k: string]: unknown } & {
uuid?: string;
key?: string;
comment?: string;
label?: string;
created_on?: string;
last_used?: string;
links?: { self?: { href?: string; name?: string } };
[k: string]: unknown;
}) & {
owner?: { type: string; [k: string]: unknown } & {
links?: {
avatar?: { href?: string; name?: string };
[k: string]: unknown;
};
created_on?: string;
display_name?: string;
username?: string;
uuid?: string;
[k: string]: unknown;
};
[k: string]: unknown;
}
) {
const url = new URL(
`https://api.bitbucket.org/2.0/users/${selected_user}/ssh-keys/${key_id}`
);
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.json();
}
Submitted by hugo697 563 days ago