github.com/argoproj/argo-cd/v2@v2.10.9/ui/src/app/shared/services/accounts-service.ts (about) 1 import {Account} from '../models'; 2 import requests from './requests'; 3 4 export class AccountsService { 5 public list(): Promise<Account[]> { 6 return requests.get('/account').then(res => (res.body.items || []) as Account[]); 7 } 8 9 public get(name: string): Promise<Account> { 10 return requests.get(`/account/${name}`).then(res => res.body as Account); 11 } 12 13 public changePassword(name: string, currentPassword: string, newPassword: string): Promise<boolean> { 14 return requests 15 .put('/account/password') 16 .send({currentPassword, name, newPassword}) 17 .then(res => res.status === 200); 18 } 19 20 public createToken(name: string, tokenId: string, expiresIn: number): Promise<string> { 21 return requests 22 .post(`/account/${name}/token`) 23 .send({expiresIn, id: tokenId}) 24 .then(res => res.body.token as string); 25 } 26 27 public deleteToken(name: string, id: string): Promise<any> { 28 return requests.delete(`/account/${name}/token/${id}`); 29 } 30 31 public canI(resource: string, action: string, subresource: string): Promise<boolean> { 32 return requests.get(`/account/can-i/${resource}/${action}/${subresource}`).then(res => res.body.value === 'yes'); 33 } 34 }