changed route on the serviceaccounts endpoint (#43989)

* changed route on the serviceaccounts endpoint

* refactor: change to base url variable

* tests fixed
This commit is contained in:
Eric Leijonmarck 2022-01-13 14:15:43 +01:00 committed by GitHub
parent 14b92b75c7
commit ccd9e46dda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 5 deletions

View File

@ -43,7 +43,7 @@ func (api *ServiceAccountsAPI) RegisterAPIEndpoints(
return
}
auth := acmiddleware.Middleware(api.accesscontrol)
api.RouterRegister.Group("/api/serviceaccounts", func(serviceAccountsRoute routing.RouteRegister) {
api.RouterRegister.Group("/api/org/serviceaccounts", func(serviceAccountsRoute routing.RouteRegister) {
serviceAccountsRoute.Get("/", auth(middleware.ReqOrgAdmin, accesscontrol.EvalPermission(serviceaccounts.ActionRead, serviceaccounts.ScopeAll)), routing.Wrap(api.ListServiceAccounts))
serviceAccountsRoute.Delete("/:serviceAccountId", auth(middleware.ReqOrgAdmin, accesscontrol.EvalPermission(serviceaccounts.ActionDelete, serviceaccounts.ScopeID)), routing.Wrap(api.DeleteServiceAccount))
serviceAccountsRoute.Get("/upgrade", auth(middleware.ReqOrgAdmin, accesscontrol.EvalPermission(serviceaccounts.ActionCreate, serviceaccounts.ScopeID)), routing.Wrap(api.UpgradeServiceAccounts))

View File

@ -23,7 +23,7 @@ import (
)
var (
serviceaccountIDPath = "/api/serviceaccounts/%s"
serviceaccountIDPath = "/api/org/serviceaccounts/%s"
)
// test the accesscontrol endpoints

View File

@ -3,9 +3,11 @@ import { getBackendSrv } from '@grafana/runtime';
import { OrgServiceAccount as OrgServiceAccount } from 'app/types';
import { serviceAccountsLoaded } from './reducers';
const BASE_URL = `'/api/org/serviceaccounts'`;
export function loadServiceAccounts(): ThunkResult<void> {
return async (dispatch) => {
const serviceAccounts = await getBackendSrv().get('/api/serviceaccounts');
const serviceAccounts = await getBackendSrv().get(BASE_URL);
dispatch(serviceAccountsLoaded(serviceAccounts));
};
}
@ -13,7 +15,7 @@ export function loadServiceAccounts(): ThunkResult<void> {
export function updateServiceAccount(serviceAccount: OrgServiceAccount): ThunkResult<void> {
return async (dispatch) => {
// TODO: implement on backend
await getBackendSrv().patch(`/api/serviceaccounts/${serviceAccount.serviceAccountId}`, {
await getBackendSrv().patch(`${BASE_URL}/${serviceAccount.serviceAccountId}`, {
role: serviceAccount.role,
});
dispatch(loadServiceAccounts());
@ -22,7 +24,7 @@ export function updateServiceAccount(serviceAccount: OrgServiceAccount): ThunkRe
export function removeServiceAccount(serviceAccountId: number): ThunkResult<void> {
return async (dispatch) => {
await getBackendSrv().delete(`/api/serviceaccounts/${serviceAccountId}`);
await getBackendSrv().delete(`${BASE_URL}/${serviceAccountId}`);
dispatch(loadServiceAccounts());
};
}