ZD CDP connector now implements version 2
This commit is contained in:
Luc Genetier 2024-11-15 15:14:11 +01:00 коммит произвёл GitHub
Родитель 5893a462cb
Коммит ea3d244fc6
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
3 изменённых файлов: 10 добавлений и 9 удалений

Просмотреть файл

@ -54,7 +54,7 @@ namespace Microsoft.PowerFx.Connectors
}
string dataset = _doubleEncoding ? CdpServiceBase.DoubleEncode(_tabularTable.DatasetName) : _tabularTable.DatasetName;
string uri = (_uriPrefix ?? string.Empty) + (IsSql() ? "/v2" : string.Empty) + $"/$metadata.json/datasets/{dataset}/tables/{CdpServiceBase.DoubleEncode(tableName)}?api-version=2015-09-01";
string uri = (_uriPrefix ?? string.Empty) + (UseV2(_uriPrefix) ? "/v2" : string.Empty) + $"/$metadata.json/datasets/{dataset}/tables/{CdpServiceBase.DoubleEncode(tableName)}?api-version=2015-09-01";
string text = await CdpServiceBase.GetObject(_httpClient, $"Get table metadata", uri, null, cancellationToken, Logger).ConfigureAwait(false);
@ -66,7 +66,7 @@ namespace Microsoft.PowerFx.Connectors
List<SqlRelationship> sqlRelationships = null;
// for SQL need to get relationships separately as they aren't included by CDP connector
if (IsSql())
if (IsSql(_uriPrefix))
{
cancellationToken.ThrowIfCancellationRequested();
@ -99,7 +99,10 @@ namespace Microsoft.PowerFx.Connectors
return connectorType;
}
private bool IsSql() => _uriPrefix.Contains("/sql/");
internal static bool IsSql(string uriPrefix) => uriPrefix.Contains("/sql/");
internal static bool UseV2(string uriPrefix) => uriPrefix.Contains("/sql/") ||
uriPrefix.Contains("/zendesk/");
private List<SqlRelationship> GetSqlRelationships(string text)
{

Просмотреть файл

@ -26,7 +26,7 @@ namespace Microsoft.PowerFx.Connectors
public static async Task<DatasetMetadata> GetDatasetsMetadataAsync(HttpClient httpClient, string uriPrefix, CancellationToken cancellationToken, ConnectorLogger logger = null)
{
string uri = (uriPrefix ?? string.Empty)
+ (uriPrefix.Contains("/sql/") ? "/v2" : string.Empty)
+ (CdpTableResolver.UseV2(uriPrefix) ? "/v2" : string.Empty)
+ $"/$metadata.json/datasets";
return await GetObject<DatasetMetadata>(httpClient, "Get datasets metadata", uri, null, cancellationToken, logger).ConfigureAwait(false);
@ -42,7 +42,7 @@ namespace Microsoft.PowerFx.Connectors
_uriPrefix = uriPrefix;
string uri = (_uriPrefix ?? string.Empty)
+ (uriPrefix.Contains("/sql/") ? "/v2" : string.Empty)
+ (CdpTableResolver.UseV2(uriPrefix) ? "/v2" : string.Empty)
+ $"/datasets/{(DatasetMetadata.IsDoubleEncoding ? DoubleEncode(DatasetName) : DatasetName)}"
+ (uriPrefix.Contains("/sharepointonline/") ? "/alltables" : "/tables");

Просмотреть файл

@ -112,14 +112,12 @@ namespace Microsoft.PowerFx.Connectors
Uri uri = new Uri(
(_uriPrefix ?? string.Empty) +
(IsSql() ? "/v2" : string.Empty) +
(CdpTableResolver.UseV2(_uriPrefix) ? "/v2" : string.Empty) +
$"/datasets/{(DatasetMetadata.IsDoubleEncoding ? DoubleEncode(DatasetName) : DatasetName)}/tables/{Uri.EscapeDataString(TableName)}/items?api-version=2015-09-01" + queryParams, UriKind.Relative);
string text = await GetObject(_httpClient, $"List items ({nameof(GetItemsInternalAsync)})", uri.ToString(), null, cancellationToken, executionLogger).ConfigureAwait(false);
return !string.IsNullOrWhiteSpace(text) ? GetResult(text) : Array.Empty<DValue<RecordValue>>();
}
private bool IsSql() => _uriPrefix.Contains("/sql/");
}
private IReadOnlyCollection<DValue<RecordValue>> GetResult(string text)
{