Skip to content

Commit

Permalink
Minor fix for cosmos db according to comments (#995)
Browse files Browse the repository at this point in the history
* fix: throughput format to throughput toString

* fix: WithCompositeIndexEmptyList to WithNewCompositeIndexList

* fix: has failover policy change to is failover loaded, and change some comments
  • Loading branch information
ChenTanyi authored Mar 5, 2020
1 parent 25c8d87 commit 7b29849
Show file tree
Hide file tree
Showing 18 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion Tests/Fluent.Tests/CosmosDB/CosmosDBTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ public void CanCRUDSqlContainer()
.WithIndexingMode(IndexingMode.Consistent)
.WithIncludedPath("/*")
.WithExcludedPath("/myPathToNotIndex/*")
.WithCompositeIndexEmptyList()
.WithNewCompositeIndexList()
.WithCompositePath("/myOrderByPath1", CompositePathSortOrder.Ascending)
.WithCompositePath("/myOrderByPath2", CompositePathSortOrder.Descending)
.Attach()
Expand Down
2 changes: 1 addition & 1 deletion src/ResourceManagement/CosmosDB/CassandraKeyspaceImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/ResourceManagement/CosmosDB/CassandraTableImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
16 changes: 8 additions & 8 deletions src/ResourceManagement/CosmosDB/CosmosDBAccountImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public partial class CosmosDBAccountImpl :
IUpdate
{
private IList<Microsoft.Azure.Management.CosmosDB.Fluent.Models.Location> failoverPolicies;
private bool hasFailoverPolicyChanges;
private bool isFailoverPolicyLoaded;
private const int maxDelayDueToMissingFailovers = 5000 * 12 * 10;
private Dictionary<string, List<Models.VirtualNetworkRule>> virtualNetworkRulesMap;
private PrivateEndpointConnectionsImpl privateEndpointConnections;
Expand Down Expand Up @@ -61,15 +61,15 @@ 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;
}

public CosmosDBAccountImpl WithoutAllReplications()
{
this.failoverPolicies.Clear();
this.hasFailoverPolicyChanges = true;
this.isFailoverPolicyLoaded = true;
return this;
}

Expand All @@ -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)
Expand Down Expand Up @@ -251,7 +251,7 @@ private void EnsureFailoverIsInitialized()
return;
}

if (!this.hasFailoverPolicyChanges)
if (!this.isFailoverPolicyLoaded)
{
this.initializeFailover();
}
Expand All @@ -276,7 +276,7 @@ private void initializeFailover()
this.failoverPolicies.Add(locationInners[i]);
}

this.hasFailoverPolicyChanges = true;
this.isFailoverPolicyLoaded = true;
}

public CosmosDBAccountImpl WithStrongConsistency()
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public interface IWithVirtualNetworkRule :
/// </summary>
/// <param name="enable">The fileter is enabled or not.</param>
/// <returns>The next stage.</returns>
Microsoft.Azure.Management.CosmosDB.Fluent.CosmosDBAccount.Definition.IWithCreate WithVirtualNetworkFilterEnabled(bool? enable);
Microsoft.Azure.Management.CosmosDB.Fluent.CosmosDBAccount.Definition.IWithCreate WithVirtualNetworkFilterEnabled(bool enable);

/// <summary>
/// Specifies the list of Virtual Network ACL Rules for the CosmosDB account.
Expand Down Expand Up @@ -187,12 +187,12 @@ public interface IWithPrivateEndpointConnection
}

/// <summary>
/// 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.
/// </summary>
public interface IWithReadReplication
{
/// <summary>
/// A georeplication location for the CosmosDB account.
/// Sets a read location for the CosmosDB account.
/// </summary>
/// <param name="region">The region for the location.</param>
/// <param name="isZoneRedundant">Flag to indicate whether or not this region is an AvailabilityZone region.</param>
Expand All @@ -216,12 +216,12 @@ public interface IWithIpRangeFilter
}

/// <summary>
/// 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.
/// </summary>
public interface IWithWriteReplication
{
/// <summary>
/// A georeplication location for the CosmosDB account.
/// Sets a write location for the CosmosDB account.
/// </summary>
/// <param name="region">The region for the location.</param>
/// <param name="isZoneRedundant">Flag to indicate whether or not this region is an AvailabilityZone region.</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public interface IWithVirtualNetworkRule :
/// </summary>
/// <param name="enable">The fileter is enabled or not.</param>
/// <return>The next stage of the update definition.</return>
Microsoft.Azure.Management.CosmosDB.Fluent.CosmosDBAccount.Update.IWithOptionals WithVirtualNetworkFilterEnabled(bool? enable);
Microsoft.Azure.Management.CosmosDB.Fluent.CosmosDBAccount.Update.IWithOptionals WithVirtualNetworkFilterEnabled(bool enable);

/// <summary>
/// A Virtual Network ACL Rule for the CosmosDB account.
Expand Down Expand Up @@ -179,21 +179,21 @@ public interface IUpdate :
}

/// <summary>
/// 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.
/// </summary>
public interface IWithReadLocations :
Microsoft.Azure.Management.ResourceManager.Fluent.Core.ResourceActions.IAppliable<Microsoft.Azure.Management.CosmosDB.Fluent.ICosmosDBAccount>
{
/// <summary>
/// A georeplication location for the CosmosDB account.
/// Sets a read location for the CosmosDB account.
/// </summary>
/// <param name="region">The region for the location.</param>
/// <param name="isZoneRedundant">Flag to indicate whether or not this region is an AvailabilityZone region.</param>
/// <return>The next stage.</return>
Microsoft.Azure.Management.CosmosDB.Fluent.CosmosDBAccount.Update.IWithReadLocations WithReadReplication(Region region, bool? isZoneRedundant = default(bool?));

/// <summary>
/// A georeplication location for the CosmosDB account.
/// Removes a read location for the CosmosDB account.
/// </summary>
/// <param name="region">The region for the location.</param>
/// <return>The next stage.</return>
Expand All @@ -212,7 +212,7 @@ public interface IWithReadLocations :
public interface IWithWriteReplication
{
/// <summary>
/// A georeplication location for the CosmosDB account.
/// Sets a write location for the CosmosDB account.
/// </summary>
/// <param name="region">The region for the location.</param>
/// <param name="isZoneRedundant">Flag to indicate whether or not this region is an AvailabilityZone region.</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public interface IWithCompositeIndexes<ParentT>
/// Specifies a composite index empty list to set every composite path.
/// </summary>
/// <returns>The next stage of the definition.</returns>
IWithCompositeIndexList<ParentT> WithCompositeIndexEmptyList();
IWithCompositeIndexList<ParentT> WithNewCompositeIndexList();
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public interface IWithCompositeIndexes<ParentT>
/// Specifies a composite index empty list to set every composite path.
/// </summary>
/// <returns>The next stage of the update.</returns>
IWithCompositeIndexList<ParentT> WithCompositeIndexEmptyList();
IWithCompositeIndexList<ParentT> WithNewCompositeIndexList();

/// <summary>
/// Removes all composite indexes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ IndexingPolicy.Definition.IWithAttach<DefinitionParentT> IndexingPolicy.Definiti
return this.WithCompositeIndex(compositePath);
}

IndexingPolicy.Definition.IWithCompositeIndexList<DefinitionParentT> IndexingPolicy.Definition.IWithCompositeIndexes<DefinitionParentT>.WithCompositeIndexEmptyList()
IndexingPolicy.Definition.IWithCompositeIndexList<DefinitionParentT> IndexingPolicy.Definition.IWithCompositeIndexes<DefinitionParentT>.WithNewCompositeIndexList()
{
return this.WithCompositeIndexEmptyList();
return this.WithNewCompositeIndexList();
}

IndexingPolicy.Definition.IWithCompositeIndexList<DefinitionParentT> IndexingPolicy.Definition.IWithCompositeIndexList<DefinitionParentT>.WithCompositePath(CompositePath compositePath)
Expand Down Expand Up @@ -183,9 +183,9 @@ IndexingPolicy.Update.IWithAttach<UpdateParentT> IndexingPolicy.Update.IWithComp
return this.WithCompositeIndex(compositePath);
}

IndexingPolicy.Update.IWithCompositeIndexList<UpdateParentT> IndexingPolicy.Update.IWithCompositeIndexes<UpdateParentT>.WithCompositeIndexEmptyList()
IndexingPolicy.Update.IWithCompositeIndexList<UpdateParentT> IndexingPolicy.Update.IWithCompositeIndexes<UpdateParentT>.WithNewCompositeIndexList()
{
return this.WithCompositeIndexEmptyList();
return this.WithNewCompositeIndexList();
}

IndexingPolicy.Update.IWithAttach<UpdateParentT> IndexingPolicy.Update.IWithCompositeIndexes<UpdateParentT>.WithoutCompositeIndexes()
Expand Down
2 changes: 1 addition & 1 deletion src/ResourceManagement/CosmosDB/GremlinDatabaseImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/ResourceManagement/CosmosDB/GremlinGraphImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/ResourceManagement/CosmosDB/IndexingPolicyImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public IndexingPolicyImpl<ParentImplT, IParentT, DefinitionParentT, UpdateParent
return this;
}

public IndexingPolicyImpl<ParentImplT, IParentT, DefinitionParentT, UpdateParentT> WithCompositeIndexEmptyList()
public IndexingPolicyImpl<ParentImplT, IParentT, DefinitionParentT, UpdateParentT> WithNewCompositeIndexList()
{
return this.WithCompositeIndex(new List<CompositePath>());
}
Expand Down
2 changes: 1 addition & 1 deletion src/ResourceManagement/CosmosDB/MongoCollectionImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/ResourceManagement/CosmosDB/MongoDBImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/ResourceManagement/CosmosDB/SqlContainerImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/ResourceManagement/CosmosDB/SqlDatabaseImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/ResourceManagement/CosmosDB/TableImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 7b29849

Please sign in to comment.