|
1 | | -const { ApiService } = Shopware.Classes |
| 1 | +const { ApiService } = Shopware.Classes; |
2 | 2 |
|
3 | 3 | class Elasticsearch extends ApiService { |
4 | | - constructor( |
5 | | - httpClient, |
6 | | - loginService, |
7 | | - apiEndpoint = '_action/frosh-tools/elasticsearch' |
8 | | - ) { |
9 | | - super(httpClient, loginService, apiEndpoint) |
10 | | - } |
| 4 | + constructor( |
| 5 | + httpClient, |
| 6 | + loginService, |
| 7 | + apiEndpoint = '_action/frosh-tools/elasticsearch' |
| 8 | + ) { |
| 9 | + super(httpClient, loginService, apiEndpoint); |
| 10 | + } |
11 | 11 |
|
12 | | - status() { |
13 | | - const apiRoute = `${this.getApiBasePath()}/status` |
14 | | - return this.httpClient |
15 | | - .get(apiRoute, { |
16 | | - headers: this.getBasicHeaders(), |
17 | | - }) |
18 | | - .then((response) => { |
19 | | - return ApiService.handleResponse(response) |
20 | | - }) |
21 | | - } |
| 12 | + status() { |
| 13 | + const apiRoute = `${this.getApiBasePath()}/status`; |
| 14 | + return this.httpClient |
| 15 | + .get(apiRoute, { |
| 16 | + headers: this.getBasicHeaders(), |
| 17 | + }) |
| 18 | + .then((response) => { |
| 19 | + return ApiService.handleResponse(response); |
| 20 | + }); |
| 21 | + } |
22 | 22 |
|
23 | | - indices() { |
24 | | - const apiRoute = `${this.getApiBasePath()}/indices` |
25 | | - return this.httpClient |
26 | | - .get(apiRoute, { |
27 | | - headers: this.getBasicHeaders(), |
28 | | - }) |
29 | | - .then((response) => { |
30 | | - return ApiService.handleResponse(response) |
31 | | - }) |
32 | | - } |
| 23 | + indices() { |
| 24 | + const apiRoute = `${this.getApiBasePath()}/indices`; |
| 25 | + return this.httpClient |
| 26 | + .get(apiRoute, { |
| 27 | + headers: this.getBasicHeaders(), |
| 28 | + }) |
| 29 | + .then((response) => { |
| 30 | + return ApiService.handleResponse(response); |
| 31 | + }); |
| 32 | + } |
33 | 33 |
|
34 | | - deleteIndex(indexName) { |
35 | | - const apiRoute = `${this.getApiBasePath()}/index/` + indexName |
36 | | - return this.httpClient |
37 | | - .delete(apiRoute, { |
38 | | - headers: this.getBasicHeaders(), |
39 | | - }) |
40 | | - .then((response) => { |
41 | | - return ApiService.handleResponse(response) |
42 | | - }) |
43 | | - } |
| 34 | + deleteIndex(indexName) { |
| 35 | + const apiRoute = `${this.getApiBasePath()}/index/` + indexName; |
| 36 | + return this.httpClient |
| 37 | + .delete(apiRoute, { |
| 38 | + headers: this.getBasicHeaders(), |
| 39 | + }) |
| 40 | + .then((response) => { |
| 41 | + return ApiService.handleResponse(response); |
| 42 | + }); |
| 43 | + } |
44 | 44 |
|
45 | | - console(method, path, payload) { |
46 | | - const apiRoute = `${this.getApiBasePath()}/console` + path |
47 | | - return this.httpClient |
48 | | - .request({ |
49 | | - url: apiRoute, |
50 | | - method: method, |
51 | | - headers: { |
52 | | - ...this.getBasicHeaders(), |
53 | | - 'content-type': 'application/json', |
54 | | - }, |
55 | | - data: payload, |
56 | | - }) |
57 | | - .then((response) => { |
58 | | - return ApiService.handleResponse(response) |
59 | | - }) |
60 | | - } |
| 45 | + console(method, path, payload) { |
| 46 | + const apiRoute = `${this.getApiBasePath()}/console` + path; |
| 47 | + return this.httpClient |
| 48 | + .request({ |
| 49 | + url: apiRoute, |
| 50 | + method: method, |
| 51 | + headers: { |
| 52 | + ...this.getBasicHeaders(), |
| 53 | + 'content-type': 'application/json', |
| 54 | + }, |
| 55 | + data: payload, |
| 56 | + }) |
| 57 | + .then((response) => { |
| 58 | + return ApiService.handleResponse(response); |
| 59 | + }); |
| 60 | + } |
61 | 61 |
|
62 | | - flushAll() { |
63 | | - const apiRoute = `${this.getApiBasePath()}/flush_all` |
64 | | - return this.httpClient |
65 | | - .post( |
66 | | - apiRoute, |
67 | | - {}, |
68 | | - { |
69 | | - headers: this.getBasicHeaders(), |
70 | | - } |
71 | | - ) |
72 | | - .then((response) => { |
73 | | - return ApiService.handleResponse(response) |
74 | | - }) |
75 | | - } |
| 62 | + flushAll() { |
| 63 | + const apiRoute = `${this.getApiBasePath()}/flush_all`; |
| 64 | + return this.httpClient |
| 65 | + .post( |
| 66 | + apiRoute, |
| 67 | + {}, |
| 68 | + { |
| 69 | + headers: this.getBasicHeaders(), |
| 70 | + } |
| 71 | + ) |
| 72 | + .then((response) => { |
| 73 | + return ApiService.handleResponse(response); |
| 74 | + }); |
| 75 | + } |
76 | 76 |
|
77 | | - reindex() { |
78 | | - const apiRoute = `${this.getApiBasePath()}/reindex` |
79 | | - return this.httpClient |
80 | | - .post( |
81 | | - apiRoute, |
82 | | - {}, |
83 | | - { |
84 | | - headers: this.getBasicHeaders(), |
85 | | - } |
86 | | - ) |
87 | | - .then((response) => { |
88 | | - return ApiService.handleResponse(response) |
89 | | - }) |
90 | | - } |
| 77 | + reindex() { |
| 78 | + const apiRoute = `${this.getApiBasePath()}/reindex`; |
| 79 | + return this.httpClient |
| 80 | + .post( |
| 81 | + apiRoute, |
| 82 | + {}, |
| 83 | + { |
| 84 | + headers: this.getBasicHeaders(), |
| 85 | + } |
| 86 | + ) |
| 87 | + .then((response) => { |
| 88 | + return ApiService.handleResponse(response); |
| 89 | + }); |
| 90 | + } |
91 | 91 |
|
92 | | - switchAlias() { |
93 | | - const apiRoute = `${this.getApiBasePath()}/switch_alias` |
94 | | - return this.httpClient |
95 | | - .post( |
96 | | - apiRoute, |
97 | | - {}, |
98 | | - { |
99 | | - headers: this.getBasicHeaders(), |
100 | | - } |
101 | | - ) |
102 | | - .then((response) => { |
103 | | - return ApiService.handleResponse(response) |
104 | | - }) |
105 | | - } |
| 92 | + switchAlias() { |
| 93 | + const apiRoute = `${this.getApiBasePath()}/switch_alias`; |
| 94 | + return this.httpClient |
| 95 | + .post( |
| 96 | + apiRoute, |
| 97 | + {}, |
| 98 | + { |
| 99 | + headers: this.getBasicHeaders(), |
| 100 | + } |
| 101 | + ) |
| 102 | + .then((response) => { |
| 103 | + return ApiService.handleResponse(response); |
| 104 | + }); |
| 105 | + } |
106 | 106 |
|
107 | | - cleanup() { |
108 | | - const apiRoute = `${this.getApiBasePath()}/cleanup` |
109 | | - return this.httpClient |
110 | | - .post( |
111 | | - apiRoute, |
112 | | - {}, |
113 | | - { |
114 | | - headers: this.getBasicHeaders(), |
115 | | - } |
116 | | - ) |
117 | | - .then((response) => { |
118 | | - return ApiService.handleResponse(response) |
119 | | - }) |
120 | | - } |
| 107 | + cleanup() { |
| 108 | + const apiRoute = `${this.getApiBasePath()}/cleanup`; |
| 109 | + return this.httpClient |
| 110 | + .post( |
| 111 | + apiRoute, |
| 112 | + {}, |
| 113 | + { |
| 114 | + headers: this.getBasicHeaders(), |
| 115 | + } |
| 116 | + ) |
| 117 | + .then((response) => { |
| 118 | + return ApiService.handleResponse(response); |
| 119 | + }); |
| 120 | + } |
121 | 121 |
|
122 | | - reset() { |
123 | | - const apiRoute = `${this.getApiBasePath()}/reset` |
124 | | - return this.httpClient |
125 | | - .post( |
126 | | - apiRoute, |
127 | | - {}, |
128 | | - { |
129 | | - headers: this.getBasicHeaders(), |
130 | | - } |
131 | | - ) |
132 | | - .then((response) => { |
133 | | - return ApiService.handleResponse(response) |
134 | | - }) |
135 | | - } |
| 122 | + reset() { |
| 123 | + const apiRoute = `${this.getApiBasePath()}/reset`; |
| 124 | + return this.httpClient |
| 125 | + .post( |
| 126 | + apiRoute, |
| 127 | + {}, |
| 128 | + { |
| 129 | + headers: this.getBasicHeaders(), |
| 130 | + } |
| 131 | + ) |
| 132 | + .then((response) => { |
| 133 | + return ApiService.handleResponse(response); |
| 134 | + }); |
| 135 | + } |
136 | 136 | } |
137 | 137 |
|
138 | | -export default Elasticsearch |
| 138 | +export default Elasticsearch; |
0 commit comments