Skip to content

Commit

Permalink
Regenerate swagger, bump version, and default EndpointSuffix to 'core…
Browse files Browse the repository at this point in the history
….windows.net' (#18981)

* update link to readme.md
* refactor to GetSegmentValueOfDefault
  • Loading branch information
christothes authored Feb 24, 2021
1 parent 3370c21 commit 162b926
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 33 deletions.
6 changes: 6 additions & 0 deletions sdk/core/Azure.Core/src/Shared/ConnectionString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ public string GetRequired(string keyword) =>
public bool TryGetSegmentValue(string keyword, out string? value) =>
_pairs.TryGetValue(keyword, out value);

public string? GetSegmentValueOrDefault(string keyword, string defaultValue) =>
_pairs.TryGetValue(keyword, out var value) switch {
false => defaultValue,
true => value
};

public bool ContainsSegmentKey(string keyword) =>
_pairs.ContainsKey(keyword);

Expand Down
9 changes: 9 additions & 0 deletions sdk/core/Azure.Core/tests/ConnectionStringTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ public void TryGetSegmentValue()
Assert.That(connectionString.TryGetSegmentValue("notpresent", out _), Is.False);
}

[Test]
public void GetSegmentValueOrDefault()
{
var connectionString = ConnectionString.Parse("x=y");
Assert.That(connectionString.GetSegmentValueOrDefault("x", "_"), Is.EqualTo("y"));
var defaultValue = "foo";
Assert.That(connectionString.GetSegmentValueOrDefault("notpresentWithDefault", defaultValue), Is.EqualTo(defaultValue));
}

[Test]
public void Add()
{
Expand Down
6 changes: 5 additions & 1 deletion sdk/tables/Azure.Data.Tables/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Release History

## 3.0.0-beta.6 (Unreleased)
## 12.0.0-beta.6 (Unreleased)

### Changed

- Changed major version number to 12 to indicate this is the latest Tables package across all legacy versions and for cross language consistency.

### Key Bug Fixes

Expand Down
2 changes: 1 addition & 1 deletion sdk/tables/Azure.Data.Tables/src/Azure.Data.Tables.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<Description>This client library enables working with the Microsoft Azure Table service</Description>
<AssemblyTitle>Microsoft Azure.Data.Tables client library</AssemblyTitle>
<Version>3.0.0-beta.6</Version>
<Version>12.0.0-beta.6</Version>
<DefineConstants>TableSDK;$(DefineConstants)</DefineConstants>
<PackageTags>Microsoft Azure Tables;Microsoft;Azure;Tables;Table;$(PackageCommonTags)</PackageTags>
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions sdk/tables/Azure.Data.Tables/src/Generated/TableRestClient.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions sdk/tables/Azure.Data.Tables/src/TableClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ public virtual async Task<Response> DeleteAsync(CancellationToken cancellationTo
scope.Start();
try
{
var response = _tableOperations.QueryEntitiesWithPartitionAndRowKey(
var response = _tableOperations.QueryEntityWithPartitionAndRowKey(
_table,
partitionKey,
rowKey,
Expand Down Expand Up @@ -469,7 +469,7 @@ public virtual async Task<Response> DeleteAsync(CancellationToken cancellationTo
scope.Start();
try
{
var response = await _tableOperations.QueryEntitiesWithPartitionAndRowKeyAsync(
var response = await _tableOperations.QueryEntityWithPartitionAndRowKeyAsync(
_table,
partitionKey,
rowKey,
Expand Down
7 changes: 4 additions & 3 deletions sdk/tables/Azure.Data.Tables/src/TableConnectionString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,10 @@ string settingOrDefault(string key)
settings.TryGetSegmentValue(TableConstants.ConnectionStrings.SharedAccessSignatureSetting, out sasToken);

var matchesAutomaticEndpointsSpec = settings.TryGetSegmentValue(TableConstants.ConnectionStrings.AccountNameSetting, out var accountName) &&
settings.TryGetSegmentValue(TableConstants.ConnectionStrings.AccountKeySetting, out var accountKey) &&
(settings.TryGetSegmentValue(TableConstants.ConnectionStrings.TableEndpointSetting, out var primary) ||
settings.TryGetSegmentValue(TableConstants.ConnectionStrings.EndpointSuffixSetting, out var endpointSuffix));
settings.TryGetSegmentValue(TableConstants.ConnectionStrings.AccountKeySetting, out var accountKey);

settings.TryGetSegmentValue(TableConstants.ConnectionStrings.TableEndpointSetting, out var primary);
var endpointSuffix = settings.GetSegmentValueOrDefault(TableConstants.ConnectionStrings.EndpointSuffixSetting, TableConstants.ConnectionStrings.DefaultEndpointSuffix);

if (matchesAutomaticEndpointsSpec || matchesExplicitEndpointsSpec)
{
Expand Down
16 changes: 4 additions & 12 deletions sdk/tables/Azure.Data.Tables/src/autorest.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,10 @@ Run `dotnet build /t:GenerateCode` to generate code.

``` yaml
title: Azure.Data.Tables
input-file:
- https://github.com/Azure/azure-rest-api-specs/blob/bda39d9be69b9e838eb41e5b71964a567a627cbc/specification/cosmos-db/data-plane/Microsoft.Tables/preview/2019-02-02/table.json
tag: package-2019-02
azure-validator: false
require:
- https://github.com/Azure/azure-rest-api-specs/blob/2df8b07bf9af7c96066ca4dda21b79297307d108/specification/cosmos-db/data-plane/readme.md
namespace: Azure.Data.Tables
include-csproj: disable
```
### Fix Response type for QueryEntitiesWithPartitionAndRowKey
``` yaml
directive:
from: swagger-document
where: $.paths["/{table}(PartitionKey='{partitionKey}',RowKey='{rowKey}')"].get.responses
transform: >
$["200"].schema.$ref = "#/definitions/TableEntityProperties"
```
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public static IEnumerable<object[]> ValidStorageConnStrings()
{
yield return new object[] { $"DefaultEndpointsProtocol=https;AccountName={AccountName};AccountKey={Secret};EndpointSuffix=core.windows.net" };
yield return new object[] { $"AccountName={AccountName};AccountKey={Secret};EndpointSuffix=core.windows.net" };
yield return new object[] { $"DefaultEndpointsProtocol=https;AccountName={AccountName};AccountKey={Secret}" };
yield return new object[] { $"AccountName={AccountName};AccountKey={Secret}" };
}

public static IEnumerable<object[]> InvalidStorageConnStrings()
Expand Down Expand Up @@ -132,7 +134,6 @@ public static IEnumerable<object[]> InvalidConnStrings()
{
yield return new object[] { "UseDevelopmentStorage=false" };
yield return new object[] { $"BlobEndpoint=https://{AccountName}.blob.core.windows.net/;QueueEndpoint=https://{AccountName}.queue.core.windows.net/;FileEndpoint=https://{AccountName}.file.core.windows.net/;TableEndpoint=https://{AccountName}.table.core.windows.net/" };
yield return new object[] { $"DefaultEndpointsProtocol=https;AccountName={AccountName};AccountKey={Secret}" };
yield return new object[] { $"DefaultEndpointsProtocol=https;AccountName={AccountName};EndpointSuffix=core.windows.net" };
yield return new object[] { $"DefaultEndpointsProtocol=https;AccountKey={Secret};EndpointSuffix=core.windows.net" };
}
Expand Down

0 comments on commit 162b926

Please sign in to comment.