|
7 | 7 |
|
8 | 8 | # [![Mocks Server][logo-url]][website-url] Mocks Server Plugin Admin Api |
9 | 9 |
|
10 | | -Plugin for [Mocks Server][website-url] that provides an API REST that allows to change dinamically the current behavior, change delay time, and another [Mocks Server options][options-url]. |
| 10 | +Plugin for [Mocks Server][website-url] that provides an API REST that allows to change the current behavior, change delay time, and another [Mocks Server options][options-url]. |
11 | 11 |
|
12 | | -This is __very useful when running acceptance tests, as you can change the behavior of the api__ simply making an HTTP request in your tests `before` method, for example. |
| 12 | +This is __very useful when running acceptance tests, as you can change the current mock__ simply with a HTTP request in the `before` method of your tests, for example. |
| 13 | + |
| 14 | +A __client for the administration api__ is also distributed as a separated package: [@mocks-server/admin-api-client](https://www.npmjs.com/package/@mocks-server/admin-api-client). |
13 | 15 |
|
14 | 16 | ## Usage |
15 | 17 |
|
16 | 18 | This plugin is included in the [main distribution of the Mocks Server project][main-distribution-url], so you can refer to the [official documentation website][website-url]. |
17 | 19 |
|
18 | 20 | ## Options |
19 | 21 |
|
20 | | -* `adminApiPath` - Base path for the administration api. Default is "/admin". You should change it only if there is any conflict with the api you are mocking. |
21 | | -* `adminApiDeprecatedPaths` - Boolean option, disables deprecated "/mocks" api path, which is still enabled by default. |
| 22 | +* __`adminApiPath`__ _(String)_: Path for the administration api. Default is `/admin`. You should change it only in case there is any conflict with the api you are mocking. |
22 | 23 |
|
23 | | -Read more about [how to define options for the mocks-server plugins here](https://www.mocks-server.org/docs/configuration-options). |
| 24 | +Read more about [how to set options in Mocks Server here](https://www.mocks-server.org/docs/configuration-options). |
24 | 25 |
|
25 | 26 | ## API Resources |
26 | 27 |
|
27 | 28 | Available api resources are: |
28 | 29 |
|
29 | | -* `GET` `/admin/about` Returns plugin information. |
| 30 | +* `GET` `/admin/about` Returns "plugin-admin-api" information. |
30 | 31 | * Response body example: `{ "version": "1.2.0" }` |
31 | | -* `GET` `/admin/behaviors` Returns behaviors collection. |
32 | | -* `GET` `/admin/behaviors/:id` Returns an specific behavior. |
33 | | -* `GET` `/admin/fixtures` Returns fixtures collection. |
34 | | -* `GET` `/admin/fixtures/:id` Returns an specific fixture. |
| 32 | +* `GET` `/admin/mocks` Returns mocks. |
| 33 | +* `GET` `/admin/mocks/:id` Returns a specific mock. |
| 34 | +* `GET` `/admin/routes` Returns routes collection. |
| 35 | +* `GET` `/admin/routes/:id` Returns a specific route. |
| 36 | +* `GET` `/admin/routes-variants` Returns routes variants collection. |
| 37 | +* `GET` `/admin/routes-variants/:id` Returns a specific route variant. |
| 38 | +* `GET` `/admin/mock-custom-routes-variants` Returns an array of currently custom routes variants ids. |
| 39 | +* `POST` `/admin/mock-custom-routes-variants` Defines a route variant to be used by current mock. |
| 40 | + * Request body example: `{ "id": "users:error" }` |
| 41 | +* `DELETE` `/admin/mock-custom-routes-variants` Restore routes variants to those defined in current mock. |
35 | 42 | * `GET` `/admin/settings` Returns current server settings. |
36 | | - * Response body example: `{ "delay": 0, behavior: "foo-behavior", path: "mocks" }` |
| 43 | + * Response body example: `{ "delay": 0, mock: "foo-mock", path: "mocks" }` |
37 | 44 | * `PATCH` `/admin/settings` Changes current server settings. |
38 | 45 | * Request body example: `{ "delay": 3000 }` |
| 46 | +* `GET` `/admin/alerts` Returns current alerts. |
| 47 | +* `GET` `/admin/alerts/:id` Returns a specific alert. The alert `id` is equivalent to the alert `context` _(read the [developing plugins chapter](plugins-developing-plugins.md) for further info about alerts)_. |
39 | 48 |
|
40 | | -> Deprecated api resources under "/mocks" api path are still available. |
| 49 | +> v1.x deprecated api resources are also still available under the `/legacy` path. |
41 | 50 |
|
42 | 51 | ## Contributing |
43 | 52 |
|
|
0 commit comments