File size: 814 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
import wpcom from 'calypso/lib/wp';
export interface SftpUser {
username: string;
password: string;
}
export async function fetchSftpUsers( siteId: number ): Promise< SftpUser[] > {
const { users } = await wpcom.req.get( {
path: `/sites/${ siteId }/hosting/ssh-users`,
apiNamespace: 'wpcom/v2',
} );
return users.map( ( username: string ) => ( {
username,
} ) );
}
export async function createSftpUser( siteId: number ): Promise< SftpUser > {
return wpcom.req.post( {
path: `/sites/${ siteId }/hosting/ssh-user`,
apiNamespace: 'wpcom/v2',
} );
}
export async function resetSftpPassword(
siteId: number,
sshUsername: string
): Promise< SftpUser > {
return wpcom.req.post( {
path: `/sites/${ siteId }/hosting/ssh-user/${ sshUsername }/reset-password`,
apiNamespace: 'wpcom/v2',
} );
}
|