# @andythehood/catalog-backend-module-apigee

> Catalog Backend Module for Apigee

Latest version **0.0.1** (published 2023-08-04) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @andythehood/catalog-backend-module-apigee
pnpm add @andythehood/catalog-backend-module-apigee
yarn add @andythehood/catalog-backend-module-apigee
bun add @andythehood/catalog-backend-module-apigee
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2023-08-04 |
| First published | 2023-08-04 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 55.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | andythehood@gmail.com |
| Maintainers | andythehood |
| Keywords | backstage |

## Links

- npm: https://www.npmjs.com/package/@andythehood/catalog-backend-module-apigee
- npm.io page: https://npm.io/package/@andythehood/catalog-backend-module-apigee

## Dependencies (4)

- [winston](https://npm.io/package/winston.md) ^3.2.1
- [google-auth-library](https://npm.io/package/google-auth-library.md) ^8.9.0
- [@backstage/plugin-events-node](https://npm.io/package/@backstage/plugin-events-node.md) ^0.2.8
- [@backstage/plugin-catalog-node](https://npm.io/package/@backstage/plugin-catalog-node.md) ^1.4.0

## Recent versions

- 0.0.1 (latest) — 2023-08-04

## README

# 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](https://cloud.google.com/apigee/docs/reference/apis/apigee/rest) to import Apigee entities into the Backstage catalog and generate the relationships between them:

![Apigee Entity Relationships](./apigee-image.svg "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](https://backstage.io/docs/auth/google/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:

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

See [Backstage documentation](https://backstage.io) 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

```diff
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"}
```

---
_Source: https://npm.io/package/@andythehood/catalog-backend-module-apigee · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
