From 162b926102f05bd9e19f9bbd0ad6a28fe62757f4 Mon Sep 17 00:00:00 2001 From: Christopher Scott Date: Wed, 24 Feb 2021 15:34:26 -0600 Subject: [PATCH] Regenerate swagger, bump version, and default EndpointSuffix to 'core.windows.net' (#18981) * update link to readme.md * refactor to GetSegmentValueOfDefault --- .../Azure.Core/src/Shared/ConnectionString.cs | 6 ++++++ .../Azure.Core/tests/ConnectionStringTests.cs | 9 +++++++++ sdk/tables/Azure.Data.Tables/CHANGELOG.md | 6 +++++- .../src/Azure.Data.Tables.csproj | 2 +- .../src/Generated/ServiceRestClient.cs | 2 +- ...eryEntityWithPartitionAndRowKeyHeaders.cs} | 4 ++-- .../src/Generated/TableRestClient.cs | 20 +++++++++---------- .../Azure.Data.Tables/src/TableClient.cs | 4 ++-- .../src/TableConnectionString.cs | 7 ++++--- sdk/tables/Azure.Data.Tables/src/autorest.md | 16 ++++----------- .../tests/TableConnectionStringTests.cs | 3 ++- 11 files changed, 46 insertions(+), 33 deletions(-) rename sdk/tables/Azure.Data.Tables/src/Generated/{TableQueryEntitiesWithPartitionAndRowKeyHeaders.cs => TableQueryEntityWithPartitionAndRowKeyHeaders.cs} (87%) diff --git a/sdk/core/Azure.Core/src/Shared/ConnectionString.cs b/sdk/core/Azure.Core/src/Shared/ConnectionString.cs index 83906cbfc912e..dfba4bc2de41e 100644 --- a/sdk/core/Azure.Core/src/Shared/ConnectionString.cs +++ b/sdk/core/Azure.Core/src/Shared/ConnectionString.cs @@ -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); diff --git a/sdk/core/Azure.Core/tests/ConnectionStringTests.cs b/sdk/core/Azure.Core/tests/ConnectionStringTests.cs index 9df7c092e2ce9..ff92cca71339e 100644 --- a/sdk/core/Azure.Core/tests/ConnectionStringTests.cs +++ b/sdk/core/Azure.Core/tests/ConnectionStringTests.cs @@ -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() { diff --git a/sdk/tables/Azure.Data.Tables/CHANGELOG.md b/sdk/tables/Azure.Data.Tables/CHANGELOG.md index 5426c44ed3f6f..c9735820a933f 100644 --- a/sdk/tables/Azure.Data.Tables/CHANGELOG.md +++ b/sdk/tables/Azure.Data.Tables/CHANGELOG.md @@ -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 diff --git a/sdk/tables/Azure.Data.Tables/src/Azure.Data.Tables.csproj b/sdk/tables/Azure.Data.Tables/src/Azure.Data.Tables.csproj index 3f191423e4470..dfe4ace47b9df 100644 --- a/sdk/tables/Azure.Data.Tables/src/Azure.Data.Tables.csproj +++ b/sdk/tables/Azure.Data.Tables/src/Azure.Data.Tables.csproj @@ -2,7 +2,7 @@ This client library enables working with the Microsoft Azure Table service Microsoft Azure.Data.Tables client library - 3.0.0-beta.6 + 12.0.0-beta.6 TableSDK;$(DefineConstants) Microsoft Azure Tables;Microsoft;Azure;Tables;Table;$(PackageCommonTags) $(RequiredTargetFrameworks) diff --git a/sdk/tables/Azure.Data.Tables/src/Generated/ServiceRestClient.cs b/sdk/tables/Azure.Data.Tables/src/Generated/ServiceRestClient.cs index 971d368a15310..93f0945559dd1 100644 --- a/sdk/tables/Azure.Data.Tables/src/Generated/ServiceRestClient.cs +++ b/sdk/tables/Azure.Data.Tables/src/Generated/ServiceRestClient.cs @@ -25,7 +25,7 @@ internal partial class ServiceRestClient /// Initializes a new instance of ServiceRestClient. /// The handler for diagnostic messaging in the client. /// The HTTP pipeline for sending and receiving REST requests and responses. - /// The URL of the service account or table that is the targe of the desired operation. + /// The URL of the service account or table that is the target of the desired operation. /// Specifies the version of the operation to use for this request. /// or is null. public ServiceRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string url, string version = "2019-02-02") diff --git a/sdk/tables/Azure.Data.Tables/src/Generated/TableQueryEntitiesWithPartitionAndRowKeyHeaders.cs b/sdk/tables/Azure.Data.Tables/src/Generated/TableQueryEntityWithPartitionAndRowKeyHeaders.cs similarity index 87% rename from sdk/tables/Azure.Data.Tables/src/Generated/TableQueryEntitiesWithPartitionAndRowKeyHeaders.cs rename to sdk/tables/Azure.Data.Tables/src/Generated/TableQueryEntityWithPartitionAndRowKeyHeaders.cs index f4aee63995add..449ff40c0bc40 100644 --- a/sdk/tables/Azure.Data.Tables/src/Generated/TableQueryEntitiesWithPartitionAndRowKeyHeaders.cs +++ b/sdk/tables/Azure.Data.Tables/src/Generated/TableQueryEntityWithPartitionAndRowKeyHeaders.cs @@ -10,10 +10,10 @@ namespace Azure.Data.Tables { - internal partial class TableQueryEntitiesWithPartitionAndRowKeyHeaders + internal partial class TableQueryEntityWithPartitionAndRowKeyHeaders { private readonly Response _response; - public TableQueryEntitiesWithPartitionAndRowKeyHeaders(Response response) + public TableQueryEntityWithPartitionAndRowKeyHeaders(Response response) { _response = response; } diff --git a/sdk/tables/Azure.Data.Tables/src/Generated/TableRestClient.cs b/sdk/tables/Azure.Data.Tables/src/Generated/TableRestClient.cs index ecb54af0af2ab..edf6f6b43228d 100644 --- a/sdk/tables/Azure.Data.Tables/src/Generated/TableRestClient.cs +++ b/sdk/tables/Azure.Data.Tables/src/Generated/TableRestClient.cs @@ -27,7 +27,7 @@ internal partial class TableRestClient /// Initializes a new instance of TableRestClient. /// The handler for diagnostic messaging in the client. /// The HTTP pipeline for sending and receiving REST requests and responses. - /// The URL of the service account or table that is the targe of the desired operation. + /// The URL of the service account or table that is the target of the desired operation. /// Specifies the version of the operation to use for this request. /// or is null. public TableRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string url, string version = "2019-02-02") @@ -390,7 +390,7 @@ public ResponseWithHeaders } } - internal HttpMessage CreateQueryEntitiesWithPartitionAndRowKeyRequest(string table, string partitionKey, string rowKey, int? timeout, QueryOptions queryOptions) + internal HttpMessage CreateQueryEntityWithPartitionAndRowKeyRequest(string table, string partitionKey, string rowKey, int? timeout, QueryOptions queryOptions) { var message = _pipeline.CreateMessage(); var request = message.Request; @@ -427,7 +427,7 @@ internal HttpMessage CreateQueryEntitiesWithPartitionAndRowKeyRequest(string tab return message; } - /// Queries entities in a table. + /// Queries a single entity in a table. /// The name of the table. /// The partition key of the entity. /// The row key of the entity. @@ -435,7 +435,7 @@ internal HttpMessage CreateQueryEntitiesWithPartitionAndRowKeyRequest(string tab /// Parameter group. /// The cancellation token to use. /// , , or is null. - public async Task, TableQueryEntitiesWithPartitionAndRowKeyHeaders>> QueryEntitiesWithPartitionAndRowKeyAsync(string table, string partitionKey, string rowKey, int? timeout = null, QueryOptions queryOptions = null, CancellationToken cancellationToken = default) + public async Task, TableQueryEntityWithPartitionAndRowKeyHeaders>> QueryEntityWithPartitionAndRowKeyAsync(string table, string partitionKey, string rowKey, int? timeout = null, QueryOptions queryOptions = null, CancellationToken cancellationToken = default) { if (table == null) { @@ -450,9 +450,9 @@ public async Task, Table throw new ArgumentNullException(nameof(rowKey)); } - using var message = CreateQueryEntitiesWithPartitionAndRowKeyRequest(table, partitionKey, rowKey, timeout, queryOptions); + using var message = CreateQueryEntityWithPartitionAndRowKeyRequest(table, partitionKey, rowKey, timeout, queryOptions); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - var headers = new TableQueryEntitiesWithPartitionAndRowKeyHeaders(message.Response); + var headers = new TableQueryEntityWithPartitionAndRowKeyHeaders(message.Response); switch (message.Response.Status) { case 200: @@ -472,7 +472,7 @@ public async Task, Table } } - /// Queries entities in a table. + /// Queries a single entity in a table. /// The name of the table. /// The partition key of the entity. /// The row key of the entity. @@ -480,7 +480,7 @@ public async Task, Table /// Parameter group. /// The cancellation token to use. /// , , or is null. - public ResponseWithHeaders, TableQueryEntitiesWithPartitionAndRowKeyHeaders> QueryEntitiesWithPartitionAndRowKey(string table, string partitionKey, string rowKey, int? timeout = null, QueryOptions queryOptions = null, CancellationToken cancellationToken = default) + public ResponseWithHeaders, TableQueryEntityWithPartitionAndRowKeyHeaders> QueryEntityWithPartitionAndRowKey(string table, string partitionKey, string rowKey, int? timeout = null, QueryOptions queryOptions = null, CancellationToken cancellationToken = default) { if (table == null) { @@ -495,9 +495,9 @@ public ResponseWithHeaders, TableQueryEntiti throw new ArgumentNullException(nameof(rowKey)); } - using var message = CreateQueryEntitiesWithPartitionAndRowKeyRequest(table, partitionKey, rowKey, timeout, queryOptions); + using var message = CreateQueryEntityWithPartitionAndRowKeyRequest(table, partitionKey, rowKey, timeout, queryOptions); _pipeline.Send(message, cancellationToken); - var headers = new TableQueryEntitiesWithPartitionAndRowKeyHeaders(message.Response); + var headers = new TableQueryEntityWithPartitionAndRowKeyHeaders(message.Response); switch (message.Response.Status) { case 200: diff --git a/sdk/tables/Azure.Data.Tables/src/TableClient.cs b/sdk/tables/Azure.Data.Tables/src/TableClient.cs index 3fbf2c0e76aa5..574476192aad1 100644 --- a/sdk/tables/Azure.Data.Tables/src/TableClient.cs +++ b/sdk/tables/Azure.Data.Tables/src/TableClient.cs @@ -430,7 +430,7 @@ public virtual async Task DeleteAsync(CancellationToken cancellationTo scope.Start(); try { - var response = _tableOperations.QueryEntitiesWithPartitionAndRowKey( + var response = _tableOperations.QueryEntityWithPartitionAndRowKey( _table, partitionKey, rowKey, @@ -469,7 +469,7 @@ public virtual async Task DeleteAsync(CancellationToken cancellationTo scope.Start(); try { - var response = await _tableOperations.QueryEntitiesWithPartitionAndRowKeyAsync( + var response = await _tableOperations.QueryEntityWithPartitionAndRowKeyAsync( _table, partitionKey, rowKey, diff --git a/sdk/tables/Azure.Data.Tables/src/TableConnectionString.cs b/sdk/tables/Azure.Data.Tables/src/TableConnectionString.cs index 2cccf287534de..73c722653cba7 100644 --- a/sdk/tables/Azure.Data.Tables/src/TableConnectionString.cs +++ b/sdk/tables/Azure.Data.Tables/src/TableConnectionString.cs @@ -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) { diff --git a/sdk/tables/Azure.Data.Tables/src/autorest.md b/sdk/tables/Azure.Data.Tables/src/autorest.md index bb2880e3467b3..7f77a5315d3e5 100644 --- a/sdk/tables/Azure.Data.Tables/src/autorest.md +++ b/sdk/tables/Azure.Data.Tables/src/autorest.md @@ -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" -``` diff --git a/sdk/tables/Azure.Data.Tables/tests/TableConnectionStringTests.cs b/sdk/tables/Azure.Data.Tables/tests/TableConnectionStringTests.cs index 0c90f5139eeba..4ab310b54977a 100644 --- a/sdk/tables/Azure.Data.Tables/tests/TableConnectionStringTests.cs +++ b/sdk/tables/Azure.Data.Tables/tests/TableConnectionStringTests.cs @@ -35,6 +35,8 @@ public static IEnumerable 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 InvalidStorageConnStrings() @@ -132,7 +134,6 @@ public static IEnumerable 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" }; }