# All files / src/app/shared/api osd.service.ts

100% Statements 38/38
71.43% Branches 5/7
100% Functions 14/14
100% Lines 35/35

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    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
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    11712x
    12x

    12x

    12x

    12x
    47x

    47x

    47x

    12x
    1x

    12x
    1x

    12x
    2x

    12x
    2x

    12x
    3x

    12x
    1x

    12x
    1x

    12x
    1x

    12x
    1x

    12x
    1x

    12x
    1x

    12x
    1x

    12x

    1x

    12x
     import { HttpClient } from '@angular/common/http';
    import { Injectable } from '@angular/core';

    import { I18n } from '@ngx-translate/i18n-polyfill';

    import { ApiModule } from './api.module';

    @Injectable({
      providedIn: ApiModule
    })
    export class OsdService {
      private path = 'api/osd';

      osdRecvSpeedModalPriorities = {
        KNOWN_PRIORITIES: [
          {
            name: null,
            text: this.i18n('-- Select the priority --'),
            values: {
              osd_max_backfills: null,
              osd_recovery_max_active: null,
              osd_recovery_max_single_start: null,
              osd_recovery_sleep: null
            }
          },
          {
            name: 'low',
            text: this.i18n('Low'),
            values: {
              osd_max_backfills: 1,
              osd_recovery_max_active: 1,
              osd_recovery_max_single_start: 1,
              osd_recovery_sleep: 0.5
            }
          },
          {
            name: 'default',
            text: this.i18n('Default'),
            values: {
              osd_max_backfills: 1,
              osd_recovery_max_active: 3,
              osd_recovery_max_single_start: 1,
              osd_recovery_sleep: 0
            }
          },
          {
            name: 'high',
            text: this.i18n('High'),
            values: {
              osd_max_backfills: 4,
              osd_recovery_max_active: 4,
              osd_recovery_max_single_start: 4,
              osd_recovery_sleep: 0
            }
          }
        ]
      };

      constructor(private http: HttpClient, private i18n: I18n) {}

      getList() {
        return this.http.get(`${this.path}`);
      }

      getDetails(id: number) {
        return this.http.get(`${this.path}/${id}`);
      }

      scrub(id, deep) {
        return this.http.post(`${this.path}/${id}/scrub?deep=${deep}`, null);
      }

      getFlags() {
        return this.http.get(`${this.path}/flags`);
      }

      updateFlags(flags: string[]) {
        return this.http.put(`${this.path}/flags`, { flags: flags });
      }

      markOut(id: number) {
        return this.http.post(`${this.path}/${id}/mark_out`, null);
      }

      markIn(id: number) {
        return this.http.post(`${this.path}/${id}/mark_in`, null);
      }

      markDown(id: number) {
        return this.http.post(`${this.path}/${id}/mark_down`, null);
      }

      reweight(id: number, weight: number) {
        return this.http.post(`${this.path}/${id}/reweight`, { weight: weight });
      }

      markLost(id: number) {
        return this.http.post(`${this.path}/${id}/mark_lost`, null);
      }

      purge(id: number) {
        return this.http.post(`${this.path}/${id}/purge`, null);
      }

      destroy(id: number) {
        return this.http.post(`${this.path}/${id}/destroy`, null);
      }

      safeToDestroy(id: number) {
        interface SafeToDestroyResponse {
          'safe-to-destroy': boolean;
          message?: string;
        }
        return this.http.get<SafeToDestroyResponse>(`${this.path}/${id}/safe_to_destroy`);
      }
    }