/* 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.Bson.Serialization;
namespace MongoDB.Driver
{
///
/// An interface representing methods used to create, delete and modify indexes.
///
///
/// This interface is not guaranteed to remain stable. Implementors should use
/// .
///
/// The type of the document.
public interface IMongoIndexManager
{
///
/// Gets the namespace of the collection.
///
CollectionNamespace CollectionNamespace { get; }
///
/// Gets the document serializer.
///
IBsonSerializer DocumentSerializer { get; }
///
/// Gets the collection settings.
///
MongoCollectionSettings Settings { get; }
///
/// Creates multiple indexes.
///
/// The models defining each of the indexes.
/// The cancellation token.
///
/// An of the names of the indexes that were created.
///
IEnumerable CreateMany(IEnumerable> models, CancellationToken cancellationToken = default(CancellationToken));
///
/// Creates multiple indexes.
///
/// The models defining each of the indexes.
/// The options for create multiple indexes.
/// The cancellation token.
///
/// An of the names of the indexes that were created.
///
IEnumerable CreateMany(
IEnumerable> models,
CreateManyIndexesOptions options,
CancellationToken cancellationToken = default(CancellationToken));
///
/// Creates multiple indexes.
///
/// The session.
/// The models defining each of the indexes.
/// The cancellation token.
///
/// An of the names of the indexes that were created.
///
IEnumerable CreateMany(IClientSessionHandle session, IEnumerable> models, CancellationToken cancellationToken = default(CancellationToken));
///
/// Creates multiple indexes.
///
/// The session.
/// The models defining each of the indexes.
/// The options for create multiple indexes.
/// The cancellation token.
///
/// An of the names of the indexes that were created.
///
IEnumerable CreateMany(
IClientSessionHandle session,
IEnumerable> models,
CreateManyIndexesOptions options,
CancellationToken cancellationToken = default(CancellationToken));
///
/// Creates multiple indexes.
///
/// The models defining each of the indexes.
/// The cancellation token.
///
/// A task whose result is an of the names of the indexes that were created.
///
Task> CreateManyAsync(IEnumerable> models, CancellationToken cancellationToken = default(CancellationToken));
///
/// Creates multiple indexes.
///
/// The models defining each of the indexes.
/// The options for create multiple indexes.
/// The cancellation token.
///
/// A task whose result is an of the names of the indexes that were created.
///
Task> CreateManyAsync(
IEnumerable> models,
CreateManyIndexesOptions options,
CancellationToken cancellationToken = default(CancellationToken));
///
/// Creates multiple indexes.
///
/// The session.
/// The models defining each of the indexes.
/// The cancellation token.
///
/// A task whose result is an of the names of the indexes that were created.
///
Task> CreateManyAsync(IClientSessionHandle session, IEnumerable> models, CancellationToken cancellationToken = default(CancellationToken));
///
/// Creates multiple indexes.
///
/// The session.
/// The models defining each of the indexes.
/// The options for create multiple indexes.
/// The cancellation token.
///
/// A task whose result is an of the names of the indexes that were created.
///
Task> CreateManyAsync(
IClientSessionHandle session,
IEnumerable> models,
CreateManyIndexesOptions options,
CancellationToken cancellationToken = default(CancellationToken));
///
/// Creates an index.
///
/// The model defining the index.
/// The create index operation options.
/// The cancellation token.
///
/// The name of the index that was created.
///
string CreateOne(
CreateIndexModel model,
CreateOneIndexOptions options = null,
CancellationToken cancellationToken = default(CancellationToken));
///
/// Creates an index.
///
/// The keys.
/// The create index request options.
/// The cancellation token.
///
/// The name of the index that was created.
///
[Obsolete("Use CreateOne with a CreateIndexModel instead.")]
string CreateOne(IndexKeysDefinition keys, CreateIndexOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Creates an index.
///
/// The session.
/// The keys.
/// The create index request options.
/// The cancellation token.
///
/// The name of the index that was created.
///
[Obsolete("Use CreateOne with a CreateIndexModel instead.")]
string CreateOne(IClientSessionHandle session, IndexKeysDefinition keys, CreateIndexOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Creates an index.
///
/// The session.
/// The model defining the index.
/// The create index operation options.
/// The cancellation token.
///
/// The name of the index that was created.
///
string CreateOne(
IClientSessionHandle session,
CreateIndexModel model,
CreateOneIndexOptions options = null,
CancellationToken cancellationToken = default(CancellationToken));
///
/// Creates an index.
///
/// The model defining the index.
/// The create index operation options.
/// The cancellation token.
///
/// A task whose result is the name of the index that was created.
///
Task CreateOneAsync(
CreateIndexModel model,
CreateOneIndexOptions options = null,
CancellationToken cancellationToken = default(CancellationToken));
///
/// Creates an index.
///
/// The keys.
/// The create index request options.
/// The cancellation token.
///
/// A task whose result is the name of the index that was created.
///
[Obsolete("Use CreateOneAsync with a CreateIndexModel instead.")]
Task CreateOneAsync(IndexKeysDefinition keys, CreateIndexOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Creates an index.
///
/// The session.
/// The keys.
/// The create index request options.
/// The cancellation token.
///
/// A task whose result is the name of the index that was created.
///
[Obsolete("Use CreateOneAsyc with a CreateIndexModel instead.")]
Task CreateOneAsync(IClientSessionHandle session, IndexKeysDefinition keys, CreateIndexOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Creates an index.
///
/// The session.
/// The model defining the index.
/// The create index operation options.
/// The cancellation token.
///
/// A task whose result is the name of the index that was created.
///
Task CreateOneAsync(
IClientSessionHandle session,
CreateIndexModel model,
CreateOneIndexOptions options = null,
CancellationToken cancellationToken = default(CancellationToken));
///
/// Drops all the indexes.
///
/// The options.
/// The cancellation token.
void DropAll(DropIndexOptions options, CancellationToken cancellationToken = default(CancellationToken));
///
/// Drops all the indexes.
///
/// The cancellation token.
void DropAll(CancellationToken cancellationToken = default(CancellationToken));
///
/// Drops all the indexes.
///
/// The session.
/// The cancellation token.
void DropAll(IClientSessionHandle session, CancellationToken cancellationToken = default(CancellationToken));
///
/// Drops all the indexes.
///
/// The session.
/// The options.
/// The cancellation token.
void DropAll(IClientSessionHandle session, DropIndexOptions options, CancellationToken cancellationToken = default(CancellationToken));
///
/// Drops all the indexes.
///
/// The options.
/// The cancellation token.
///
/// A task.
///
Task DropAllAsync(DropIndexOptions options, CancellationToken cancellationToken = default(CancellationToken));
///
/// Drops all the indexes.
///
/// The cancellation token.
/// A task.
Task DropAllAsync(CancellationToken cancellationToken = default(CancellationToken));
///
/// Drops all the indexes.
///
/// The session.
/// The cancellation token.
///
/// A task.
///
Task DropAllAsync(IClientSessionHandle session, CancellationToken cancellationToken = default(CancellationToken));
///
/// Drops all the indexes.
///
/// The session.
/// The options.
/// The cancellation token.
///
/// A task.
///
Task DropAllAsync(IClientSessionHandle session, DropIndexOptions options, CancellationToken cancellationToken = default(CancellationToken));
///
/// Drops an index by its name.
///
/// The name.
/// The cancellation token.
void DropOne(string name, CancellationToken cancellationToken = default(CancellationToken));
///
/// Drops an index by its name.
///
/// The name.
/// The options.
/// The cancellation token.
void DropOne(string name, DropIndexOptions options, CancellationToken cancellationToken = default(CancellationToken));
///
/// Drops an index by its name.
///
/// The session.
/// The name.
/// The cancellation token.
void DropOne(IClientSessionHandle session, string name, CancellationToken cancellationToken = default(CancellationToken));
///
/// Drops an index by its name.
///
/// The session.
/// The name.
/// The options.
/// The cancellation token.
void DropOne(IClientSessionHandle session, string name, DropIndexOptions options, CancellationToken cancellationToken = default(CancellationToken));
///
/// Drops an index by its name.
///
/// The name.
/// The cancellation token.
/// A task.
Task DropOneAsync(string name, CancellationToken cancellationToken = default(CancellationToken));
///
/// Drops an index by its name.
///
/// The name.
/// The options.
/// The cancellation token.
/// A task.
Task DropOneAsync(string name, DropIndexOptions options, CancellationToken cancellationToken = default(CancellationToken));
///
/// Drops an index by its name.
///
/// The session.
/// The name.
/// The cancellation token.
///
/// A task.
///
Task DropOneAsync(IClientSessionHandle session, string name, CancellationToken cancellationToken = default(CancellationToken));
///
/// Drops an index by its name.
///
/// The session.
/// The name.
/// The options.
/// The cancellation token.
///
/// A task.
///
Task DropOneAsync(IClientSessionHandle session, string name, DropIndexOptions options, CancellationToken cancellationToken = default(CancellationToken));
///
/// Lists the indexes.
///
/// The cancellation token.
/// A cursor.
IAsyncCursor List(CancellationToken cancellationToken = default(CancellationToken));
///
/// Lists the indexes.
///
/// The session.
/// The cancellation token.
///
/// A cursor.
///
IAsyncCursor List(IClientSessionHandle session, CancellationToken cancellationToken = default(CancellationToken));
///
/// Lists the indexes.
///
/// The cancellation token.
/// A Task whose result is a cursor.
Task> ListAsync(CancellationToken cancellationToken = default(CancellationToken));
///
/// Lists the indexes.
///
/// The session.
/// The cancellation token.
///
/// A Task whose result is a cursor.
///
Task> ListAsync(IClientSessionHandle session, CancellationToken cancellationToken = default(CancellationToken));
}
}