0.0.1 • Published 9 months ago

@andythehood/catalog-backend-module-apigee v0.0.1

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
9 months ago

Catalog Backend Module for Apigee

This is an extension module to the Backstage plugin-catalog-backend plugin, providing an Apigee Entity provider.

The provider uses the Apigee Management API to import Apigee entities into the Backstage catalog and generate the relationships between them:

Apigee Entity Relationships

Currently supported entities are

  • API Proxies imported as kind:Component, spec.type:apiproxy
  • API Products imported as kind:Component, spec.type:apiproduct
  • Developer Applications imported as kind:Component, spec.type:devapp
  • Developers imported as kind:Component, spec.type:developer
  • Environments imported as kind:Resource, spec.type:environment
  • API Deployments imported as kind:Component, spec.type:deployment

Dependencies

This module depends on the following Backstage backend plugins:

  • the Auth backend plugin needs to be configured with a Google Authentication Provider
  • the Events backend plugin needs to be enabled and configured with a HttpPostIngressEventPublisher to enable the webhook trigger

yarn add --cwd packages/backend @backstage/plugin-events-backend

yarn --cwd packages/backend add @backstage/plugin-events-node

/Users/andyhood/Projects/Backstage/backstage-dev/packages/backend/src/types.ts import { EventBroker } from '@backstage/plugin-events-node';

/Users/andyhood/Projects/Backstage/backstage-dev/packages/backend/src/index.ts

import { DefaultEventBroker } from '@backstage/plugin-events-backend';

import events from './plugins/events'; const eventsEnv = useHotMemoize(module, () => createEnv('events'));

apiRouter.use('/events', await events(eventsEnv));

const eventBroker = new DefaultEventBroker(root.child({ type: 'plugin' }));

return (plugin: string): PluginEnvironment => { const logger = root.child({ type: 'plugin', plugin }); const database = databaseManager.forPlugin(plugin); const cache = cacheManager.forPlugin(plugin); const scheduler = taskScheduler.forPlugin(plugin); return { logger, ... eventBroker, };

Installation

This module needs to be added to an existing Backstage instance:

# From your Backstage root directory
yarn add --cwd packages/backend @andythehood/catalog-backend-module-apigee

See Backstage documentation for further details on how to install modules.

Configuration

You should now be able to add this class to your backend in packages/backend/src/plugins/catalog.ts:

packages/backend/src/plugins/catalog.ts

import { CatalogBuilder } from '@backstage/plugin-catalog-backend';
import { ScaffolderEntitiesProcessor } from '@backstage/plugin-scaffolder-backend';
import { Router } from 'express';
import { PluginEnvironment } from '../types';

+import { ApigeeEntityProvider } from '@andythehood/catalog-backend-module-apigee';

export default async function createPlugin(
  env: PluginEnvironment,
): Promise<Router> {
  const builder = await CatalogBuilder.create(env);
  builder.addProcessor(new ScaffolderEntitiesProcessor());

+  const apigeeAPIProvider = new ApigeeEntityProvider({
+    logger: env.logger,
+    topics: ['apigee'],
+    eventBroker: env.eventBroker,
+  });
+  builder.addEntityProvider(apigeeAPIProvider);

  const { processingEngine, router } = await builder.build();
  await processingEngine.start();
  return router;
}

Usage

To trigger an import from an Apigee Organization, send a HTTP POST request to the backend http events endpoint, e.g. http://localhost:7007/api/events/http/apigee with a JSON payload of the format

    {"organization" : "my-apigeex-org", "namespace": "default"}