Skip to content

Commit

Permalink
Revert encryption GA (#2826)
Browse files Browse the repository at this point in the history
  • Loading branch information
j82w authored Oct 29, 2021
1 parent 45c0afc commit b73ed61
Show file tree
Hide file tree
Showing 19 changed files with 750 additions and 620 deletions.
7 changes: 6 additions & 1 deletion Microsoft.Azure.Cosmos/src/CosmosClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,12 @@ internal CosmosClient(
/// a custom container that modifies the response. For example the client encryption
/// uses this to decrypt responses before returning to the caller.
/// </remarks>
public virtual CosmosResponseFactory ResponseFactory => this.ClientContext.ResponseFactory;
#if PREVIEW
public
#else
internal
#endif
virtual CosmosResponseFactory ResponseFactory => this.ClientContext.ResponseFactory;

/// <summary>
/// Gets the endpoint Uri for the Azure Cosmos DB service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@
namespace Microsoft.Azure.Cosmos.Fluent
{
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;

/// <summary>
/// <see cref="ClientEncryptionPolicy"/> fluent definition.
/// </summary>
public sealed class ClientEncryptionPolicyDefinition
#if PREVIEW
public
#else
internal
#endif
sealed class ClientEncryptionPolicyDefinition
{
private readonly Collection<ClientEncryptionIncludedPath> clientEncryptionIncludedPaths = new Collection<ClientEncryptionIncludedPath>();
private readonly ContainerBuilder parent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,12 @@ ChangeFeedPolicyDefinition WithChangeFeedPolicy(TimeSpan retention)
/// Defines the ClientEncryptionPolicy for Azure Cosmos container
/// </summary>
/// <returns>An instance of <see cref="ClientEncryptionPolicyDefinition"/>.</returns>
public ClientEncryptionPolicyDefinition WithClientEncryptionPolicy()
#if PREVIEW
public
#else
internal
#endif
ClientEncryptionPolicyDefinition WithClientEncryptionPolicy()
{
return new ClientEncryptionPolicyDefinition(
this,
Expand Down
11 changes: 10 additions & 1 deletion Microsoft.Azure.Cosmos/src/Handler/ResponseMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ namespace Microsoft.Azure.Cosmos
/// </summary>
public class ResponseMessage : IDisposable
{
#if PREVIEW
private CosmosDiagnostics diagnostics = null;
#endif

/// <summary>
/// Create a <see cref="ResponseMessage"/>
Expand Down Expand Up @@ -130,14 +132,21 @@ public virtual Stream Content
/// </summary>
public virtual RequestMessage RequestMessage { get; internal set; }

#if PREVIEW
/// <summary>
/// Gets or sets the cosmos diagnostic information for the current request to Azure Cosmos DB service
/// Gets the cosmos diagnostic information for the current request to Azure Cosmos DB service
/// </summary>
public virtual CosmosDiagnostics Diagnostics
{
get => this.diagnostics ?? new CosmosTraceDiagnostics(this.Trace ?? NoOpTrace.Singleton);
set => this.diagnostics = value ?? throw new ArgumentNullException(nameof(this.Diagnostics));
}
#else
/// <summary>
/// Gets the cosmos diagnostic information for the current request to Azure Cosmos DB service
/// </summary>
public virtual CosmosDiagnostics Diagnostics => new CosmosTraceDiagnostics(this.Trace ?? NoOpTrace.Singleton);
#endif

internal ITrace Trace { get; set; }

Expand Down
14 changes: 12 additions & 2 deletions Microsoft.Azure.Cosmos/src/RequestOptions/RequestOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,15 @@ public class RequestOptions
/// </summary>
public IReadOnlyDictionary<string, object> Properties { get; set; }

#if PREVIEW
/// <summary>
/// Gets or sets a delegate which injects/appends a custom header in the request.
/// </summary>
public Action<Headers> AddRequestHeaders { get; set; }
public
#else
internal
#endif
Action<Headers> AddRequestHeaders { get; set; }

/// <summary>
/// Gets or sets the boolean to use effective partition key routing in the cosmos db request.
Expand Down Expand Up @@ -88,11 +93,16 @@ internal virtual void PopulateRequestOptions(RequestMessage request)
this.AddRequestHeaders?.Invoke(request.Headers);
}

#if PREVIEW
/// <summary>
/// Clone RequestOptions.
/// </summary>
/// <returns> cloned RequestOptions. </returns>
public RequestOptions ShallowCopy()
public
#else
internal
#endif
RequestOptions ShallowCopy()
{
return this.MemberwiseClone() as RequestOptions;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ namespace Microsoft.Azure.Cosmos
/// See <see cref="Database"/> for operations to create and enumerate client encryption keys.
/// See https://aka.ms/CosmosClientEncryption for more information on client-side encryption support in Azure Cosmos DB.
/// </summary>
public abstract class ClientEncryptionKey
#if PREVIEW
public
#else
internal
#endif
abstract class ClientEncryptionKey
{
/// <summary>
/// The unique identifier of the client encryption key.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ namespace Microsoft.Azure.Cosmos
/// <summary>
/// Details of an encryption key for use with the Azure Cosmos DB service.
/// </summary>
public class ClientEncryptionKeyProperties : IEquatable<ClientEncryptionKeyProperties>
#if PREVIEW
public
#else
internal
#endif
class ClientEncryptionKeyProperties : IEquatable<ClientEncryptionKeyProperties>
{
/// <summary>
/// Initializes a new instance of <see cref="ClientEncryptionKeyProperties"/>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ namespace Microsoft.Azure.Cosmos
/// <summary>
/// Response from the Cosmos DB service for a <see cref="Cosmos.ClientEncryptionKey"/> related request.
/// </summary>
public class ClientEncryptionKeyResponse : Response<ClientEncryptionKeyProperties>
#if PREVIEW
public
#else
internal
#endif
class ClientEncryptionKeyResponse : Response<ClientEncryptionKeyProperties>
{
/// <summary>
/// Creates a client encryption key response as a no-op for mock testing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ namespace Microsoft.Azure.Cosmos
/// <summary>
/// Metadata that a key wrapping provider can use to wrap/unwrap data encryption keys.
/// </summary>
public class EncryptionKeyWrapMetadata : IEquatable<EncryptionKeyWrapMetadata>
#if PREVIEW
public
#else
internal
#endif
class EncryptionKeyWrapMetadata : IEquatable<EncryptionKeyWrapMetadata>
{
// For JSON deserialize
private EncryptionKeyWrapMetadata()
Expand Down
7 changes: 6 additions & 1 deletion Microsoft.Azure.Cosmos/src/Resource/CosmosResponseFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ namespace Microsoft.Azure.Cosmos
/// to the corresponding type response using the
/// CosmosClient serializer
/// </summary>
public abstract class CosmosResponseFactory
#if PREVIEW
public
#else
internal
#endif
abstract class CosmosResponseFactory
{
/// <summary>
/// Creates a FeedResponse from a response message
Expand Down
2 changes: 2 additions & 0 deletions Microsoft.Azure.Cosmos/src/Resource/Database/Database.cs
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,7 @@ public abstract ContainerBuilder DefineContainer(
string name,
string partitionKeyPath);

#if PREVIEW
/// <summary>
/// Returns a reference to a client encryption key object.
/// This method is not meant to be invoked directly. Please see https://aka.ms/CosmosClientEncryption in order to use client-side encryption.
Expand Down Expand Up @@ -1029,5 +1030,6 @@ public abstract Task<ClientEncryptionKeyResponse> CreateClientEncryptionKeyAsync
ClientEncryptionKeyProperties clientEncryptionKeyProperties,
RequestOptions requestOptions = null,
CancellationToken cancellationToken = default);
#endif
}
}
27 changes: 21 additions & 6 deletions Microsoft.Azure.Cosmos/src/Resource/Database/DatabaseCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,12 @@ public override ContainerBuilder DefineContainer(
return new ContainerBuilder(this, name, partitionKeyPath);
}

public override ClientEncryptionKey GetClientEncryptionKey(string id)
#if PREVIEW
public override
#else
internal virtual
#endif
ClientEncryptionKey GetClientEncryptionKey(string id)
{
if (string.IsNullOrEmpty(id))
{
Expand All @@ -697,10 +702,15 @@ public override ClientEncryptionKey GetClientEncryptionKey(string id)
id);
}

public override FeedIterator<ClientEncryptionKeyProperties> GetClientEncryptionKeyQueryIterator(
QueryDefinition queryDefinition,
string continuationToken = null,
QueryRequestOptions requestOptions = null)
#if PREVIEW
public override
#else
internal virtual
#endif
FeedIterator<ClientEncryptionKeyProperties> GetClientEncryptionKeyQueryIterator(
QueryDefinition queryDefinition,
string continuationToken = null,
QueryRequestOptions requestOptions = null)
{
if (!(this.GetClientEncryptionKeyQueryStreamIterator(
queryDefinition: queryDefinition,
Expand Down Expand Up @@ -733,7 +743,12 @@ private FeedIterator GetClientEncryptionKeyQueryStreamIterator(
options: requestOptions);
}

public async Task<ClientEncryptionKeyResponse> CreateClientEncryptionKeyAsync(
#if PREVIEW
public
#else
internal virtual
#endif
async Task<ClientEncryptionKeyResponse> CreateClientEncryptionKeyAsync(
ITrace trace,
ClientEncryptionKeyProperties clientEncryptionKeyProperties,
RequestOptions requestOptions = null,
Expand Down
33 changes: 24 additions & 9 deletions Microsoft.Azure.Cosmos/src/Resource/Database/DatabaseInlineCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -305,23 +305,38 @@ public override Task<UserResponse> UpsertUserAsync(
(trace) => base.UpsertUserAsync(id, requestOptions, trace, cancellationToken));
}

public override ClientEncryptionKey GetClientEncryptionKey(string id)
#if PREVIEW
public
#else
internal
#endif
override ClientEncryptionKey GetClientEncryptionKey(string id)
{
return base.GetClientEncryptionKey(id);
}

public override FeedIterator<ClientEncryptionKeyProperties> GetClientEncryptionKeyQueryIterator(
QueryDefinition queryDefinition,
string continuationToken = null,
QueryRequestOptions requestOptions = null)
#if PREVIEW
public
#else
internal
#endif
override FeedIterator<ClientEncryptionKeyProperties> GetClientEncryptionKeyQueryIterator(
QueryDefinition queryDefinition,
string continuationToken = null,
QueryRequestOptions requestOptions = null)
{
return base.GetClientEncryptionKeyQueryIterator(queryDefinition, continuationToken, requestOptions);
}

public override Task<ClientEncryptionKeyResponse> CreateClientEncryptionKeyAsync(
ClientEncryptionKeyProperties clientEncryptionKeyProperties,
RequestOptions requestOptions = null,
CancellationToken cancellationToken = default)
#if PREVIEW
public override
#else
internal
#endif
Task<ClientEncryptionKeyResponse> CreateClientEncryptionKeyAsync(
ClientEncryptionKeyProperties clientEncryptionKeyProperties,
RequestOptions requestOptions = null,
CancellationToken cancellationToken = default)
{
return this.ClientContext.OperationHelperAsync(
nameof(CreateClientEncryptionKeyAsync),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ namespace Microsoft.Azure.Cosmos
/// <summary>
/// Path that needs encryption and the associated settings within <see cref="ClientEncryptionPolicy"/>.
/// </summary>
public sealed class ClientEncryptionIncludedPath
#if PREVIEW
public
#else
internal
#endif
sealed class ClientEncryptionIncludedPath
{
/// <summary>
/// Gets or sets the path to be encrypted. Must be a top level path, eg. /salary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ namespace Microsoft.Azure.Cosmos
/// <summary>
/// Client encryption policy.
/// </summary>
public sealed class ClientEncryptionPolicy
#if PREVIEW
public
#else
internal
#endif
sealed class ClientEncryptionPolicy
{
/// <summary>
/// Initializes a new instance of the <see cref="ClientEncryptionPolicy"/> class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ public UniqueKeyPolicy UniqueKeyPolicy
public DateTime? LastModified { get; private set; }

/// <summary>
/// Gets or sets the client encryption policy information for storing items in a container from the Azure Cosmos service.
/// Gets the client encryption policy information for storing items in a container from the Azure Cosmos service.
/// </summary>
/// <value>
/// It is an optional property.
Expand All @@ -258,7 +258,12 @@ public UniqueKeyPolicy UniqueKeyPolicy
/// </para>
/// </remarks>
[JsonIgnore]
public ClientEncryptionPolicy ClientEncryptionPolicy
#if PREVIEW
public
#else
internal
#endif
ClientEncryptionPolicy ClientEncryptionPolicy
{
get => this.clientEncryptionPolicyInternal;

Expand Down
Loading

0 comments on commit b73ed61

Please sign in to comment.