-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fleet] Enrollment api key UI (#51495)
- Loading branch information
Showing
15 changed files
with
575 additions
and
171 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,24 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
export function useInput(defaultValue = '') { | ||
const [value, setValue] = React.useState<string>(defaultValue); | ||
|
||
return { | ||
value, | ||
props: { | ||
onChange: (e: React.ChangeEvent<HTMLInputElement | HTMLSelectElement>) => { | ||
setValue(e.target.value); | ||
}, | ||
value, | ||
}, | ||
clear: () => { | ||
setValue(''); | ||
}, | ||
}; | ||
} |
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
x-pack/legacy/plugins/fleet/public/lib/enrollment_api_key.ts
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,46 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { | ||
ReturnTypeList, | ||
ReturnTypeGet, | ||
ReturnTypeCreate, | ||
ReturnTypeDelete, | ||
} from '../../common/return_types'; | ||
import { RestAPIAdapter } from './adapters/rest_api/adapter_types'; | ||
import { Pagination } from '../hooks/use_pagination'; | ||
import { EnrollmentApiKey } from '../../common/types/domain_data'; | ||
|
||
export class EnrollmentApiKeyLib { | ||
constructor(private readonly rest: RestAPIAdapter) {} | ||
|
||
public async listKeys(pagination: Pagination) { | ||
return await this.rest.get<ReturnTypeList<EnrollmentApiKey>>('/api/fleet/enrollment-api-keys', { | ||
page: pagination.currentPage, | ||
perPage: pagination.pageSize, | ||
}); | ||
} | ||
|
||
public async get(keyId: string) { | ||
return await this.rest.get<ReturnTypeGet<EnrollmentApiKey>>( | ||
`/api/fleet/enrollment-api-keys/${keyId}` | ||
); | ||
} | ||
|
||
public async delete(keyId: string) { | ||
return await this.rest.delete<ReturnTypeDelete>(`/api/fleet/enrollment-api-keys/${keyId}`); | ||
} | ||
|
||
public async create(data: { name: string; policyId: string }) { | ||
return await this.rest.post<ReturnTypeCreate<EnrollmentApiKey>>( | ||
`/api/fleet/enrollment-api-keys`, | ||
{ | ||
name: data.name, | ||
policy_id: data.policyId, | ||
} | ||
); | ||
} | ||
} |
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
Oops, something went wrong.