{"library":"oci-databasemigration","title":"OCI Database Migration Service Client for Node.js","description":"The `oci-databasemigration` package provides a Node.js client for interacting with the Oracle Cloud Infrastructure (OCI) Database Migration Service. It allows developers to programmatically manage resources related to database migrations within the OCI ecosystem, such as creating, managing, and monitoring migration jobs. This module is an integral part of the broader OCI TypeScript SDK and ships with comprehensive TypeScript type definitions, enabling robust development with full type safety. As of version 2.130.0, the SDK is actively maintained, with a rapid release cadence (typically multiple minor versions per month, as evidenced by recent release logs) that consistently introduces support for new OCI services, features, and API endpoints across various OCI components, not solely Database Migration. Its key differentiator is being the official, idiomatic client for OCI services, ensuring seamless compatibility and strict alignment with OCI's continuously evolving API landscape. Successful usage requires an existing OCI account, a configured user with appropriate IAM policies, and an API signing key pair for authentication.","language":"javascript","status":"active","last_verified":"Wed Apr 22","install":{"commands":["npm install oci-databasemigration"],"cli":null},"imports":["import * as databasemigration from 'oci-databasemigration';\nconst client = new databasemigration.DatabaseMigrationClient({...});","import * as common from 'oci-common';\nconst provider = new common.ConfigFileAuthenticationDetailsProvider();","import * as databasemigration from 'oci-databasemigration';\nconst request: databasemigration.requests.ListMigrationsRequest = { compartmentId: '...' };"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import * as databasemigration from 'oci-databasemigration';\nimport * as common from 'oci-common';\n\n// IMPORTANT: Ensure your OCI configuration file (typically ~/.oci/config) is set up\n// and the profile is configured for API signing keys.\n// You can also pass authentication details directly, but a config file is common.\n// For sensitive keys, use environment variables or OCI Vault.\n// Example environment variables for authentication (not recommended for production keys):\n// process.env.OCI_COMPARTMENT_ID\n// process.env.OCI_USER_OCID\n// process.env.OCI_TENANCY_OCID\n// process.env.OCI_FINGERPRINT\n// process.env.OCI_PRIVATE_KEY_PATH\n// process.env.OCI_REGION\n\nasync function listOciDatabaseMigrations() {\n  try {\n    // Initialize the authentication provider using the default OCI config file and profile\n    const authProvider = new common.ConfigFileAuthenticationDetailsProvider();\n\n    // Create a client for the Database Migration Service\n    const client = new databasemigration.DatabaseMigrationClient({\n      authenticationDetailsProvider: authProvider,\n      region: authProvider.getRegion() // Use region from config or explicitly set\n    });\n\n    // Define the compartment ID where your migrations are located\n    const compartmentId = process.env.OCI_COMPARTMENT_ID || 'ocid1.compartment.oc1..examplecompartmentid'; \n    if (compartmentId === 'ocid1.compartment.oc1..examplecompartmentid') {\n      console.warn('Using a placeholder compartment ID. Please set OCI_COMPARTMENT_ID environment variable or replace it directly.');\n    }\n\n    // Create a request object to list migrations in the specified compartment\n    const listMigrationsRequest: databasemigration.requests.ListMigrationsRequest = {\n      compartmentId: compartmentId,\n      lifecycleState: databasemigration.models.Migration.LifecycleState.Active // Optional: Filter by active migrations\n    };\n\n    console.log(`Listing OCI Database Migrations in compartment: ${compartmentId}...`);\n\n    // Call the API to list migrations\n    const response = await client.listMigrations(listMigrationsRequest);\n\n    if (response.items && response.items.length > 0) {\n      console.log(`Found ${response.items.length} migrations:`)\n      response.items.forEach(migration => {\n        console.log(`- ${migration.displayName} (OCID: ${migration.id}, State: ${migration.lifecycleState})`);\n      });\n    } else {\n      console.log('No database migrations found in the specified compartment.');\n    }\n  } catch (error) {\n    console.error('Error listing OCI Database Migrations:', error);\n    if (error instanceof Error && error.message.includes('AuthNFailed')) {\n        console.error('Authentication failed. Please check your OCI config file and API key setup.');\n    } else if (error instanceof Error && error.message.includes('NotFound')) {\n        console.error('Resource not found. Check compartment ID and permissions.');\n    }\n  }\n}\n\nlistOciDatabaseMigrations();","lang":"typescript","description":"This quickstart demonstrates how to initialize the OCI Database Migration client and list existing migrations within a specified OCI compartment, using credentials from the default OCI config file.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}