/* Copyright 2010-present MongoDB Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using MongoDB.Bson; using MongoDB.Driver.Core.Clusters; namespace MongoDB.Driver { /// /// The client interface to MongoDB. /// public interface IMongoClient : IDisposable { /// /// Gets the cluster. /// /// /// The cluster. /// ICluster Cluster { get; } /// /// Gets the settings. /// MongoClientSettings Settings { get; } /// /// Executes a list of mixed write operations. /// /// List of operations to execute. /// The bulk write options. /// The cancellation token. ClientBulkWriteResult BulkWrite(IReadOnlyList models, ClientBulkWriteOptions options = null, CancellationToken cancellationToken = default); /// /// Executes a list of mixed write operations. /// /// The session. /// List of operations to execute. /// The bulk write options. /// The cancellation token. ClientBulkWriteResult BulkWrite(IClientSessionHandle session, IReadOnlyList models, ClientBulkWriteOptions options = null, CancellationToken cancellationToken = default); /// /// Executes a list of mixed write operations. /// /// List of operations to execute. /// The bulk write options. /// The cancellation token. Task BulkWriteAsync(IReadOnlyList models, ClientBulkWriteOptions options = null, CancellationToken cancellationToken = default); /// /// Executes a list of mixed write operations. /// /// The session. /// List of operations to execute. /// The bulk write options. /// The cancellation token. Task BulkWriteAsync(IClientSessionHandle session, IReadOnlyList models, ClientBulkWriteOptions options = null, CancellationToken cancellationToken = default); /// /// Drops the database with the specified name. /// /// The name of the database to drop. /// The cancellation token. void DropDatabase(string name, CancellationToken cancellationToken = default(CancellationToken)); /// /// Drops the database with the specified name. /// /// The session. /// The name of the database to drop. /// The cancellation token. void DropDatabase(IClientSessionHandle session, string name, CancellationToken cancellationToken = default(CancellationToken)); /// /// Drops the database with the specified name. /// /// The name of the database to drop. /// The cancellation token. /// A task. Task DropDatabaseAsync(string name, CancellationToken cancellationToken = default(CancellationToken)); /// /// Drops the database with the specified name. /// /// The session. /// The name of the database to drop. /// The cancellation token. /// /// A task. /// Task DropDatabaseAsync(IClientSessionHandle session, string name, CancellationToken cancellationToken = default(CancellationToken)); /// /// Gets a database. /// /// The name of the database. /// The database settings. /// An implementation of a database. IMongoDatabase GetDatabase(string name, MongoDatabaseSettings settings = null); /// /// Returns the names of the databases on the server. /// /// The cancellation token. /// The database names. IAsyncCursor ListDatabaseNames( CancellationToken cancellationToken = default(CancellationToken)); /// /// Returns the names of the databases on the server. /// /// The cancellation token. /// The options. /// The database names. IAsyncCursor ListDatabaseNames( ListDatabaseNamesOptions options, CancellationToken cancellationToken = default(CancellationToken)); /// /// Returns the names of the databases on the server. /// /// The session. /// The cancellation token. /// The database names. IAsyncCursor ListDatabaseNames( IClientSessionHandle session, CancellationToken cancellationToken = default(CancellationToken)); /// /// Returns the names of the databases on the server. /// /// The session. /// The options. /// The cancellation token. /// The database names. IAsyncCursor ListDatabaseNames( IClientSessionHandle session, ListDatabaseNamesOptions options, CancellationToken cancellationToken = default(CancellationToken)); /// /// Returns the names of the databases on the server. /// /// The cancellation token. /// The database names. Task> ListDatabaseNamesAsync( CancellationToken cancellationToken = default(CancellationToken)); /// /// Returns the names of the databases on the server. /// /// The options. /// The cancellation token. /// The database names. Task> ListDatabaseNamesAsync( ListDatabaseNamesOptions options, CancellationToken cancellationToken = default(CancellationToken)); /// /// Returns the names of the databases on the server. /// /// The session. /// The cancellation token. /// The database names. Task> ListDatabaseNamesAsync( IClientSessionHandle session, CancellationToken cancellationToken = default(CancellationToken)); /// /// Returns the names of the databases on the server. /// /// The session. /// The options. /// The cancellation token. /// The database names. Task> ListDatabaseNamesAsync( IClientSessionHandle session, ListDatabaseNamesOptions options, CancellationToken cancellationToken = default(CancellationToken)); /// /// Lists the databases on the server. /// /// The cancellation token. /// A cursor. IAsyncCursor ListDatabases( CancellationToken cancellationToken = default(CancellationToken)); /// /// Lists the databases on the server. /// /// The options. /// The cancellation token. /// A cursor. IAsyncCursor ListDatabases( ListDatabasesOptions options, CancellationToken cancellationToken = default(CancellationToken)); /// /// Lists the databases on the server. /// /// The session. /// The cancellation token. /// /// A cursor. /// IAsyncCursor ListDatabases( IClientSessionHandle session, CancellationToken cancellationToken = default(CancellationToken)); /// /// Lists the databases on the server. /// /// The session. /// The options. /// The cancellation token. /// /// A cursor. /// IAsyncCursor ListDatabases( IClientSessionHandle session, ListDatabasesOptions options, CancellationToken cancellationToken = default(CancellationToken)); /// /// Lists the databases on the server. /// /// The cancellation token. /// A Task whose result is a cursor. Task> ListDatabasesAsync( CancellationToken cancellationToken = default(CancellationToken)); /// /// Lists the databases on the server. /// /// The cancellation token. /// The options. /// A Task whose result is a cursor. Task> ListDatabasesAsync( ListDatabasesOptions options, CancellationToken cancellationToken = default(CancellationToken)); /// /// Lists the databases on the server. /// /// The session. /// The cancellation token. /// /// A Task whose result is a cursor. /// Task> ListDatabasesAsync( IClientSessionHandle session, CancellationToken cancellationToken = default(CancellationToken)); /// /// Lists the databases on the server. /// /// The session. /// The options. /// The cancellation token. /// /// A Task whose result is a cursor. /// Task> ListDatabasesAsync( IClientSessionHandle session, ListDatabasesOptions options, CancellationToken cancellationToken = default(CancellationToken)); /// /// Starts a client session. /// /// The session options. /// The cancellation token. /// /// A client session. /// IClientSessionHandle StartSession(ClientSessionOptions options = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Starts a client session. /// /// The session options. /// The cancellation token. /// /// A Task whose result is a client session. /// Task StartSessionAsync(ClientSessionOptions options = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Watches changes on all collections in all databases. /// /// The type of the result. /// The pipeline. /// The options. /// The cancellation token. /// /// A change stream. /// IChangeStreamCursor Watch( PipelineDefinition, TResult> pipeline, ChangeStreamOptions options = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Watches changes on all collections in all databases. /// /// The type of the result. /// The session. /// The pipeline. /// The options. /// The cancellation token. /// /// A change stream. /// IChangeStreamCursor Watch( IClientSessionHandle session, PipelineDefinition, TResult> pipeline, ChangeStreamOptions options = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Watches changes on all collections in all databases. /// /// The type of the result. /// The pipeline. /// The options. /// The cancellation token. /// /// A change stream. /// Task> WatchAsync( PipelineDefinition, TResult> pipeline, ChangeStreamOptions options = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Watches changes on all collections in all databases. /// /// The type of the result. /// The session. /// The pipeline. /// The options. /// The cancellation token. /// /// A change stream. /// Task> WatchAsync( IClientSessionHandle session, PipelineDefinition, TResult> pipeline, ChangeStreamOptions options = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Returns a new IMongoClient instance with a different read concern setting. /// /// The read concern. /// A new IMongoClient instance with a different read concern setting. IMongoClient WithReadConcern(ReadConcern readConcern); /// /// Returns a new IMongoClient instance with a different read preference setting. /// /// The read preference. /// A new IMongoClient instance with a different read preference setting. IMongoClient WithReadPreference(ReadPreference readPreference); /// /// Returns a new IMongoClient instance with a different write concern setting. /// /// The write concern. /// A new IMongoClient instance with a different write concern setting. IMongoClient WithWriteConcern(WriteConcern writeConcern); } }