github.com/argoproj/argo-cd@v1.8.7/ui/src/app/shared/services/clusters-service.ts (about)

     1  import * as models from '../models';
     2  import requests from './requests';
     3  
     4  export class ClustersService {
     5      public list(): Promise<models.Cluster[]> {
     6          return requests
     7              .get('/clusters')
     8              .then(res => res.body as models.ClusterList)
     9              .then(list => list.items || []);
    10      }
    11  
    12      public get(url: string, name: string): Promise<models.Cluster> {
    13          let queryName = '';
    14          if (url === undefined) {
    15              url = '';
    16              queryName = `?name=${name}`;
    17          }
    18          const requestUrl = `/clusters/${encodeURIComponent(url)}` + queryName;
    19          return requests.get(requestUrl).then(res => res.body as models.Cluster);
    20      }
    21  
    22      public update(cluster: models.Cluster, ...paths: string[]): Promise<models.Cluster> {
    23          return requests
    24              .put(`/clusters/${encodeURIComponent(cluster.server)}`)
    25              .query({updatedFields: paths})
    26              .send(cluster)
    27              .then(res => res.body as models.Cluster);
    28      }
    29  
    30      public invalidateCache(url: string): Promise<models.Cluster> {
    31          return requests
    32              .post(`/clusters/${encodeURIComponent(url)}/invalidate-cache`)
    33              .send({})
    34              .then(res => res.body as models.Cluster);
    35      }
    36  
    37      public delete(server: string): Promise<models.Cluster> {
    38          return requests
    39              .delete(`/clusters/${encodeURIComponent(server)}`)
    40              .send()
    41              .then(res => res.body as models.Cluster);
    42      }
    43  }