-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add api key template api call for usage panel (#851)
* feat: add api key template api call for usage panel J:ORG-659 * chore: fix build * chore: fix build * chore: replace url by fetch by id * chore: fix test * chore: fix build * Update src/resources/ApiKeyTemplate/ApiKeyTemplateInterface.ts Co-authored-by: Gaël Dostie <35579930+gdostie@users.noreply.github.com> * Update src/resources/ApiKeyTemplate/ApiKeyTemplate.ts Co-authored-by: Gaël Dostie <35579930+gdostie@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Gaël Dostie <35579930+gdostie@users.noreply.github.com> * chore: apply pr comments * chore: fix build * Update src/resources/ApiKeyTemplate/test/ApiKeyTemplate.spec.ts Co-authored-by: Gaël Dostie <35579930+gdostie@users.noreply.github.com> --------- Co-authored-by: Gaël Dostie <35579930+gdostie@users.noreply.github.com>
- Loading branch information
1 parent
2d6cbc4
commit 2375f77
Showing
6 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import Resource from "../Resource.js"; | ||
import { ApiKeyTemplateModel } from "./ApiKeyTemplateInterface.js"; | ||
|
||
export default class ApiKeyTemplate extends Resource { | ||
static baseUrl = '/rest/templates/apikeys' | ||
|
||
get(apiKeyTemplateId:string) { | ||
return this.api.get<ApiKeyTemplateModel[]>(`${ApiKeyTemplate.baseUrl}/${apiKeyTemplateId}`) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { PrivilegeModel } from "../BaseInterfaces.js"; | ||
|
||
export interface ApiKeyTemplateModel { | ||
/** | ||
* The unique identifier of the API key template. | ||
*/ | ||
id?: string; | ||
/** | ||
* The displaye name of the Api key template. | ||
*/ | ||
displayName?: string; | ||
/** | ||
* The descirption of the Api key template. | ||
*/ | ||
description?: string; | ||
/** | ||
* A set of IP addresses allowed to use the Api key template. | ||
*/ | ||
allowedIps?: string[]; | ||
/** | ||
* A set of IP addresses that will be denied access when attempting to use the API key template. | ||
*/ | ||
deniedIps?: string[]; | ||
/** | ||
* A set of privileges binded to an api key template. | ||
*/ | ||
privileges?: PrivilegeModel[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './ApiKeyTemplate.js'; | ||
export * from './ApiKeyTemplateInterface.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import API from '../../../APICore.js'; | ||
|
||
import ApiKeyTemplate from '../ApiKeyTemplate.js'; | ||
|
||
jest.mock('../../../APICore.js'); | ||
|
||
const APIMock: jest.Mock<API> = API as any; | ||
|
||
describe('ApiKeyTemplateModel', () => { | ||
let apiKeyTemplate: ApiKeyTemplate; | ||
const api = new APIMock() as jest.Mocked<API>; | ||
const serverlessApi = new APIMock() as jest.Mocked<API>; | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
apiKeyTemplate = new ApiKeyTemplate(api, serverlessApi); | ||
}); | ||
|
||
describe('get', () => { | ||
it('should make a GET call to the ApiKeys at the keyPurpose', async () => { | ||
const apiKeyTemplateToGetId = 'ApikeyTemplate-to-be-fetched'; | ||
await apiKeyTemplate.get(apiKeyTemplateToGetId); | ||
expect(api.get).toHaveBeenCalledTimes(1); | ||
expect(api.get).toHaveBeenCalledWith(`${ApiKeyTemplate.baseUrl}/${apiKeyTemplateToGetId}`); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters