mirror of
https://github.com/grafana/grafana.git
synced 2024-11-26 19:00:54 -06:00
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:
parent
14b92b75c7
commit
ccd9e46dda
@ -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))
|
||||
|
@ -23,7 +23,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
serviceaccountIDPath = "/api/serviceaccounts/%s"
|
||||
serviceaccountIDPath = "/api/org/serviceaccounts/%s"
|
||||
)
|
||||
|
||||
// test the accesscontrol endpoints
|
||||
|
@ -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());
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user