{"id":16466,"library":"oci-databasetools","title":"OCI Database Tools Service Client for NodeJS","description":"The `oci-databasetools` package is the official Oracle Cloud Infrastructure (OCI) NodeJS client for the Database Tools Service. It enables developers to programmatically manage resources within this service, such as database connections, private endpoints, and related configurations. As part of the broader OCI TypeScript SDK, it ships with comprehensive TypeScript type definitions, enhancing developer experience. Currently at version 2.130.0, the package follows a rapid release cadence, often receiving updates weekly or bi-weekly to incorporate new OCI service features and API enhancements. Its key differentiators include direct integration with OCI's authentication mechanisms, adherence to OCI API specifications, and guaranteed compatibility with the latest service functionalities, providing a robust and reliable interface for OCI automation compared to generic HTTP clients.","status":"active","version":"2.130.0","language":"javascript","source_language":"en","source_url":"https://github.com/oracle/oci-typescript-sdk","tags":["javascript","typescript"],"install":[{"cmd":"npm install oci-databasetools","lang":"bash","label":"npm"},{"cmd":"yarn add oci-databasetools","lang":"bash","label":"yarn"},{"cmd":"pnpm add oci-databasetools","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Provides core utilities for OCI SDKs, including authentication providers and base client functionalities.","package":"oci-common","optional":false}],"imports":[{"note":"The OCI TypeScript SDK is primarily designed for ES Modules. While CommonJS might work in some setups, direct ES module imports are recommended, especially for TypeScript projects.","wrong":"const DatabaseToolsClient = require('oci-databasetools').DatabaseToolsClient;","symbol":"DatabaseToolsClient","correct":"import { DatabaseToolsClient } from 'oci-databasetools';"},{"note":"Types for requests and responses are typically found under the 'lib/model' sub-path. This import pattern ensures you get all necessary types for the service.","symbol":"models","correct":"import * as models from 'oci-databasetools/lib/model';"},{"note":"Authentication and other core utilities like the `DefaultAuthenticationDetailsProvider` are provided by the separate `oci-common` package, not directly from the service client package itself.","wrong":"import { DefaultAuthenticationDetailsProvider } from 'oci-databasetools';","symbol":"common","correct":"import * as common from 'oci-common';"}],"quickstart":{"code":"import * as common from 'oci-common';\nimport * as databasetools from 'oci-databasetools';\nimport * as models from 'oci-databasetools/lib/model';\n\nasync function main() {\n  try {\n    // Configure authentication provider. This will attempt to load configuration\n    // from ~/.oci/config (recommended) or environment variables.\n    const provider = new common.DefaultAuthenticationDetailsProvider();\n\n    // Create a client for the Database Tools Service\n    const client = new databasetools.DatabaseToolsClient({\n      authenticationDetailsProvider: provider\n    });\n\n    // Replace with your compartment ID (e.g., from environment variable or direct string)\n    const compartmentId = process.env.OCI_COMPARTMENT_ID ?? 'ocid1.compartment.oc1..exampleuniqueid';\n\n    console.log(`Listing Database Tools Connections in compartment: ${compartmentId}`);\n\n    const listConnectionsRequest: models.ListDatabaseToolsConnectionsRequest = {\n      compartmentId: compartmentId,\n      limit: 10, // Limit results for demonstration\n      lifecycleState: models.DatabaseToolsConnection.LifecycleState.Active // Filter for active connections\n    };\n\n    const response = await client.listDatabaseToolsConnections(listConnectionsRequest);\n\n    if (response.databaseToolsConnectionCollection.items.length > 0) {\n      console.log('Found Database Tools Connections:');\n      response.databaseToolsConnectionCollection.items.forEach(connection => {\n        console.log(`- ${connection.displayName} (ID: ${connection.id}, State: ${connection.lifecycleState})`);\n      });\n    } else {\n      console.log('No active Database Tools Connections found in this compartment.');\n    }\n\n  } catch (error) {\n    console.error('Error interacting with OCI Database Tools Service:', error);\n    if (error instanceof common.errors.ServiceError) {\n      console.error(`OCI Service Error: ${error.statusCode} - ${error.serviceCode}`);\n      console.error(`Message: ${error.message}`);\n    } else if (error instanceof Error) {\n      console.error(`General Error: ${error.message}`);\n    }\n  }\n}\n\nmain();\n","lang":"typescript","description":"This quickstart initializes the OCI Database Tools client using default authentication, then lists active database tools connections within a specified compartment. It demonstrates basic client instantiation, request creation, and error handling."},"warnings":[{"fix":"Ensure your `~/.oci/config` file is correctly configured with your user OCID, tenancy OCID, fingerprint, and private key path. Alternatively, set environment variables like `OCI_TENANCY`, `OCI_USER`, `OCI_FINGERPRINT`, `OCI_KEY_FILE`, and `OCI_REGION`.","message":"OCI SDKs require proper authentication configuration via `~/.oci/config` file or environment variables (`OCI_CONFIG_FILE`, `OCI_PROFILE`, `OCI_REGION`, etc.). Incorrect setup often leads to `NotAuthenticated` errors.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Double-check all OCIDs used in your requests for correctness. Use the OCI Console or `oci-cli` to verify resource OCIDs before incorporating them into your code.","message":"The SDK relies heavily on Oracle Cloud Identifiers (OCIDs) for resources. Providing an incorrect or non-existent OCID for compartments or resources will result in `NotFound` errors, even if authentication is successful.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set the `OCI_REGION` environment variable or explicitly provide the region when creating the authentication provider: `const provider = new common.DefaultAuthenticationDetailsProvider({ region: 'us-ashburn-1' });`","message":"By default, the SDK determines the region from your OCI configuration. If running in an environment without a configured region (e.g., local development without `~/.oci/config`) or if you need to override the configured region, explicit region setting is required.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Verify `~/.oci/config` file contents, permissions (private key must be `0400`), and environment variables (e.g., `OCI_CONFIG_FILE`, `OCI_PROFILE`). Ensure the public key is uploaded to the OCI user API Keys.","cause":"The SDK could not find or validate authentication credentials (API Key or Instance Principal).","error":"ServiceError: NotAuthenticated. The request must be signed with a valid authentication credential to use the API."},{"fix":"Check the exact OCID(s) in your request parameters against the OCI Console or `oci-cli` to confirm they are valid and refer to existing resources in the correct region and tenancy.","cause":"An OCID provided in the request (e.g., for a compartment or specific database tool connection) is incorrect or refers to a deleted resource.","error":"ServiceError: NotFound. The specified resource does not exist."},{"fix":"Consult the OCI API documentation for the specific operation to ensure all required fields are present and their values adhere to the specified constraints (e.g., data types, enum values, length limits).","cause":"A required parameter for an API operation was missing, or a provided parameter had an invalid format or value.","error":"ServiceError: BadArgument. One or more parameters in the request were invalid."}],"ecosystem":"npm"}