All Downloads are FREE. Search and download functionalities are using the official Maven repository.

src.app.core.services.backups.service.ts Maven / Gradle / Ivy

The newest version!
/*
 * SPDX-FileCopyrightText: 2017-2024 Enedis
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 */

import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';

import { environment } from '@env/environment';
import { Backup } from '@core/model/backups.model';

@Injectable({
    providedIn: 'root'
})
export class BackupsService {

    private url = '/api/v1/backups';

    constructor(private http: HttpClient) {
    }

    list(): Observable> {
        return this.http.get>(environment.backend + this.url);
    }

    get(id: string): Observable {
        return this.http.get(
            environment.backend + this.url + `/${id}`);
    }

    delete(id: string): Observable {
        return this.http.delete(environment.backend + this.url + `/${id}`);
    }

    download(id: string): Observable {
        const options: any = {
            responseType: 'arraybuffer'
        };
        return this.http.get(environment.backend + this.url + `/${id}` + '/download', options);
    }

    save(backup: Backup): Observable {
        return this.http.post(environment.backend + this.url, backup, {responseType: 'text'});
    }

    getBackupables(): Observable {
        return this.http.get(environment.backend + this.url + '/backupables');
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy