github.com/argoproj/argo-cd@v1.8.7/ui/src/app/shared/services/repo-service.ts (about) 1 import * as models from '../models'; 2 import requests from './requests'; 3 4 export class RepositoriesService { 5 public list(): Promise<models.Repository[]> { 6 return requests 7 .get(`/repositories`) 8 .then(res => res.body as models.RepositoryList) 9 .then(list => list.items || []); 10 } 11 12 public listNoCache(): Promise<models.Repository[]> { 13 return requests 14 .get(`/repositories?forceRefresh=true`) 15 .then(res => res.body as models.RepositoryList) 16 .then(list => list.items || []); 17 } 18 19 public createHTTPS({ 20 type, 21 name, 22 url, 23 username, 24 password, 25 tlsClientCertData, 26 tlsClientCertKey, 27 insecure, 28 enableLfs 29 }: { 30 type: string; 31 name: string; 32 url: string; 33 username: string; 34 password: string; 35 tlsClientCertData: string; 36 tlsClientCertKey: string; 37 insecure: boolean; 38 enableLfs: boolean; 39 }): Promise<models.Repository> { 40 return requests 41 .post('/repositories') 42 .send({type, name, repo: url, username, password, tlsClientCertData, tlsClientCertKey, insecure, enableLfs}) 43 .then(res => res.body as models.Repository); 44 } 45 46 public createSSH({ 47 type, 48 name, 49 url, 50 sshPrivateKey, 51 insecure, 52 enableLfs 53 }: { 54 type: string; 55 name: string; 56 url: string; 57 sshPrivateKey: string; 58 insecure: boolean; 59 enableLfs: boolean; 60 }): Promise<models.Repository> { 61 return requests 62 .post('/repositories') 63 .send({type, name, repo: url, sshPrivateKey, insecure, enableLfs}) 64 .then(res => res.body as models.Repository); 65 } 66 67 public delete(url: string): Promise<models.Repository> { 68 return requests 69 .delete(`/repositories/${encodeURIComponent(url)}`) 70 .send() 71 .then(res => res.body as models.Repository); 72 } 73 74 public async revisions(repo: string): Promise<models.RefsInfo> { 75 return requests.get(`/repositories/${encodeURIComponent(repo)}/refs`).then(res => res.body as models.RefsInfo); 76 } 77 78 public apps(repo: string, revision: string): Promise<models.AppInfo[]> { 79 return requests 80 .get(`/repositories/${encodeURIComponent(repo)}/apps`) 81 .query({revision}) 82 .then(res => (res.body.items as models.AppInfo[]) || []); 83 } 84 85 public charts(repo: string): Promise<models.HelmChart[]> { 86 return requests.get(`/repositories/${encodeURIComponent(repo)}/helmcharts`).then(res => (res.body.items as models.HelmChart[]) || []); 87 } 88 89 public appDetails(source: models.ApplicationSource): Promise<models.RepoAppDetails> { 90 return requests 91 .post(`/repositories/${encodeURIComponent(source.repoURL)}/appdetails`) 92 .send({source}) 93 .then(res => res.body as models.RepoAppDetails); 94 } 95 }