From 7b298496d2914272738c997157f4c55d2c0a05a5 Mon Sep 17 00:00:00 2001 From: Tanyi Chen Date: Thu, 5 Mar 2020 17:10:06 +0800 Subject: [PATCH] Minor fix for cosmos db according to comments (#995) * fix: throughput format to throughput toString * fix: WithCompositeIndexEmptyList to WithNewCompositeIndexList * fix: has failover policy change to is failover loaded, and change some comments --- Tests/Fluent.Tests/CosmosDB/CosmosDBTest.cs | 2 +- .../CosmosDB/CassandraKeyspaceImpl.cs | 2 +- .../CosmosDB/CassandraTableImpl.cs | 2 +- .../CosmosDB/CosmosDBAccountImpl.cs | 16 ++++++++-------- .../CosmosDBAccount/Definition/IDefinition.cs | 10 +++++----- .../Domain/CosmosDBAccount/Update/IUpdate.cs | 10 +++++----- .../IndexingPolicy/Definition/IDefinition.cs | 2 +- .../Domain/IndexingPolicy/Update/IUpdate.cs | 2 +- .../Domain/InterfaceImpl/CosmosDBAccountImpl.cs | 4 ++-- .../Domain/InterfaceImpl/IndexingPolicyImpl.cs | 8 ++++---- .../CosmosDB/GremlinDatabaseImpl.cs | 2 +- .../CosmosDB/GremlinGraphImpl.cs | 2 +- .../CosmosDB/IndexingPolicyImpl.cs | 2 +- .../CosmosDB/MongoCollectionImpl.cs | 2 +- src/ResourceManagement/CosmosDB/MongoDBImpl.cs | 2 +- .../CosmosDB/SqlContainerImpl.cs | 2 +- .../CosmosDB/SqlDatabaseImpl.cs | 2 +- src/ResourceManagement/CosmosDB/TableImpl.cs | 2 +- 18 files changed, 37 insertions(+), 37 deletions(-) diff --git a/Tests/Fluent.Tests/CosmosDB/CosmosDBTest.cs b/Tests/Fluent.Tests/CosmosDB/CosmosDBTest.cs index cea73ed78..b7787a839 100644 --- a/Tests/Fluent.Tests/CosmosDB/CosmosDBTest.cs +++ b/Tests/Fluent.Tests/CosmosDB/CosmosDBTest.cs @@ -303,7 +303,7 @@ public void CanCRUDSqlContainer() .WithIndexingMode(IndexingMode.Consistent) .WithIncludedPath("/*") .WithExcludedPath("/myPathToNotIndex/*") - .WithCompositeIndexEmptyList() + .WithNewCompositeIndexList() .WithCompositePath("/myOrderByPath1", CompositePathSortOrder.Ascending) .WithCompositePath("/myOrderByPath2", CompositePathSortOrder.Descending) .Attach() diff --git a/src/ResourceManagement/CosmosDB/CassandraKeyspaceImpl.cs b/src/ResourceManagement/CosmosDB/CassandraKeyspaceImpl.cs index 99228d445..763954adc 100644 --- a/src/ResourceManagement/CosmosDB/CassandraKeyspaceImpl.cs +++ b/src/ResourceManagement/CosmosDB/CassandraKeyspaceImpl.cs @@ -109,7 +109,7 @@ public CassandraKeyspaceImpl WithoutOptions() public CassandraKeyspaceImpl WithThroughput(int throughput) { - this.createUpdateParameters.Options.Throughput = $"{throughput}"; + this.createUpdateParameters.Options.Throughput = throughput.ToString(); return this; } diff --git a/src/ResourceManagement/CosmosDB/CassandraTableImpl.cs b/src/ResourceManagement/CosmosDB/CassandraTableImpl.cs index 586e8af2a..f3523a3b8 100644 --- a/src/ResourceManagement/CosmosDB/CassandraTableImpl.cs +++ b/src/ResourceManagement/CosmosDB/CassandraTableImpl.cs @@ -160,7 +160,7 @@ public CassandraTableImpl WithoutOptions() public CassandraTableImpl WithThroughput(int throughput) { - this.createUpdateParameters.Options.Throughput = $"{throughput}"; + this.createUpdateParameters.Options.Throughput = throughput.ToString(); return this; } diff --git a/src/ResourceManagement/CosmosDB/CosmosDBAccountImpl.cs b/src/ResourceManagement/CosmosDB/CosmosDBAccountImpl.cs index d48167b1e..9cf91efb8 100644 --- a/src/ResourceManagement/CosmosDB/CosmosDBAccountImpl.cs +++ b/src/ResourceManagement/CosmosDB/CosmosDBAccountImpl.cs @@ -32,7 +32,7 @@ public partial class CosmosDBAccountImpl : IUpdate { private IList failoverPolicies; - private bool hasFailoverPolicyChanges; + private bool isFailoverPolicyLoaded; private const int maxDelayDueToMissingFailovers = 5000 * 12 * 10; private Dictionary> virtualNetworkRulesMap; private PrivateEndpointConnectionsImpl privateEndpointConnections; @@ -61,7 +61,7 @@ public CosmosDBAccountImpl WithReadReplication(Region region, bool? isZoneRedund FailoverPolicy.LocationName = region.Name; FailoverPolicy.IsZoneRedundant = isZoneRedundant; FailoverPolicy.FailoverPriority = this.failoverPolicies.Count; - this.hasFailoverPolicyChanges = true; + this.isFailoverPolicyLoaded = true; this.failoverPolicies.Add(FailoverPolicy); return this; } @@ -69,7 +69,7 @@ public CosmosDBAccountImpl WithReadReplication(Region region, bool? isZoneRedund public CosmosDBAccountImpl WithoutAllReplications() { this.failoverPolicies.Clear(); - this.hasFailoverPolicyChanges = true; + this.isFailoverPolicyLoaded = true; return this; } @@ -96,7 +96,7 @@ await this.Manager.Inner.DatabaseAccounts.UpdateAsync( locationParameters = new UpdateLocationParameters(updateParametersInner); } this.failoverPolicies.Clear(); - this.hasFailoverPolicyChanges = false; + this.isFailoverPolicyLoaded = false; bool done = false; ICosmosDBAccount databaseAccount = null; while (!done) @@ -251,7 +251,7 @@ private void EnsureFailoverIsInitialized() return; } - if (!this.hasFailoverPolicyChanges) + if (!this.isFailoverPolicyLoaded) { this.initializeFailover(); } @@ -276,7 +276,7 @@ private void initializeFailover() this.failoverPolicies.Add(locationInners[i]); } - this.hasFailoverPolicyChanges = true; + this.isFailoverPolicyLoaded = true; } public CosmosDBAccountImpl WithStrongConsistency() @@ -408,7 +408,7 @@ public CosmosDBAccountImpl WithWriteReplication(Region region, bool? isZoneRedun FailoverPolicy.LocationName = region.Name; FailoverPolicy.IsZoneRedundant = isZoneRedundant; FailoverPolicy.FailoverPriority = this.failoverPolicies.Count; - this.hasFailoverPolicyChanges = true; + this.isFailoverPolicyLoaded = true; this.failoverPolicies.Add(FailoverPolicy); return this; } @@ -575,7 +575,7 @@ public CosmosDBAccountImpl WithVirtualNetwork(string virtualNetworkId, string su return this; } - public CosmosDBAccountImpl WithVirtualNetworkFilterEnabled(bool? enable) + public CosmosDBAccountImpl WithVirtualNetworkFilterEnabled(bool enable) { this.Inner.IsVirtualNetworkFilterEnabled = enable; return this; diff --git a/src/ResourceManagement/CosmosDB/Domain/CosmosDBAccount/Definition/IDefinition.cs b/src/ResourceManagement/CosmosDB/Domain/CosmosDBAccount/Definition/IDefinition.cs index 127cfbc7c..57c8a11d3 100644 --- a/src/ResourceManagement/CosmosDB/Domain/CosmosDBAccount/Definition/IDefinition.cs +++ b/src/ResourceManagement/CosmosDB/Domain/CosmosDBAccount/Definition/IDefinition.cs @@ -69,7 +69,7 @@ public interface IWithVirtualNetworkRule : /// /// The fileter is enabled or not. /// The next stage. - Microsoft.Azure.Management.CosmosDB.Fluent.CosmosDBAccount.Definition.IWithCreate WithVirtualNetworkFilterEnabled(bool? enable); + Microsoft.Azure.Management.CosmosDB.Fluent.CosmosDBAccount.Definition.IWithCreate WithVirtualNetworkFilterEnabled(bool enable); /// /// Specifies the list of Virtual Network ACL Rules for the CosmosDB account. @@ -187,12 +187,12 @@ public interface IWithPrivateEndpointConnection } /// - /// The stage of the cosmos db definition allowing the definition of a write location. + /// The stage of the cosmos db definition allowing the definition of a read location. /// public interface IWithReadReplication { /// - /// A georeplication location for the CosmosDB account. + /// Sets a read location for the CosmosDB account. /// /// The region for the location. /// Flag to indicate whether or not this region is an AvailabilityZone region. @@ -216,12 +216,12 @@ public interface IWithIpRangeFilter } /// - /// The stage of the cosmos db definition allowing the definition of a read location. + /// The stage of the cosmos db definition allowing the definition of a write location. /// public interface IWithWriteReplication { /// - /// A georeplication location for the CosmosDB account. + /// Sets a write location for the CosmosDB account. /// /// The region for the location. /// Flag to indicate whether or not this region is an AvailabilityZone region. diff --git a/src/ResourceManagement/CosmosDB/Domain/CosmosDBAccount/Update/IUpdate.cs b/src/ResourceManagement/CosmosDB/Domain/CosmosDBAccount/Update/IUpdate.cs index 03241cac1..15b8c88c4 100644 --- a/src/ResourceManagement/CosmosDB/Domain/CosmosDBAccount/Update/IUpdate.cs +++ b/src/ResourceManagement/CosmosDB/Domain/CosmosDBAccount/Update/IUpdate.cs @@ -76,7 +76,7 @@ public interface IWithVirtualNetworkRule : /// /// The fileter is enabled or not. /// The next stage of the update definition. - Microsoft.Azure.Management.CosmosDB.Fluent.CosmosDBAccount.Update.IWithOptionals WithVirtualNetworkFilterEnabled(bool? enable); + Microsoft.Azure.Management.CosmosDB.Fluent.CosmosDBAccount.Update.IWithOptionals WithVirtualNetworkFilterEnabled(bool enable); /// /// A Virtual Network ACL Rule for the CosmosDB account. @@ -179,13 +179,13 @@ public interface IUpdate : } /// - /// The stage of the cosmos db definition allowing the definition of a write location. + /// The stage of the cosmos db definition allowing the definition of a read location. /// public interface IWithReadLocations : Microsoft.Azure.Management.ResourceManager.Fluent.Core.ResourceActions.IAppliable { /// - /// A georeplication location for the CosmosDB account. + /// Sets a read location for the CosmosDB account. /// /// The region for the location. /// Flag to indicate whether or not this region is an AvailabilityZone region. @@ -193,7 +193,7 @@ public interface IWithReadLocations : Microsoft.Azure.Management.CosmosDB.Fluent.CosmosDBAccount.Update.IWithReadLocations WithReadReplication(Region region, bool? isZoneRedundant = default(bool?)); /// - /// A georeplication location for the CosmosDB account. + /// Removes a read location for the CosmosDB account. /// /// The region for the location. /// The next stage. @@ -212,7 +212,7 @@ public interface IWithReadLocations : public interface IWithWriteReplication { /// - /// A georeplication location for the CosmosDB account. + /// Sets a write location for the CosmosDB account. /// /// The region for the location. /// Flag to indicate whether or not this region is an AvailabilityZone region. diff --git a/src/ResourceManagement/CosmosDB/Domain/IndexingPolicy/Definition/IDefinition.cs b/src/ResourceManagement/CosmosDB/Domain/IndexingPolicy/Definition/IDefinition.cs index 09a8605f3..982f33a8d 100644 --- a/src/ResourceManagement/CosmosDB/Domain/IndexingPolicy/Definition/IDefinition.cs +++ b/src/ResourceManagement/CosmosDB/Domain/IndexingPolicy/Definition/IDefinition.cs @@ -149,7 +149,7 @@ public interface IWithCompositeIndexes /// Specifies a composite index empty list to set every composite path. /// /// The next stage of the definition. - IWithCompositeIndexList WithCompositeIndexEmptyList(); + IWithCompositeIndexList WithNewCompositeIndexList(); } /// diff --git a/src/ResourceManagement/CosmosDB/Domain/IndexingPolicy/Update/IUpdate.cs b/src/ResourceManagement/CosmosDB/Domain/IndexingPolicy/Update/IUpdate.cs index 9ac96fb86..08f4b78a9 100644 --- a/src/ResourceManagement/CosmosDB/Domain/IndexingPolicy/Update/IUpdate.cs +++ b/src/ResourceManagement/CosmosDB/Domain/IndexingPolicy/Update/IUpdate.cs @@ -193,7 +193,7 @@ public interface IWithCompositeIndexes /// Specifies a composite index empty list to set every composite path. /// /// The next stage of the update. - IWithCompositeIndexList WithCompositeIndexEmptyList(); + IWithCompositeIndexList WithNewCompositeIndexList(); /// /// Removes all composite indexes. diff --git a/src/ResourceManagement/CosmosDB/Domain/InterfaceImpl/CosmosDBAccountImpl.cs b/src/ResourceManagement/CosmosDB/Domain/InterfaceImpl/CosmosDBAccountImpl.cs index e44c0186d..c45e5eab4 100644 --- a/src/ResourceManagement/CosmosDB/Domain/InterfaceImpl/CosmosDBAccountImpl.cs +++ b/src/ResourceManagement/CosmosDB/Domain/InterfaceImpl/CosmosDBAccountImpl.cs @@ -532,7 +532,7 @@ CosmosDBAccount.Definition.IWithCreate CosmosDBAccount.Definition.IWithVirtualNe return this.WithVirtualNetwork(virtualNetworkId, subnetName, ignoreMissingVNetServiceEndpoint); } - CosmosDBAccount.Definition.IWithCreate CosmosDBAccount.Definition.IWithVirtualNetworkRule.WithVirtualNetworkFilterEnabled(bool? enable) + CosmosDBAccount.Definition.IWithCreate CosmosDBAccount.Definition.IWithVirtualNetworkRule.WithVirtualNetworkFilterEnabled(bool enable) { return this.WithVirtualNetworkFilterEnabled(enable); } @@ -556,7 +556,7 @@ CosmosDBAccount.Update.IWithOptionals CosmosDBAccount.Update.IWithVirtualNetwork return this.WithVirtualNetwork(virtualNetworkId, subnetName, ignoreMissingVNetServiceEndpoint); } - CosmosDBAccount.Update.IWithOptionals CosmosDBAccount.Update.IWithVirtualNetworkRule.WithVirtualNetworkFilterEnabled(bool? enable) + CosmosDBAccount.Update.IWithOptionals CosmosDBAccount.Update.IWithVirtualNetworkRule.WithVirtualNetworkFilterEnabled(bool enable) { return this.WithVirtualNetworkFilterEnabled(enable); } diff --git a/src/ResourceManagement/CosmosDB/Domain/InterfaceImpl/IndexingPolicyImpl.cs b/src/ResourceManagement/CosmosDB/Domain/InterfaceImpl/IndexingPolicyImpl.cs index 702b1b863..a6f998d01 100644 --- a/src/ResourceManagement/CosmosDB/Domain/InterfaceImpl/IndexingPolicyImpl.cs +++ b/src/ResourceManagement/CosmosDB/Domain/InterfaceImpl/IndexingPolicyImpl.cs @@ -58,9 +58,9 @@ IndexingPolicy.Definition.IWithAttach IndexingPolicy.Definiti return this.WithCompositeIndex(compositePath); } - IndexingPolicy.Definition.IWithCompositeIndexList IndexingPolicy.Definition.IWithCompositeIndexes.WithCompositeIndexEmptyList() + IndexingPolicy.Definition.IWithCompositeIndexList IndexingPolicy.Definition.IWithCompositeIndexes.WithNewCompositeIndexList() { - return this.WithCompositeIndexEmptyList(); + return this.WithNewCompositeIndexList(); } IndexingPolicy.Definition.IWithCompositeIndexList IndexingPolicy.Definition.IWithCompositeIndexList.WithCompositePath(CompositePath compositePath) @@ -183,9 +183,9 @@ IndexingPolicy.Update.IWithAttach IndexingPolicy.Update.IWithComp return this.WithCompositeIndex(compositePath); } - IndexingPolicy.Update.IWithCompositeIndexList IndexingPolicy.Update.IWithCompositeIndexes.WithCompositeIndexEmptyList() + IndexingPolicy.Update.IWithCompositeIndexList IndexingPolicy.Update.IWithCompositeIndexes.WithNewCompositeIndexList() { - return this.WithCompositeIndexEmptyList(); + return this.WithNewCompositeIndexList(); } IndexingPolicy.Update.IWithAttach IndexingPolicy.Update.IWithCompositeIndexes.WithoutCompositeIndexes() diff --git a/src/ResourceManagement/CosmosDB/GremlinDatabaseImpl.cs b/src/ResourceManagement/CosmosDB/GremlinDatabaseImpl.cs index 857162895..82dc53a50 100644 --- a/src/ResourceManagement/CosmosDB/GremlinDatabaseImpl.cs +++ b/src/ResourceManagement/CosmosDB/GremlinDatabaseImpl.cs @@ -109,7 +109,7 @@ public GremlinDatabaseImpl WithoutOptions() public GremlinDatabaseImpl WithThroughput(int throughput) { - this.createUpdateParameters.Options.Throughput = $"{throughput}"; + this.createUpdateParameters.Options.Throughput = throughput.ToString(); return this; } diff --git a/src/ResourceManagement/CosmosDB/GremlinGraphImpl.cs b/src/ResourceManagement/CosmosDB/GremlinGraphImpl.cs index 902a387d2..438c15646 100644 --- a/src/ResourceManagement/CosmosDB/GremlinGraphImpl.cs +++ b/src/ResourceManagement/CosmosDB/GremlinGraphImpl.cs @@ -188,7 +188,7 @@ public GremlinGraphImpl WithoutOptions() public GremlinGraphImpl WithThroughput(int throughput) { - this.createUpdateParameters.Options.Throughput = $"{throughput}"; + this.createUpdateParameters.Options.Throughput = throughput.ToString(); return this; } diff --git a/src/ResourceManagement/CosmosDB/IndexingPolicyImpl.cs b/src/ResourceManagement/CosmosDB/IndexingPolicyImpl.cs index 7aa324c43..c37cc4b6b 100644 --- a/src/ResourceManagement/CosmosDB/IndexingPolicyImpl.cs +++ b/src/ResourceManagement/CosmosDB/IndexingPolicyImpl.cs @@ -183,7 +183,7 @@ public IndexingPolicyImpl WithCompositeIndexEmptyList() + public IndexingPolicyImpl WithNewCompositeIndexList() { return this.WithCompositeIndex(new List()); } diff --git a/src/ResourceManagement/CosmosDB/MongoCollectionImpl.cs b/src/ResourceManagement/CosmosDB/MongoCollectionImpl.cs index 8269053c9..eac359434 100644 --- a/src/ResourceManagement/CosmosDB/MongoCollectionImpl.cs +++ b/src/ResourceManagement/CosmosDB/MongoCollectionImpl.cs @@ -160,7 +160,7 @@ public MongoCollectionImpl WithoutOptions() public MongoCollectionImpl WithThroughput(int throughput) { - this.createUpdateParameters.Options.Throughput = $"{throughput}"; + this.createUpdateParameters.Options.Throughput = throughput.ToString(); return this; } diff --git a/src/ResourceManagement/CosmosDB/MongoDBImpl.cs b/src/ResourceManagement/CosmosDB/MongoDBImpl.cs index 0dc1f3239..28ed2deed 100644 --- a/src/ResourceManagement/CosmosDB/MongoDBImpl.cs +++ b/src/ResourceManagement/CosmosDB/MongoDBImpl.cs @@ -109,7 +109,7 @@ public MongoDBImpl WithoutOptions() public MongoDBImpl WithThroughput(int throughput) { - this.createUpdateParameters.Options.Throughput = $"{throughput}"; + this.createUpdateParameters.Options.Throughput = throughput.ToString(); return this; } diff --git a/src/ResourceManagement/CosmosDB/SqlContainerImpl.cs b/src/ResourceManagement/CosmosDB/SqlContainerImpl.cs index b2543f91f..6345b988d 100644 --- a/src/ResourceManagement/CosmosDB/SqlContainerImpl.cs +++ b/src/ResourceManagement/CosmosDB/SqlContainerImpl.cs @@ -212,7 +212,7 @@ public SqlContainerImpl WithoutOptions() public SqlContainerImpl WithThroughput(int throughput) { - this.createUpdateParameters.Options.Throughput = $"{throughput}"; + this.createUpdateParameters.Options.Throughput = throughput.ToString(); return this; } diff --git a/src/ResourceManagement/CosmosDB/SqlDatabaseImpl.cs b/src/ResourceManagement/CosmosDB/SqlDatabaseImpl.cs index 88184f766..29d63dde3 100644 --- a/src/ResourceManagement/CosmosDB/SqlDatabaseImpl.cs +++ b/src/ResourceManagement/CosmosDB/SqlDatabaseImpl.cs @@ -119,7 +119,7 @@ public SqlDatabaseImpl WithoutOptions() public SqlDatabaseImpl WithThroughput(int throughput) { - this.createUpdateParameters.Options.Throughput = $"{throughput}"; + this.createUpdateParameters.Options.Throughput = throughput.ToString(); return this; } diff --git a/src/ResourceManagement/CosmosDB/TableImpl.cs b/src/ResourceManagement/CosmosDB/TableImpl.cs index 7d8e64ee0..ecbdd5799 100644 --- a/src/ResourceManagement/CosmosDB/TableImpl.cs +++ b/src/ResourceManagement/CosmosDB/TableImpl.cs @@ -107,7 +107,7 @@ public TableImpl WithoutOptions() public TableImpl WithThroughput(int throughput) { - this.createUpdateParameters.Options.Throughput = $"{throughput}"; + this.createUpdateParameters.Options.Throughput = throughput.ToString(); return this; }