feat(catalog): add analyze location endpoint to client

Signed-off-by: Benjamin Janssens <benji.janssens@gmail.com>
This commit is contained in:
Benjamin Janssens
2025-07-07 13:53:30 +02:00
parent 72f52b6ff9
commit cf39e4e84c
4 changed files with 42 additions and 0 deletions
+1
View File
@@ -55,6 +55,7 @@
},
"devDependencies": {
"@backstage/cli": "workspace:^",
"@backstage/plugin-catalog-common": "workspace:^",
"msw": "^1.0.0"
}
}
@@ -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<AnalyzeLocationResponse> {
const response = await this.apiClient.analyzeLocation(
{
body: request,
},
options,
);
if (response.status !== 200) {
throw await ResponseError.fromResponse(response);
}
return response.json() as Promise<AnalyzeLocationResponse>;
}
//
// Private methods
//
+15
View File
@@ -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<ValidateEntityResponse>;
/**
* Validate a given location.
*
* @param location - Request parameters
* @param options - Additional options
*/
analyzeLocation(
location: AnalyzeLocationRequest,
options?: CatalogRequestOptions,
): Promise<AnalyzeLocationResponse>;
}
+1
View File
@@ -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"