Skip to content

add query by name for buckets,tasks and orgs api #277

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

Closed
lonelyleaf opened this issue Nov 4, 2021 · 5 comments · Fixed by #278
Closed

add query by name for buckets,tasks and orgs api #277

lonelyleaf opened this issue Nov 4, 2021 · 5 comments · Fixed by #278
Labels
enhancement New feature or request
Milestone

Comments

@lonelyleaf
Copy link
Contributor

Proposal:
Add query param for taskApi and orgApi for query by name。

Use case:
In my case,I need add bucket by code in runtime,but I need find all task first,and then filter them by name。Influxdb's rest api have this feature but why you not open it in java client?

@bednar
Copy link
Contributor

bednar commented Nov 4, 2021

Hi @lonelyleaf,

The TaskApi and OrgApi do not copy InfluxDB 2 HTTP API at 100% level, but you are able to directly use OrganizationsService and TasksService.

Something like will works:

package example;

import com.influxdb.client.InfluxDBClient;
import com.influxdb.client.InfluxDBClientFactory;
import com.influxdb.client.domain.Organization;
import com.influxdb.client.domain.Task;
import com.influxdb.client.service.OrganizationsService;
import com.influxdb.client.service.TasksService;

public class PlatformExample {

    public static void main(final String[] args) throws Exception {

        String url = "http://localhost:8086";
        String token = "my-token";

        String orgName = "my-org";
        String taskName = "my-task";

        try (InfluxDBClient client = InfluxDBClientFactory.create(url, token.toCharArray()))
        {
            OrganizationsService organizations = client.getService(OrganizationsService.class);
            Organization org = organizations.getOrgs(null, null, null, null, orgName, null, null)
                    .execute()
                    .body()
                    .getOrgs()
                    .get(0);

            System.out.println("org = " + org);

            TasksService tasks = client.getService(TasksService.class);
            Task task = tasks.getTasks(null, taskName, null, null, null, null, null, null)
                    .execute()
                    .body()
                    .getTasks()
                    .get(0);

            System.out.println("task = " + task);
        }
    }
}

Regards

@bednar bednar added the wontfix This will not be worked on label Nov 4, 2021
@lonelyleaf
Copy link
Contributor Author

@bednar thank you,your replay is very helpful.But why not add one method with param like

findTask(TaskQuery taskQuery)

public class TaskQuery {
    String after;
    String name;
    String org;
    String orgId;
    String String;
    String status;
    String type;
    String user;
}

no need to hide so many information from rest api,but add so many method with different params

@bednar
Copy link
Contributor

bednar commented Nov 4, 2021

@bednar thank you,your replay is very helpful.But why not add one method with param like

findTask(TaskQuery taskQuery)

public class TaskQuery {
    String after;
    String name;
    String org;
    String orgId;
    String String;
    String status;
    String type;
    String user;
}

no need to hide so many information from rest api,but add so many method with different params

@lonelyleaf thanks for the suggestion 👍. Is this something you might be willing to help with?

@bednar bednar added enhancement New feature or request and removed wontfix This will not be worked on labels Nov 4, 2021
@lonelyleaf
Copy link
Contributor Author

@bednar
can this pull request be helped?
#278

@bednar
Copy link
Contributor

bednar commented Nov 4, 2021

@lonelyleaf, of course. It is awesome improvement 👍.

I will review your PR later today.

Thanks for PR 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants