@adityasinghal26/plugin-oracle-cloud-backend
Version:
A backend plugin implementation to connect to the Oracle Cloud API.
186 lines (180 loc) • 7.48 kB
TypeScript
import express from 'express';
import { Logger } from 'winston';
import { Config } from '@backstage/config';
import * as identity from 'oci-identity';
import * as common from 'oci-common';
import { GetTenancyResponse, ListCompartmentsResponse, GetCompartmentResponse } from 'oci-identity/lib/response';
import * as artifacts from 'oci-artifacts';
import { ListContainerRepositoriesResponse } from 'oci-artifacts/lib/response';
/**
* Information about an Oracle Cloud tenancy.
* @public
*/
interface OracleConfig {
/**
* Name of the tenancy. A tenancy name in configuration and catalog should match.
*/
tenancyName: string;
/**
* Configuration file path to access the tenancy config
*/
configFilePath: string;
/**
* Default profile to access the tenancy from the frontend
*/
defaultProfile?: string;
}
/**
* Holds multiple Oracle Cloud tenancy configurations
* @public
*/
declare class OracleCloudApi {
/**
*
* @param logger - Object to add different logs to the server
* @param config - Backend configuration loaded from app-config.*.yaml
* @param tenancyList - List of Oracle Cloud tenancies configuration from config file
*
*/
protected readonly logger: Logger;
protected readonly config: Config;
readonly tenancyList: OracleConfig[];
protected constructor(logger: Logger, config: Config, tenancyList: OracleConfig[]);
/**
* Read all tenancy configurations from config file
* @param config - Root configuration from app-config.*.yaml file
* @param options - Various options required to complement config
* @returns A OracleCloudApi object that contains list of tenancies
*/
static fromConfiguration(config: Config, options: {
logger: Logger;
}): OracleCloudApi;
/**
* Reads configuration for a particular tenancy
* @param name - Name of the tenancy for which config is required
* @returns configurationFilePath and defaultProfile from the config
* @public
*/
getTenancyConfiguration(name?: string): Promise<{
configurationFilePath: string;
defaultProfile: string;
}>;
/**
* Reads profile details map from config file
* @param configurationFilePath - Path of the Oracle configuration file
* @param profile - Profile to be used
* @returns a Map of the configured Profile
* @public
*/
getProfileConfig(configurationFilePath: string, profile: string): Promise<Map<string, string> | undefined>;
/**
* Read profile details based on tenancy name
* Gets the config file path and default profile for tenancy
* and passes that to {@link getProfileConfig} for Profile details map
* @param tenancyName - Name of the tenancy
* @param profile - Profile to be used
* @returns Profile details Map to read the configurations
*/
getProfileConfigFromTenancy(tenancyName?: string, profile?: string): Promise<Map<string, string> | undefined>;
/**
* Creates provider for Oracle Downstream API modules
* @param configurationFilePath - Path of the Oracle configuration file
* @param profile - Profile to be used
* @returns an instance of Oracle Authentication Details Provider
* @public
*/
getAuthenticationDetailsProvider(configurationFilePath: string, profile: string): Promise<common.ConfigFileAuthenticationDetailsProvider>;
}
/**
* Provides Oracle Cloud API endpoint for Identity services
* @public
*/
declare class IdentityApi extends OracleCloudApi {
/**
* Read all tenancy configurations from config file
* @param config - Root configuration from app-config.*.yaml file
* @param options - Various options required to complement config
* @returns A IdentityApi object that contains list of tenancies
*/
static fromConfig(config: Config, options: {
logger: Logger;
}): IdentityApi;
/**
* Read config file and profile for an Identity API client
* @param tenancyName - Name of the tenancy
* @param profile - Name of the profile for getting the client
* @returns an instance of {@link IdentityClient} to trigger Identity REST APIs
* @public
*/
getIdentityClient(tenancyName?: string, profile?: string): Promise<identity.IdentityClient>;
/**
* Fetch the details of the tenancy configured
* based on the tenancyId for a certain config file and profile
* @param tenancyName - Name of the tenancy
* @param profile - Profile to be used from the config file
* @returns an instance of {@link GetTenancyResponse} from Identity Responses
* @public
*/
getTenancy(tenancyName?: string, profile?: string): Promise<GetTenancyResponse>;
/**
* Get the list of compartments in Tenancy
* @param tenancyName - Name of the tenancy
* @param profile - Profile to be used
* @param compartmentName - Name of the compartment to filter with (if any)
* @returns an instance of {@link ListCompartmentsResponse} with compartment items
* @public
*/
getCompartmentsInTenancy(tenancyName?: string, profile?: string, compartmentName?: string): Promise<ListCompartmentsResponse>;
/**
* Get the details of the compartment in a tenancy
* @param compartmentName - Name of the compartment to get details for
* @param tenancyName - Name of the tenancy
* @param profile - Profile to be used
* @returns an instance of {@link GetCompartmentResponse} with compartment model
* @public
*/
getCompartmentDetailsInTenancy(compartmentName: string, tenancyName?: string, profile?: string): Promise<GetCompartmentResponse>;
}
/**
* Provides Oracle Cloud API endpoint for Artifacts services
* @public
*/
declare class ArtifactsApi extends OracleCloudApi {
private readonly identityApi;
private constructor();
/**
* Read all tenancy configurations from config file
* @param config - Root configuration from app-config.*.yaml file
* @param options - Various options required to complement config
* @returns A ArtifactsApi object that contains list of tenancies
*/
static fromConfig(config: Config, options: {
logger: Logger;
}): ArtifactsApi;
/**
* Read config file and profile for an Artifacts API client
* @param tenancyName - Name of the tenancy
* @param profile - Name of the profile for getting the client
* @returns an instance of ArtifactsClient to trigger Artifacts REST APIs
* @public
*/
getArtifactsClient(tenancyName?: string, profile?: string): Promise<artifacts.ArtifactsClient>;
/**
* Fetch the list and the details of the container repositories present
* based on the compartment name for a certain config file and profile
* @param compartmentName - Name of the compartment
* @param tenancyName - Name of the tenancy
* @param profile - Profile to be used from the config file
* @returns an instance of GetTenancyResponse from Identity Responses
* @public
*/
getContainerRepositories(compartmentName: string, tenancyName?: string, profile?: string): Promise<ListContainerRepositoriesResponse>;
}
interface RouterOptions {
identityApi?: IdentityApi;
artifactsApi?: ArtifactsApi;
logger: Logger;
config: Config;
}
declare function createRouter(options: RouterOptions): Promise<express.Router>;
export { RouterOptions, createRouter };