All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.thunderz99.cosmos.Cosmos Maven / Gradle / Ivy

There is a newer version: 0.7.11
Show newest version
package io.github.thunderz99.cosmos;

import io.github.thunderz99.cosmos.dto.CosmosContainerResponse;
import io.github.thunderz99.cosmos.dto.UniqueKeyPolicy;

/***
 * class that represent a cosmos account
 *
 * 
 * Usage: var cosmos = CosmosFactory.create
 *   ("AccountEndpoint=https://xxx.documents.azure.com:443/;AccountKey=xxx==;");
 * var db = cosmos.getDatabase("Database1");
 *
 * //Then use db to do CRUD / query db.upsert("Users", user);
 * 
* */ public interface Cosmos { /** * Get a CosmosDatabase object by name * * @param db database name * @return CosmosDatabase instance */ public CosmosDatabase getDatabase(String db); /** * Create the db and coll if not exist. Coll creation will be skipped if empty. uniqueKeyPolicy can be specified. * * @param db database name * @param coll collection name * @param uniqueKeyPolicy unique key policy for the collection * @return CosmosDatabase instance * @throws CosmosException Cosmos client exception */ public CosmosDatabase createIfNotExist(String db, String coll, UniqueKeyPolicy uniqueKeyPolicy) throws CosmosException; /** * Create the db and coll if not exist. Coll creation will be skipped if empty. * *

* No uniqueKeyPolicy will be used. *

* * @param db database name * @param coll collection name * @return CosmosDatabase instance * @throws CosmosException Cosmos client exception Cosmos client exception */ public CosmosDatabase createIfNotExist(String db, String coll) throws CosmosException; /** * Delete a database by name * * @param db database name * @throws CosmosException Cosmos client exception */ public void deleteDatabase(String db) throws CosmosException; /** * Delete a collection by db name and coll name * * @param db database name * @param coll collection name * @throws CosmosException Cosmos client exception */ public void deleteCollection(String db, String coll) throws CosmosException; /** * Read the document collection obj by dbName and collName. * * @param db dbName * @param coll collName * @return CosmosContainerResponse obj * @throws CosmosException when client exception occurs */ public CosmosContainerResponse readCollection(String db, String coll) throws CosmosException; /** * Get the account / cluster name * * @return account / cluster name * @throws CosmosException */ public String getAccount() throws CosmosException; /** * Get the database type("cosmosdb" or "mongodb") * * @return databaseType */ public String getDatabaseType(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy