Skip to content

Commit

Permalink
feat: add query method with all params for BucketsApi, OrganizationAp…
Browse files Browse the repository at this point in the history
…i and TasksApi (#278)
  • Loading branch information
lonelyleaf authored Nov 5, 2021
1 parent 59b0d63 commit 7e4b969
Show file tree
Hide file tree
Showing 10 changed files with 453 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

### Features
1. [#272](https://github.com/influxdata/influxdb-client-java/pull/272): Add `PingService` to check status of OSS and Cloud instance
2. [#278](https://github.com/influxdata/influxdb-client-java/pull/278): Add query method with all params for BucketsApi, OrganizationApi and TasksApi

### CI
1. [#275](https://github.com/influxdata/influxdb-client-java/pull/275): Deploy `influxdb-client-test` package into Maven repository
Expand Down
10 changes: 9 additions & 1 deletion client/src/main/java/com/influxdb/client/BucketsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,14 @@ Bucket createBucket(@Nonnull final String name,
@Nonnull
List<Bucket> findBucketsByOrgName(@Nullable final String orgName);

/**
* List all buckets.
*
* @return List all buckets
*/
@Nonnull
List<Bucket> findBuckets(@Nonnull final BucketsQuery query);

/**
* List all users with member privileges for a bucket.
*
Expand Down Expand Up @@ -368,4 +376,4 @@ Bucket createBucket(@Nonnull final String name,
* @param labelID the ID of a label
*/
void deleteLabel(@Nonnull final String labelID, @Nonnull final String bucketID);
}
}
134 changes: 134 additions & 0 deletions client/src/main/java/com/influxdb/client/BucketsQuery.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/*
* The MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.influxdb.client;

import javax.annotation.Nullable;

public class BucketsQuery {

/**
* Offset. (optional)
*/
@Nullable
private Integer offset;

/**
* Limit. (optional, default to 20)
*/
@Nullable
private Integer limit;

/**
* The last resource ID from which to seek from (but not including).
* This is to be used instead of &#x60;offset&#x60;. (optional)
*/
@Nullable
private String after;

/**
* The name of the organization. (optional)
*/
@Nullable
private String org;

/**
* The organization ID. (optional)
*/
@Nullable
private String orgID;

/**
* Only returns buckets with a specific name. (optional)
*/
@Nullable
private String name;

/**
* Only returns buckets with a specific ID. (optional)
*/
@Nullable
private String id;

@Nullable
public Integer getOffset() {
return offset;
}

public void setOffset(@Nullable final Integer offset) {
this.offset = offset;
}

@Nullable
public Integer getLimit() {
return limit;
}

public void setLimit(@Nullable final Integer limit) {
this.limit = limit;
}

@Nullable
public String getAfter() {
return after;
}

public void setAfter(@Nullable final String after) {
this.after = after;
}

@Nullable
public String getOrg() {
return org;
}

public void setOrg(@Nullable final String org) {
this.org = org;
}

@Nullable
public String getOrgID() {
return orgID;
}

public void setOrgID(@Nullable final String orgID) {
this.orgID = orgID;
}

@Nullable
public String getName() {
return name;
}

public void setName(@Nullable final String name) {
this.name = name;
}

@Nullable
public String getId() {
return id;
}

public void setId(@Nullable final String id) {
this.id = id;
}

}
12 changes: 10 additions & 2 deletions client/src/main/java/com/influxdb/client/OrganizationsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ public interface OrganizationsApi {
@Nonnull
List<Organization> findOrganizations();

/**
* List all organizations.
*
* @return List all organizations
*/
@Nonnull
List<Organization> findOrganizations(@Nonnull final OrganizationsQuery query);

/**
* List of secret keys the are stored for Organization.
* <p>
Expand Down Expand Up @@ -185,7 +193,7 @@ public interface OrganizationsApi {
* Delete provided secrets.
*
* @param secretKeys secret key to deleted (required)
* @param orgID ID of the organization (required)
* @param orgID ID of the organization (required)
*/
void deleteSecrets(@Nonnull final SecretKeys secretKeys, @Nonnull final String orgID);

Expand Down Expand Up @@ -297,4 +305,4 @@ public interface OrganizationsApi {
*/
void deleteOwner(@Nonnull final String ownerID, @Nonnull final String orgID);

}
}
117 changes: 117 additions & 0 deletions client/src/main/java/com/influxdb/client/OrganizationsQuery.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/*
* The MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.influxdb.client;

import javax.annotation.Nullable;

public class OrganizationsQuery {

/**
* Offset. (optional)
*/
@Nullable
private Integer offset;

/**
* Limit. (optional, default to 20)
*/
@Nullable
private Integer limit;

/**
* Descending. (optional, default to false)
*/
@Nullable
private Boolean descending;

/**
* Filter organizations to a specific organization name. (optional)
*/
@Nullable
private String org;
/**
* Filter organizations to a specific organization ID. (optional)
*/
@Nullable
private String orgID;

/**
* Filter organizations to a specific user ID. (optional)
*/
@Nullable
private String userID;

@Nullable
public Integer getOffset() {
return offset;
}

public void setOffset(@Nullable final Integer offset) {
this.offset = offset;
}

@Nullable
public Integer getLimit() {
return limit;
}

public void setLimit(@Nullable final Integer limit) {
this.limit = limit;
}

@Nullable
public Boolean getDescending() {
return descending;
}

public void setDescending(@Nullable final Boolean descending) {
this.descending = descending;
}

@Nullable
public String getOrg() {
return org;
}

public void setOrg(@Nullable final String org) {
this.org = org;
}

@Nullable
public String getOrgID() {
return orgID;
}

public void setOrgID(@Nullable final String orgID) {
this.orgID = orgID;
}

@Nullable
public String getUserID() {
return userID;
}

public void setUserID(@Nullable final String userID) {
this.userID = userID;
}

}
12 changes: 10 additions & 2 deletions client/src/main/java/com/influxdb/client/TasksApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,15 @@ List<Task> findTasks(@Nullable final String afterID,
@Nullable final String userID,
@Nullable final String orgID);

/**
* Lists tasks, limit 100.
*
* @param query query params for task
* @return A list of tasks
*/
@Nonnull
List<Task> findTasks(@Nonnull final TasksQuery query);

/**
* List all task members.
*
Expand Down Expand Up @@ -402,7 +411,6 @@ List<Run> getRuns(@Nonnull final Task task,
* Retrieve list of run records for a task.
*
* @param taskID ID of task to get runs for
*
* @return the list of run records for a task
*/
@Nonnull
Expand Down Expand Up @@ -585,4 +593,4 @@ List<Run> getRuns(@Nonnull final String taskID,
* @param labelID the ID of a label
*/
void deleteLabel(@Nonnull final String labelID, @Nonnull final String taskID);
}
}
Loading

0 comments on commit 7e4b969

Please sign in to comment.