1/**
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16import { HttpClient } from '@angular/common/http';
17import { Injectable } from '@angular/core';
18
19import { catchError } from 'rxjs/operators';
20import { Observable } from 'rxjs';
21
22import { environment } from '../../../environments/environment';
23import { HostWrapper } from '../../model/host_wrapper';
24import { ServiceBase } from '../../shared/servicebase';
25
26
27@Injectable()
28export class LabService extends ServiceBase {
29  // url: string;
30  constructor(public httpClient: HttpClient) {
31    super(httpClient);
32    this.url = environment['baseURL'] + '/lab/v1/';
33  }
34
35  getLabs(size: number,
36          offset: number,
37          filterInfo: string,
38          sort: string,
39          direction: string): Observable<HostWrapper> {
40    const url = this.url + 'get';
41    return this.httpClient.post<HostWrapper>(url,  {size: size, offset: offset, filter: filterInfo, sort: sort, direction: direction})
42      .pipe(catchError(this.handleError));
43  }
44}
45