fix: remove call to IdentityApi in favor of FetchApi
Signed-off-by: Isaiah Thiessen <isaiah.thiessen@telus.com>
This commit is contained in:
@@ -14,28 +14,20 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { DynatraceProblems, DynatraceApi } from './DynatraceApi';
|
||||
import {
|
||||
DiscoveryApi,
|
||||
IdentityApi,
|
||||
FetchApi,
|
||||
} from '@backstage/core-plugin-api';
|
||||
import { DiscoveryApi, FetchApi } from '@backstage/core-plugin-api';
|
||||
|
||||
export class DynatraceClient implements DynatraceApi {
|
||||
discoveryApi: DiscoveryApi;
|
||||
identityApi: IdentityApi;
|
||||
fetchApi: FetchApi;
|
||||
|
||||
constructor({
|
||||
discoveryApi,
|
||||
identityApi,
|
||||
fetchApi,
|
||||
}: {
|
||||
discoveryApi: DiscoveryApi;
|
||||
identityApi: IdentityApi;
|
||||
fetchApi: FetchApi;
|
||||
}) {
|
||||
this.discoveryApi = discoveryApi;
|
||||
this.identityApi = identityApi;
|
||||
this.fetchApi = fetchApi;
|
||||
}
|
||||
|
||||
@@ -43,15 +35,12 @@ export class DynatraceClient implements DynatraceApi {
|
||||
path: string,
|
||||
query: { [key in string]: any },
|
||||
): Promise<T | undefined> {
|
||||
const { token: idToken } = await this.identityApi.getCredentials();
|
||||
|
||||
const apiUrl = `${await this.discoveryApi.getBaseUrl('proxy')}/dynatrace`;
|
||||
const response = await this.fetchApi.fetch(
|
||||
`${apiUrl}/${path}?${new URLSearchParams(query).toString()}`,
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
...(idToken && { Authorization: `Bearer ${idToken}` }),
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
@@ -18,7 +18,6 @@ import {
|
||||
createApiFactory,
|
||||
createPlugin,
|
||||
discoveryApiRef,
|
||||
identityApiRef,
|
||||
fetchApiRef,
|
||||
createRoutableExtension,
|
||||
} from '@backstage/core-plugin-api';
|
||||
@@ -38,13 +37,11 @@ export const dynatracePlugin = createPlugin({
|
||||
api: dynatraceApiRef,
|
||||
deps: {
|
||||
discoveryApi: discoveryApiRef,
|
||||
identityApi: identityApiRef,
|
||||
fetchApi: fetchApiRef,
|
||||
},
|
||||
factory: ({ discoveryApi, identityApi, fetchApi }) =>
|
||||
factory: ({ discoveryApi, fetchApi }) =>
|
||||
new DynatraceClient({
|
||||
discoveryApi,
|
||||
identityApi,
|
||||
fetchApi,
|
||||
}),
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user