diff --git a/packages/catalog-client/package.json b/packages/catalog-client/package.json index 93f45f8611..d5ac5f720e 100644 --- a/packages/catalog-client/package.json +++ b/packages/catalog-client/package.json @@ -55,6 +55,7 @@ }, "devDependencies": { "@backstage/cli": "workspace:^", + "@backstage/plugin-catalog-common": "workspace:^", "msw": "^1.0.0" } } diff --git a/packages/catalog-client/src/CatalogClient.ts b/packages/catalog-client/src/CatalogClient.ts index e69f6ad434..7d86eed95d 100644 --- a/packages/catalog-client/src/CatalogClient.ts +++ b/packages/catalog-client/src/CatalogClient.ts @@ -44,6 +44,10 @@ import { } from './types/api'; import { isQueryEntitiesInitialRequest, splitRefsIntoChunks } from './utils'; import { DefaultApiClient, TypedResponse } from './schema/openapi'; +import type { + AnalyzeLocationRequest, + AnalyzeLocationResponse, +} from '@backstage/plugin-catalog-common'; /** * A frontend and backend compatible client for communicating with the Backstage @@ -431,6 +435,27 @@ export class CatalogClient implements CatalogApi { }; } + /** + * {@inheritdoc CatalogApi.analyzeLocation} + */ + async analyzeLocation( + request: AnalyzeLocationRequest, + options?: CatalogRequestOptions, + ): Promise { + const response = await this.apiClient.analyzeLocation( + { + body: request, + }, + options, + ); + + if (response.status !== 200) { + throw await ResponseError.fromResponse(response); + } + + return response.json() as Promise; + } + // // Private methods // diff --git a/packages/catalog-client/src/types/api.ts b/packages/catalog-client/src/types/api.ts index c999b29390..28fe8bf276 100644 --- a/packages/catalog-client/src/types/api.ts +++ b/packages/catalog-client/src/types/api.ts @@ -16,6 +16,10 @@ import { CompoundEntityRef, Entity } from '@backstage/catalog-model'; import { SerializedError } from '@backstage/errors'; +import type { + AnalyzeLocationRequest, + AnalyzeLocationResponse, +} from '@backstage/plugin-catalog-common'; /** * This symbol can be used in place of a value when passed to filters in e.g. @@ -677,4 +681,15 @@ export interface CatalogApi { locationRef: string, options?: CatalogRequestOptions, ): Promise; + + /** + * Validate a given location. + * + * @param location - Request parameters + * @param options - Additional options + */ + analyzeLocation( + location: AnalyzeLocationRequest, + options?: CatalogRequestOptions, + ): Promise; } diff --git a/yarn.lock b/yarn.lock index 45962f279b..8d0f99bd8a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3872,6 +3872,7 @@ __metadata: "@backstage/catalog-model": "workspace:^" "@backstage/cli": "workspace:^" "@backstage/errors": "workspace:^" + "@backstage/plugin-catalog-common": "workspace:^" cross-fetch: "npm:^4.0.0" msw: "npm:^1.0.0" uri-template: "npm:^2.0.0"