-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cc/api3 #129
base: master
Are you sure you want to change the base?
Cc/api3 #129
Changes from all commits
cb9371b
64c4115
a31909c
93dcdf7
da50b68
20be931
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
image: Visual Studio 2017 | ||
|
||
# Versioning | ||
version: '1.0.{build}' | ||
version: '1.1.{build}' | ||
|
||
assembly_info: | ||
patch: true | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,7 +105,9 @@ $testProjects | ForEach-Object { | |
$dotnetArgs = @('test', "`"$($_.FullName)`"") | ||
$dotnetArgs += $commonDotnetArgs | ||
|
||
$logFileName = "$($_.BaseName)_$(Get-Date -Format 'yyyyMMdd_HHmmss').trx" | ||
# Due to this issue, timestamp is being auto added by dotnet test which breaks AppVeyor from finding tests - https://github.com/Microsoft/vstest/issues/1951 | ||
$logBaseName = $_.BaseName | ||
$logFileName = "$($logBaseName).trx" # Depending how above issue is fixed, may need to add this back in _$(Get-Date -Format 'yyyyMMdd_HHmmss') | ||
if($Logger) { | ||
$dotnetArgs += @('--logger', "`"$Logger;LogFileName=$logFileName`"") | ||
} | ||
|
@@ -115,9 +117,14 @@ $testProjects | ForEach-Object { | |
$exitCode = $LASTEXITCODE # Save exit code in case upload results fails | ||
|
||
if($ResultsDirectory -and $Logger -and $UploadResultsToAppVeyor -and $env:APPVEYOR_JOB_ID) { | ||
$resultsLog = Join-Path -Path $ResultsDirectory -ChildPath $logFileName | ||
if(Test-Path -Path $resultsLog) { | ||
Write-Host "Publishing test results..." | ||
#Write-Host "ResultsDirectory: $ResultsDirectory" | ||
#Write-Host "LogFileName: $logFileName" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This section of code is doubly indented. I would recommend removing these commented out console logs if you feel they aren't needed anymore. |
||
$resultsFileName = Join-Path -Path $ResultsDirectory -ChildPath "$($logBaseName)*.trx" | ||
$resultsLog = Get-ChildItem -Path $resultsFileName | Select-Object -First 1 | % { $_.FullName } | ||
if($resultsLog -and (Test-Path -Path $resultsLog)) { | ||
# https://www.appveyor.com/docs/running-tests/ | ||
# https://www.appveyor.com/docs/running-tests/#pushing-real-time-test-results-to-build-console | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inconsistent indentation. |
||
try { | ||
Write-Output "Uploading file to AppVeyor (job ID $($env:APPVEYOR_JOB_ID)): $resultsLog" | ||
$wc = New-Object 'System.Net.WebClient' | ||
|
@@ -128,7 +135,7 @@ $testProjects | ForEach-Object { | |
} | ||
} | ||
else { | ||
Write-Warning "No results file found at: $resultsLog" | ||
Write-Warning "No results file found at: $resultsFileName" | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
using System.Linq; | ||
using System.Management.Automation; | ||
using Microsoft.PowerBI.Api.V2; | ||
using Microsoft.PowerBI.Common.Api.Helpers; | ||
|
||
namespace Microsoft.PowerBI.Common.Api.Datasets | ||
{ | ||
|
@@ -21,8 +22,8 @@ public DatasetsClient(IPowerBIClient client) : base(client) | |
public object AddDataset(Dataset dataset, Guid? workspaceId = default) | ||
{ | ||
var result = workspaceId.HasValue && workspaceId.Value != default ? | ||
this.Client.Datasets.PostDatasetInGroup(groupId: workspaceId.Value.ToString(), dataset: Dataset.ConvertToDatasetV2Model(dataset)) : | ||
this.Client.Datasets.PostDataset(dataset: Dataset.ConvertToDatasetV2Model(dataset)); | ||
this.Client.Datasets.PostDatasetInGroup(groupId: workspaceId.Value, dataset: Dataset.ConvertToDatasetRequest(dataset), EnumTypeConverter.ConvertTo<Microsoft.PowerBI.Api.V2.Models.DefaultRetentionPolicy, DefaultRetentionPolicy>(dataset.DefaultRetentionPolicy)) : | ||
this.Client.Datasets.PostDataset(dataset: Dataset.ConvertToDatasetRequest(dataset), EnumTypeConverter.ConvertTo<Microsoft.PowerBI.Api.V2.Models.DefaultRetentionPolicy, DefaultRetentionPolicy>(dataset.DefaultRetentionPolicy)); | ||
|
||
return result; | ||
} | ||
|
@@ -34,7 +35,7 @@ public IEnumerable<Dataset> GetDatasets() | |
|
||
public IEnumerable<Dataset> GetDatasetsForWorkspace(Guid workspaceId) | ||
{ | ||
return this.Client.Datasets.GetDatasets(groupId: workspaceId.ToString()).Value?.Select(x => (Dataset)x); | ||
return this.Client.Datasets.GetDatasets(groupId: workspaceId).Value?.Select(x => (Dataset)x); | ||
} | ||
|
||
public IEnumerable<Dataset> GetDatasetsAsAdmin(string filter = null, int? top = null, int? skip = null) | ||
|
@@ -44,40 +45,48 @@ public IEnumerable<Dataset> GetDatasetsAsAdmin(string filter = null, int? top = | |
|
||
public IEnumerable<Dataset> GetDatasetsAsAdminForWorkspace(Guid workspaceId, string filter = null, int? top = null, int? skip = null) | ||
{ | ||
return this.Client.Datasets.GetDatasetsAsAdmin(groupId: workspaceId.ToString(), filter: filter, top: top, skip: skip).Value?.Select(x => (Dataset)x); | ||
return this.Client.Datasets.GetDatasetsAsAdmin(groupId: workspaceId, filter: filter, top: top, skip: skip).Value?.Select(x => (Dataset)x); | ||
} | ||
|
||
public IEnumerable<Datasource> GetDatasources(Guid datasetId, Guid? workspaceId = default) | ||
{ | ||
var result = workspaceId.HasValue && workspaceId.Value != default ? | ||
this.Client.Datasets.GetDatasources(groupId: workspaceId.Value.ToString(), datasetKey: datasetId.ToString()) : | ||
this.Client.Datasets.GetDatasources(datasetKey: datasetId.ToString()); | ||
this.Client.Datasets.GetDatasources(groupId: workspaceId.Value, datasetId: datasetId) : | ||
this.Client.Datasets.GetDatasources(datasetId: datasetId); | ||
return result.Value?.Select(x => (Datasource)x); | ||
|
||
} | ||
|
||
public IEnumerable<Datasource> GetDatasourcesAsAdmin(Guid datasetId) | ||
{ | ||
return this.Client.Datasets.GetDatasourcesAsAdmin(datasetId.ToString()).Value?.Select(x => (Datasource)x); | ||
return this.Client.Datasets.GetDatasourcesAsAdmin(datasetId).Value?.Select(x => (Datasource)x); | ||
} | ||
|
||
public IEnumerable<Table> GetTables(Guid datasetId, Guid? workspaceId = default) | ||
{ | ||
var result = workspaceId.HasValue && workspaceId.Value != default ? | ||
this.Client.Datasets.GetTables(groupId: workspaceId.Value.ToString(), datasetKey: datasetId.ToString()) : | ||
this.Client.Datasets.GetTables(datasetKey: datasetId.ToString()); | ||
this.Client.Datasets.GetTables(groupId: workspaceId.Value, datasetId: datasetId) : | ||
this.Client.Datasets.GetTables(datasetId: datasetId); | ||
return result.Value?.Select(x => (Table)x); | ||
} | ||
|
||
public Table UpdateTable(Table table, Guid datasetId, Guid? workspaceId = null) | ||
{ | ||
var result = workspaceId.HasValue && workspaceId.Value != default ? | ||
this.Client.Datasets.PutTableInGroup(groupId: workspaceId.Value.ToString(), datasetKey: datasetId.ToString(), tableName: table.Name, (Microsoft.PowerBI.Api.V2.Models.Table)table) : | ||
this.Client.Datasets.PutTable(datasetKey: datasetId.ToString(), tableName: table.Name, (Microsoft.PowerBI.Api.V2.Models.Table)table); | ||
return result as Table; | ||
this.Client.Datasets.PutTableInGroup(groupId: workspaceId.Value, datasetId: datasetId, tableName: table.Name, (Microsoft.PowerBI.Api.V2.Models.Table)table) : | ||
this.Client.Datasets.PutTable(datasetId: datasetId, tableName: table.Name, (Microsoft.PowerBI.Api.V2.Models.Table)table); | ||
|
||
if (result != null) | ||
{ | ||
return (Table)result; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could cast using as instead. I think that would help you avoid the if-else return null block. |
||
} | ||
else | ||
{ | ||
return null; | ||
} | ||
} | ||
|
||
public object AddRows(string datasetId, string tableName, List<PSObject> rows, Guid? workspaceId = default) | ||
public void AddRows(Guid datasetId, string tableName, List<PSObject> rows, Guid? workspaceId = null) | ||
{ | ||
var hashRows = new List<Hashtable>(); | ||
foreach (var row in rows) | ||
|
@@ -99,21 +108,27 @@ public object AddRows(string datasetId, string tableName, List<PSObject> rows, G | |
} | ||
hashRows.Add(hashtable); | ||
} | ||
var result = workspaceId.HasValue && workspaceId.Value != default ? | ||
this.Client.Datasets.PostRowsInGroup(groupId: workspaceId.Value.ToString(), datasetKey: datasetId, tableName: tableName, requestMessage: hashRows) : | ||
this.Client.Datasets.PostRows(datasetKey: datasetId, tableName: tableName, requestMessage: hashRows); | ||
|
||
return result; | ||
if(workspaceId.HasValue && workspaceId.Value != Guid.Empty) | ||
{ | ||
this.Client.Datasets.PostRowsInGroup(groupId: workspaceId.Value, datasetId: datasetId, tableName: tableName, requestMessage: hashRows); | ||
} | ||
else | ||
{ | ||
this.Client.Datasets.PostRows(datasetId: datasetId, tableName: tableName, requestMessage: hashRows); | ||
} | ||
} | ||
|
||
public object DeleteRows(string datasetId, string tableName, Guid? workspaceId = default) | ||
public void DeleteRows(Guid datasetId, string tableName, Guid? workspaceId = default) | ||
{ | ||
|
||
var result = workspaceId.HasValue && workspaceId.Value != default ? | ||
this.Client.Datasets.DeleteRowsInGroup(groupId: workspaceId.Value.ToString(), datasetKey: datasetId, tableName: tableName) : | ||
this.Client.Datasets.DeleteRows(datasetKey: datasetId, tableName: tableName); | ||
|
||
return result; | ||
if(workspaceId.HasValue && workspaceId.Value != default) | ||
{ | ||
this.Client.Datasets.DeleteRowsInGroup(groupId: workspaceId.Value, datasetId: datasetId, tableName: tableName); | ||
} | ||
else | ||
{ | ||
this.Client.Datasets.DeleteRows(datasetId: datasetId, tableName: tableName); | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,14 @@ | |
*/ | ||
|
||
using System; | ||
using Microsoft.PowerBI.Common.Api.Helpers; | ||
|
||
namespace Microsoft.PowerBI.Common.Api.Datasets | ||
{ | ||
public class Relationship | ||
{ | ||
public string Name { get; set; } | ||
public CrossFilteringBehaviorEnum CrossFilteringBehavior { get; set; } | ||
public CrossFilteringBehaviorEnum? CrossFilteringBehavior { get; set; } | ||
public string FromTable { get; set; } | ||
public string FromColumn { get; set; } | ||
public string ToTable { get; set; } | ||
|
@@ -26,7 +27,7 @@ public static implicit operator Relationship(PowerBI.Api.V2.Models.Relationship | |
return new Relationship | ||
{ | ||
Name = relationship.Name, | ||
CrossFilteringBehavior = ConvertCrossFilteringBehavior(relationship.CrossFilteringBehavior), | ||
CrossFilteringBehavior = EnumTypeConverter.ConvertTo<CrossFilteringBehaviorEnum, PowerBI.Api.V2.Models.CrossFilteringBehavior>(relationship.CrossFilteringBehavior), | ||
FromTable = relationship.FromTable, | ||
FromColumn = relationship.FromColumn, | ||
ToTable = relationship.ToTable, | ||
|
@@ -44,30 +45,19 @@ public static implicit operator PowerBI.Api.V2.Models.Relationship(Relationship | |
return new PowerBI.Api.V2.Models.Relationship | ||
{ | ||
Name = relationship.Name, | ||
CrossFilteringBehavior = (PowerBI.Api.V2.Models.CrossFilteringBehaviorEnum)Enum.Parse(typeof(PowerBI.Api.V2.Models.CrossFilteringBehaviorEnum), relationship.CrossFilteringBehavior.ToString(), true), | ||
CrossFilteringBehavior = EnumTypeConverter.ConvertTo<PowerBI.Api.V2.Models.CrossFilteringBehavior, CrossFilteringBehaviorEnum>(relationship.CrossFilteringBehavior), | ||
FromTable = relationship.FromTable, | ||
FromColumn = relationship.FromColumn, | ||
ToTable = relationship.ToTable, | ||
ToColumn = relationship.ToColumn | ||
}; | ||
} | ||
|
||
private static CrossFilteringBehaviorEnum ConvertCrossFilteringBehavior(PowerBI.Api.V2.Models.CrossFilteringBehaviorEnum? crossFilteringBehavior) | ||
{ | ||
if(crossFilteringBehavior == null) | ||
{ | ||
return CrossFilteringBehaviorEnum.NotAvailable; | ||
} | ||
|
||
return (CrossFilteringBehaviorEnum)Enum.Parse(typeof(CrossFilteringBehaviorEnum), crossFilteringBehavior.Value.ToString(), true); | ||
} | ||
} | ||
|
||
public enum CrossFilteringBehaviorEnum | ||
{ | ||
OneDirection, | ||
BothDirections, | ||
Automatic, | ||
NotAvailable | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it intentional to remove NotAvailable from here? |
||
Automatic | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent indentation.