From 92a1fa3212f7423a0b2840e753f6bc47f1bda5ec Mon Sep 17 00:00:00 2001 From: Pere Diaz Bou Date: Mon, 4 Jul 2022 12:56:03 +0200 Subject: [PATCH] mgr/dashboard: update rbd list api version to 2 Signed-off-by: Pere Diaz Bou (cherry picked from commit 5386dd1cb3195e7bc2dd80dafa1f0d29e8e0eb9e) (cherry picked from commit 076a0d7f86783779d2903d5ce59445e4bd88f59f) Resolves: rhbz#2125432 --- src/pybind/mgr/dashboard/controllers/rbd.py | 2 ++ .../frontend/src/app/shared/api/rbd.service.ts | 13 ++++++++++--- src/pybind/mgr/dashboard/openapi.yaml | 7 ++++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/pybind/mgr/dashboard/controllers/rbd.py b/src/pybind/mgr/dashboard/controllers/rbd.py index fea7733821148..49faf477be666 100644 --- a/src/pybind/mgr/dashboard/controllers/rbd.py +++ b/src/pybind/mgr/dashboard/controllers/rbd.py @@ -23,6 +23,7 @@ from ..tools import ViewCache, str_to_bool from . import APIDoc, APIRouter, BaseController, CreatePermission, \ DeletePermission, Endpoint, EndpointDoc, ReadPermission, RESTController, \ Task, UIRouter, UpdatePermission, allow_empty_body +from ._version import APIVersion logger = logging.getLogger(__name__) @@ -107,6 +108,7 @@ class Rbd(RESTController): 'offset': (int, 'offset'), }, responses={200: RBD_SCHEMA}) + @RESTController.MethodMap(version=APIVersion(2, 0)) # type: ignore def list(self, pool_name=None, offset: int = 0, limit: int = 5, search: str = ''): return self._rbd_list(pool_name, offset=offset, limit=limit, search=search) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd.service.ts index 6525f3926b1aa..555f0db0f4f80 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd.service.ts @@ -4,6 +4,7 @@ import { Injectable } from '@angular/core'; import _ from 'lodash'; import { map } from 'rxjs/operators'; +import { ApiClient } from '~/app/shared/api/api-client'; import { cdEncode, cdEncodeNot } from '../decorators/cd-encode'; import { ImageSpec } from '../models/image-spec'; import { RbdConfigurationService } from '../services/rbd-configuration.service'; @@ -13,8 +14,10 @@ import { RbdPool } from './rbd.model'; @Injectable({ providedIn: 'root' }) -export class RbdService { - constructor(private http: HttpClient, private rbdConfigurationService: RbdConfigurationService) {} +export class RbdService extends ApiClient { + constructor(private http: HttpClient, private rbdConfigurationService: RbdConfigurationService) { + super(); + } isRBDPool(pool: any) { return _.indexOf(pool.application_metadata, 'rbd') !== -1 && !pool.pool_name.includes('/'); @@ -42,7 +45,11 @@ export class RbdService { list(params: any) { return this.http - .get('api/block/image', { params: params, observe: 'response' }) + .get('api/block/image', { + params: params, + headers: { Accept: this.getVersionHeaderValue(2, 0) }, + observe: 'response' + }) .pipe( map((response: any) => { return response['body'].map((pool: any) => { diff --git a/src/pybind/mgr/dashboard/openapi.yaml b/src/pybind/mgr/dashboard/openapi.yaml index 3249eaf5ec93a..43f93be3bd341 100644 --- a/src/pybind/mgr/dashboard/openapi.yaml +++ b/src/pybind/mgr/dashboard/openapi.yaml @@ -166,10 +166,15 @@ paths: name: limit schema: type: integer + - default: '' + in: query + name: search + schema: + type: string responses: '200': content: - application/vnd.ceph.api.v1.0+json: + application/vnd.ceph.api.v2.0+json: schema: items: properties: -- 2.39.5