Skip to content

QueryApi: Organization name and id are interchangeably #28

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Aug 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## 1.0.0.M3 [unreleased]

### Bugs
1. [#48](https://github.com/bonitoo-io/influxdb-client-csharp/issues/27): The org parameter takes either the ID or Name interchangeably

### API
1. [#25](https://github.com/bonitoo-io/influxdb-client-csharp/issues/25): Updated swagger to latest version

Expand Down
8 changes: 4 additions & 4 deletions Client.Test/ItTasksApiTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ public async Task CreateTask()

var flux = $"option task = {{\nname: \"{taskName}\",\nevery: 1h\n}}\n\n{TaskFlux}";

var task = new Api.Domain.Task(_organization.Id, _organization.Name,
taskName, "testing task", TaskStatusType.Active, null, null, flux);
var task = new Api.Domain.Task(orgID:_organization.Id, org:_organization.Name,
name: taskName, description: "testing task", status: TaskStatusType.Active, flux: flux);

task = await _tasksApi.CreateTask(task, _token);

Expand Down Expand Up @@ -194,8 +194,8 @@ public async Task CreateTaskWithOffset()

var flux = $"option task = {{\nname: \"{taskName}\",\nevery: 1h,\noffset: 30m\n}}\n\n{TaskFlux}";

var task = new Api.Domain.Task(_organization.Id, _organization.Name, taskName,
null, TaskStatusType.Active, null, null, flux);
var task = new Api.Domain.Task(orgID:_organization.Id, org:_organization.Name,
name: taskName, status: TaskStatusType.Active, flux: flux);

task = await _tasksApi.CreateTask(task, _token);

Expand Down
31 changes: 31 additions & 0 deletions Client.Test/ItWriteQueryApiTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,37 @@ public async Task WriteRecordsList()
Assert.AreEqual(2, records[1].GetValue());
Assert.AreEqual("level water_level", records[1].GetField());
}

[Test]
public async Task WriteAndQueryByOrganizationName()
{
var bucketName = _bucket.Name;

const string record1 = "h2o_feet,location=coyote_creek level\\ water_level=1.0 1";
const string record2 = "h2o_feet,location=coyote_creek level\\ water_level=2.0 2";

_writeApi = Client.GetWriteApi();
_writeApi.WriteRecords(bucketName, _organization.Name, WritePrecision.Ns,
new List<string> {record1, record2});
_writeApi.Flush();

var query = await _queryApi.Query(
"from(bucket:\"" + bucketName + "\") |> range(start: 1970-01-01T00:00:00.000000001Z)",
_organization.Name);

Assert.AreEqual(1, query.Count);

var records = query[0].Records;
Assert.AreEqual(2, records.Count);

Assert.AreEqual("h2o_feet", records[0].GetMeasurement());
Assert.AreEqual(1, records[0].GetValue());
Assert.AreEqual("level water_level", records[0].GetField());

Assert.AreEqual("h2o_feet", records[1].GetMeasurement());
Assert.AreEqual(2, records[1].GetValue());
Assert.AreEqual("level water_level", records[1].GetField());
}

[Test]
public async Task WriteRecordsParams()
Expand Down
53 changes: 47 additions & 6 deletions Client/InfluxDB.Client.Api/Domain/CheckViewProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ protected CheckViewProperties() { }
/// <param name="type">type (required).</param>
/// <param name="shape">shape (required).</param>
/// <param name="checkID">checkID (required).</param>
/// <param name="check">check (required).</param>
public CheckViewProperties(TypeEnum type = default(TypeEnum), ShapeEnum shape = default(ShapeEnum), string checkID = default(string), Check check = default(Check)) : base()
/// <param name="check">check.</param>
/// <param name="queries">queries (required).</param>
/// <param name="colors">Colors define color encoding of data into a visualization (required).</param>
public CheckViewProperties(TypeEnum type = default(TypeEnum), ShapeEnum shape = default(ShapeEnum), string checkID = default(string), Check check = default(Check), List<DashboardQuery> queries = default(List<DashboardQuery>), List<string> colors = default(List<string>)) : base()
{
// to ensure "type" is required (not null)
if (type == null)
Expand Down Expand Up @@ -108,15 +110,25 @@ protected CheckViewProperties() { }
{
this.CheckID = checkID;
}
// to ensure "check" is required (not null)
if (check == null)
// to ensure "queries" is required (not null)
if (queries == null)
{
throw new InvalidDataException("check is a required property for CheckViewProperties and cannot be null");
throw new InvalidDataException("queries is a required property for CheckViewProperties and cannot be null");
}
else
{
this.Check = check;
this.Queries = queries;
}
// to ensure "colors" is required (not null)
if (colors == null)
{
throw new InvalidDataException("colors is a required property for CheckViewProperties and cannot be null");
}
else
{
this.Colors = colors;
}
this.Check = check;
}


Expand All @@ -134,6 +146,19 @@ protected CheckViewProperties() { }
[JsonConverter(typeof(CheckViewPropertiesCheckAdapter))]
public Check Check { get; set; }

/// <summary>
/// Gets or Sets Queries
/// </summary>
[DataMember(Name="queries", EmitDefaultValue=false)]
public List<DashboardQuery> Queries { get; set; }

/// <summary>
/// Colors define color encoding of data into a visualization
/// </summary>
/// <value>Colors define color encoding of data into a visualization</value>
[DataMember(Name="colors", EmitDefaultValue=false)]
public List<string> Colors { get; set; }

/// <summary>
/// Returns the string presentation of the object
/// </summary>
Expand All @@ -147,6 +172,8 @@ public override string ToString()
sb.Append(" Shape: ").Append(Shape).Append("\n");
sb.Append(" CheckID: ").Append(CheckID).Append("\n");
sb.Append(" Check: ").Append(Check).Append("\n");
sb.Append(" Queries: ").Append(Queries).Append("\n");
sb.Append(" Colors: ").Append(Colors).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
Expand Down Expand Up @@ -200,6 +227,16 @@ public bool Equals(CheckViewProperties input)

(this.Check != null &&
this.Check.Equals(input.Check))
) && base.Equals(input) &&
(
this.Queries == input.Queries ||
this.Queries != null &&
this.Queries.SequenceEqual(input.Queries)
) && base.Equals(input) &&
(
this.Colors == input.Colors ||
this.Colors != null &&
this.Colors.SequenceEqual(input.Colors)
);
}

Expand All @@ -220,6 +257,10 @@ public override int GetHashCode()
hashCode = hashCode * 59 + this.CheckID.GetHashCode();
if (this.Check != null)
hashCode = hashCode * 59 + this.Check.GetHashCode();
if (this.Queries != null)
hashCode = hashCode * 59 + this.Queries.GetHashCode();
if (this.Colors != null)
hashCode = hashCode * 59 + this.Colors.GetHashCode();
return hashCode;
}
}
Expand Down
19 changes: 18 additions & 1 deletion Client/InfluxDB.Client.Api/Domain/Task.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ protected Task() { }
/// <summary>
/// Initializes a new instance of the <see cref="Task" /> class.
/// </summary>
/// <param name="type">The type of task, this can be used for filtering tasks on list actions..</param>
/// <param name="orgID">The ID of the organization that owns this Task. (required).</param>
/// <param name="org">The name of the organization that owns this Task..</param>
/// <param name="name">The name of the task. (required).</param>
Expand All @@ -54,7 +55,7 @@ protected Task() { }
/// <param name="cron">A task repetition schedule in the form &#39;* * * * * *&#39;; parsed from Flux..</param>
/// <param name="offset">Duration to delay after the schedule, before executing the task; parsed from flux, if set to zero it will remove this option and use 0 as the default..</param>
/// <param name="links">links.</param>
public Task(string orgID = default(string), string org = default(string), string name = default(string), string description = default(string), TaskStatusType? status = default(TaskStatusType?), List<Label> labels = default(List<Label>), string authorizationID = default(string), string flux = default(string), string every = default(string), string cron = default(string), string offset = default(string), TaskLinks links = default(TaskLinks))
public Task(string type = default(string), string orgID = default(string), string org = default(string), string name = default(string), string description = default(string), TaskStatusType? status = default(TaskStatusType?), List<Label> labels = default(List<Label>), string authorizationID = default(string), string flux = default(string), string every = default(string), string cron = default(string), string offset = default(string), TaskLinks links = default(TaskLinks))
{
// to ensure "orgID" is required (not null)
if (orgID == null)
Expand Down Expand Up @@ -83,6 +84,7 @@ protected Task() { }
{
this.Flux = flux;
}
this.Type = type;
this.Org = org;
this.Description = description;
this.Status = status;
Expand All @@ -100,6 +102,13 @@ protected Task() { }
[DataMember(Name="id", EmitDefaultValue=false)]
public string Id { get; private set; }

/// <summary>
/// The type of task, this can be used for filtering tasks on list actions.
/// </summary>
/// <value>The type of task, this can be used for filtering tasks on list actions.</value>
[DataMember(Name="type", EmitDefaultValue=false)]
public string Type { get; set; }

/// <summary>
/// The ID of the organization that owns this Task.
/// </summary>
Expand Down Expand Up @@ -204,6 +213,7 @@ public override string ToString()
var sb = new StringBuilder();
sb.Append("class Task {\n");
sb.Append(" Id: ").Append(Id).Append("\n");
sb.Append(" Type: ").Append(Type).Append("\n");
sb.Append(" OrgID: ").Append(OrgID).Append("\n");
sb.Append(" Org: ").Append(Org).Append("\n");
sb.Append(" Name: ").Append(Name).Append("\n");
Expand Down Expand Up @@ -258,6 +268,11 @@ public bool Equals(Task input)
(this.Id != null &&
this.Id.Equals(input.Id))
) &&
(
this.Type == input.Type ||
(this.Type != null &&
this.Type.Equals(input.Type))
) &&
(
this.OrgID == input.OrgID ||
(this.OrgID != null &&
Expand Down Expand Up @@ -346,6 +361,8 @@ public override int GetHashCode()
int hashCode = 41;
if (this.Id != null)
hashCode = hashCode * 59 + this.Id.GetHashCode();
if (this.Type != null)
hashCode = hashCode * 59 + this.Type.GetHashCode();
if (this.OrgID != null)
hashCode = hashCode * 59 + this.OrgID.GetHashCode();
if (this.Org != null)
Expand Down
19 changes: 18 additions & 1 deletion Client/InfluxDB.Client.Api/Domain/TaskCreateRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ protected TaskCreateRequest() { }
/// <summary>
/// Initializes a new instance of the <see cref="TaskCreateRequest" /> class.
/// </summary>
/// <param name="type">The type of task, this can be used for filtering tasks on list actions..</param>
/// <param name="orgID">The ID of the organization that owns this Task..</param>
/// <param name="org">The name of the organization that owns this Task..</param>
/// <param name="status">status.</param>
/// <param name="flux">The Flux script to run for this task. (required).</param>
/// <param name="description">An optional description of the task..</param>
/// <param name="token">The token to use for authenticating this task when it executes queries. (required).</param>
public TaskCreateRequest(string orgID = default(string), string org = default(string), TaskStatusType? status = default(TaskStatusType?), string flux = default(string), string description = default(string), string token = default(string))
public TaskCreateRequest(string type = default(string), string orgID = default(string), string org = default(string), TaskStatusType? status = default(TaskStatusType?), string flux = default(string), string description = default(string), string token = default(string))
{
// to ensure "flux" is required (not null)
if (flux == null)
Expand All @@ -68,12 +69,20 @@ protected TaskCreateRequest() { }
{
this.Token = token;
}
this.Type = type;
this.OrgID = orgID;
this.Org = org;
this.Status = status;
this.Description = description;
}

/// <summary>
/// The type of task, this can be used for filtering tasks on list actions.
/// </summary>
/// <value>The type of task, this can be used for filtering tasks on list actions.</value>
[DataMember(Name="type", EmitDefaultValue=false)]
public string Type { get; set; }

/// <summary>
/// The ID of the organization that owns this Task.
/// </summary>
Expand Down Expand Up @@ -118,6 +127,7 @@ public override string ToString()
{
var sb = new StringBuilder();
sb.Append("class TaskCreateRequest {\n");
sb.Append(" Type: ").Append(Type).Append("\n");
sb.Append(" OrgID: ").Append(OrgID).Append("\n");
sb.Append(" Org: ").Append(Org).Append("\n");
sb.Append(" Status: ").Append(Status).Append("\n");
Expand Down Expand Up @@ -158,6 +168,11 @@ public bool Equals(TaskCreateRequest input)
return false;

return
(
this.Type == input.Type ||
(this.Type != null &&
this.Type.Equals(input.Type))
) &&
(
this.OrgID == input.OrgID ||
(this.OrgID != null &&
Expand Down Expand Up @@ -199,6 +214,8 @@ public override int GetHashCode()
unchecked // Overflow is fine, just wrap
{
int hashCode = 41;
if (this.Type != null)
hashCode = hashCode * 59 + this.Type.GetHashCode();
if (this.OrgID != null)
hashCode = hashCode * 59 + this.OrgID.GetHashCode();
if (this.Org != null)
Expand Down
Loading