diff options
Diffstat (limited to 'src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-site.service.ts')
-rw-r--r-- | src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-site.service.ts | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-site.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-site.service.ts new file mode 100644 index 000000000..49589c83f --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-site.service.ts @@ -0,0 +1,38 @@ +import { HttpClient, HttpParams } from '@angular/common/http'; +import { Injectable } from '@angular/core'; + +import { Observable } from 'rxjs'; +import { map, mergeMap } from 'rxjs/operators'; + +import { RgwDaemon } from '~/app/ceph/rgw/models/rgw-daemon'; +import { RgwDaemonService } from '~/app/shared/api/rgw-daemon.service'; +import { cdEncode } from '~/app/shared/decorators/cd-encode'; + +@cdEncode +@Injectable({ + providedIn: 'root' +}) +export class RgwSiteService { + private url = 'api/rgw/site'; + + constructor(private http: HttpClient, private rgwDaemonService: RgwDaemonService) {} + + get(query?: string) { + return this.rgwDaemonService.request((params: HttpParams) => { + if (query) { + params = params.append('query', query); + } + return this.http.get(this.url, { params: params }); + }); + } + + isDefaultRealm(): Observable<boolean> { + return this.get('default-realm').pipe( + mergeMap((defaultRealm: string) => + this.rgwDaemonService.selectedDaemon$.pipe( + map((selectedDaemon: RgwDaemon) => selectedDaemon.realm_name === defaultRealm) + ) + ) + ); + } +} |