# @adityasinghal26/plugin-oracle-cloud-backend

> A backend plugin implementation to connect to the Oracle Cloud API.

Latest version **0.3.0** (published 2024-01-03) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @adityasinghal26/plugin-oracle-cloud-backend
pnpm add @adityasinghal26/plugin-oracle-cloud-backend
yarn add @adityasinghal26/plugin-oracle-cloud-backend
bun add @adityasinghal26/plugin-oracle-cloud-backend
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2024-01-03 |
| First published | 2024-01-02 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 11 |
| Unpacked size | 80.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | adityasinghal26 |
| Keywords | backstage, plugin, backend, oracle, oracle-cloud, oracle-cloud-infrastructure |

## Links

- npm: https://www.npmjs.com/package/@adityasinghal26/plugin-oracle-cloud-backend
- Repository: https://github.com/adityasinghal26/backstage-plugins
- Homepage: https://github.com/adityasinghal26/backstage-plugins#readme
- Issues: https://github.com/adityasinghal26/backstage-plugins/issues
- npm.io page: https://npm.io/package/@adityasinghal26/plugin-oracle-cloud-backend

## Dependencies (11)

- [yn](https://npm.io/package/yn.md) ^4.0.0
- [express](https://npm.io/package/express.md) ^4.17.1
- [winston](https://npm.io/package/winston.md) ^3.2.1
- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.7
- [oci-common](https://npm.io/package/oci-common.md) ^2.76.0
- [oci-identity](https://npm.io/package/oci-identity.md) ^2.76.0
- [oci-artifacts](https://npm.io/package/oci-artifacts.md) ^2.76.0
- [@types/express](https://npm.io/package/@types/express.md) *
- [@backstage/config](https://npm.io/package/@backstage/config.md) ^1.1.1
- [express-promise-router](https://npm.io/package/express-promise-router.md) ^4.1.0
- [@backstage/backend-common](https://npm.io/package/@backstage/backend-common.md) ^0.20.0

## Alternatives

- [localforage](https://npm.io/package/localforage.md) — 6.2M weekly downloads
- [localforage-observable](https://npm.io/package/localforage-observable.md) — 30.8K weekly downloads
- [@y/y](https://npm.io/package/@y/y.md) — 30.1K weekly downloads
- [@metaobjectsdev/render](https://npm.io/package/@metaobjectsdev/render.md) — 3.5K weekly downloads
- [@ledgerhq/coin-algorand](https://npm.io/package/@ledgerhq/coin-algorand.md) — 1.1K weekly downloads

## Recent versions

- 0.3.0 (latest) — 2024-01-03
- 0.2.1 — 2024-01-02
- 0.2.0 — 2024-01-02
- 0.1.0 — 2024-01-02

## README

# Oracle Cloud Backend Plugin

A backend plugin implementation to connect to the Oracle Cloud API.

## Setup into a Backstage Instance

The plugin needs to be configured and then installed as per the steps in following section. 

### Configuration

The Oracle Cloud plugin allows either single or multiple Oracle Cloud tenancies, allowing to trigger REST APIs with the tenancy and profile name. The tenancy name (tenancyName) and the profile name (profile) in the API query parameters is optional, which if not provided, will utilise the default tenancy and the profile in the configuration.

#### Oracle Configuration File

Below is a sample reference for Oracle configuration file. Here, the profile name is in square brackets '[]' and other details such as user ID, tenancy ID and region can be configured. You will also need to provide a path to your private PEM file for authentication.

**Note:** It is advised to create one config file for each tenancy where different profiles such as DEFAULT, and test (in this example) can be configured with different users and regions.

```
[DEFAULT]
user=ocid1.user.oc1..<your_unique_id>
fingerprint=<your_fingerprint>
tenancy=ocid1.tenancy.oc1..<your_unique_id>
region=<your_region>
key_file=~/.oci/oci_api_key.pem

[test]
user=ocid1.user.oc1..<your_unique_id_test>
fingerprint=<your_fingerprint_test>
tenancy=ocid1.tenancy.oc1..<your_unique_id>
region=<your_region>
key_file=~/.oci/oci_api_key.pem
```

#### Single Configuration

```yaml
oracleCloud:
  configFilePath: ./config
  defaultProfile: test
```

#### Multiple Configurations

```yaml
oracleCloud:
  configFilePath: ./config
  defaultProfile: test
  tenancies:
  - tenancyName: companyA
    configFilePath: ./configA
    defaultProfile: profileA1
  - tenancyName: companyB
    configFilePath: ./configB
    defaultProfile: profileB1
```

#### Sample API to get tenancy details based on tenancy and profile configurations

If the query parameters tenancyName and profile are omitted or left empty, the plugin will consider the default values for both tenancy and profile configuration.

```bash
curl --location 'http://localhost:7007/api/oracle-cloud/identity/tenancy?tenancyName=companyA&profile=profileA1'
```

### Up and Running

Follow the below steps and integrate Oracle Cloud Backend plugin into your Backstage instance.

1. First we need to add the `@backstage/plugin-oracle-cloud-backend` package to your backend:

   ```sh
   # From your Backstage root directory
   yarn add --cwd packages/backend @adityasinghal26/plugin-oracle-cloud-backend
   ```

2. Then we will create a new file named `packages/backend/src/plugins/oracle-cloud.ts`, and add the
   following to it:

   ```ts
   import { createRouter } from '@adityasinghal26/plugin-oracle-cloud-backend';
   import { Router } from 'express';
   import type { PluginEnvironment } from '../types';

   export default function createPlugin(
     env: PluginEnvironment,
   ): Promise<Router> {
     return createRouter({
       logger: env.logger,
       config: env.config,
     });
   }
   ```

3. Next we wire this into the overall backend router, edit `packages/backend/src/index.ts`:

   ```ts
   import oracleCloud from './plugins/oracle-cloud';
   // ...
   async function main() {
     // ...
     // Add this line under the other lines that follow the useHotMemoize pattern
     const oracleEnv = useHotMemoize(module, () => createEnv('oracleCloud'));
     // ...
     // Insert this line under the other lines that add their routers to apiRouter in the same way
     apiRouter.use('/oracle-cloud', await oracleCloud(oracleEnv));
   ```

4. Now run `yarn start-backend` from the repo root
5. Finally open `http://localhost:7007/api/oracle-cloud/health` in a browser/or from Postman and it should return `{"status":"ok"}`

### New Backend System

The Oracle Cloud Backend plugin does not support the [new backend system](https://backstage.io/docs/backend-system/) currently. The plugin will be extended to support the same in upcoming versions.

---
_Source: https://npm.io/package/@adityasinghal26/plugin-oracle-cloud-backend · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
