@distilled.cloud/mongodb-atlas
v0.5.1
Published
Effect-native MongoDB Atlas SDK generated from the [MongoDB Atlas Administration API specification](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/). Manage clusters, database users, projects, organizations, backups, and 390+ operation
Readme
@distilled.cloud/mongodb-atlas
Effect-native MongoDB Atlas SDK generated from the MongoDB Atlas Administration API specification. Manage clusters, database users, projects, organizations, backups, and 390+ operations with exhaustive error typing.
Installation
npm install @distilled.cloud/mongodb-atlas effectQuick Start
import { Effect, Layer } from "effect";
import * as Stream from "effect/Stream";
import * as FetchHttpClient from "effect/unstable/http/FetchHttpClient";
import { listGroupClusters } from "@distilled.cloud/mongodb-atlas/Operations";
import { CredentialsFromEnv } from "@distilled.cloud/mongodb-atlas";
const program = Effect.gen(function* () {
const clusters = yield* listGroupClusters({ groupId: "my-project-id" });
return clusters;
});
const AtlasLive = Layer.mergeAll(FetchHttpClient.layer, CredentialsFromEnv);
program.pipe(Effect.provide(AtlasLive), Effect.runPromise);Configuration
Set the following environment variable:
MONGODB_ATLAS_API_KEY=your-api-keyCreate an API key in the MongoDB Atlas console under Organization Settings > API Keys or Project Settings > API Keys. Grant the key an appropriate role (e.g. Organization Member, Project Owner).
Error Handling
import { getGroupCluster } from "@distilled.cloud/mongodb-atlas/Operations";
getGroupCluster({ groupId: "my-project", clusterName: "missing" }).pipe(
Effect.catchTags({
NotFound: () => Effect.succeed(null),
UnknownMongodbAtlasError: (e) => Effect.fail(new Error(`Unknown: ${e.message}`)),
}),
);Services
Key operation areas include:
- Clusters -- create, update, delete, status, process args, global writes, performance advisor
- Flex Clusters -- create, update, delete, backups, restore, upgrade
- Database Users -- CRUD, certificates
- Groups (Projects) -- CRUD, settings, limits, events, teams, users, API keys
- Organizations -- CRUD, settings, billing, invoices, federation, teams, users
- Backups -- compliance policies, snapshots, restore jobs, export buckets, schedules
- Network -- VPC peering, containers, private endpoints, encryption at rest
- Search -- Atlas Search indexes and deployments
- Streams -- Atlas Stream Processing workspaces, connections, processors
- Data Federation -- create, update, query logs, limits
- Alerts -- alert configurations, acknowledgment
- Live Migrations -- create, validate, cutover
- Integrations -- third-party and log integrations
- Auditing -- audit log configuration
License
MIT
