Skip to content

Commit

Permalink
feat: update swagger with a delete endpoint (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
bednar authored Oct 24, 2019
1 parent af4ba93 commit ace4c94
Show file tree
Hide file tree
Showing 7 changed files with 274 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## 1.2.0 [unreleased]

### API
1. [#65](https://github.com/influxdata/influxdb-client-java/pull/65): Updated swagger to latest version


## 1.1.0 [2019-10-11]

### Features
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
/*
* Influx API Service
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* OpenAPI spec version: 0.1.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/


package com.influxdb.client.domain;

import java.util.Objects;
import java.util.Arrays;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.IOException;
import java.time.OffsetDateTime;

/**
* the delete predicate request
*/
@ApiModel(description = "the delete predicate request")

public class DeletePredicateRequest {
public static final String SERIALIZED_NAME_START = "start";
@SerializedName(SERIALIZED_NAME_START)
private OffsetDateTime start;

public static final String SERIALIZED_NAME_STOP = "stop";
@SerializedName(SERIALIZED_NAME_STOP)
private OffsetDateTime stop;

public static final String SERIALIZED_NAME_PREDICATE = "predicate";
@SerializedName(SERIALIZED_NAME_PREDICATE)
private String predicate;

public DeletePredicateRequest start(OffsetDateTime start) {
this.start = start;
return this;
}

/**
* RFC3339Nano.
* @return start
**/
@ApiModelProperty(required = true, value = "RFC3339Nano.")
public OffsetDateTime getStart() {
return start;
}

public void setStart(OffsetDateTime start) {
this.start = start;
}

public DeletePredicateRequest stop(OffsetDateTime stop) {
this.stop = stop;
return this;
}

/**
* RFC3339Nano.
* @return stop
**/
@ApiModelProperty(required = true, value = "RFC3339Nano.")
public OffsetDateTime getStop() {
return stop;
}

public void setStop(OffsetDateTime stop) {
this.stop = stop;
}

public DeletePredicateRequest predicate(String predicate) {
this.predicate = predicate;
return this;
}

/**
* sql where like delete statement
* @return predicate
**/
@ApiModelProperty(example = "tag1=\"value1\" and (tag2=\"value2\" and tag3=\"value3\")", value = "sql where like delete statement")
public String getPredicate() {
return predicate;
}

public void setPredicate(String predicate) {
this.predicate = predicate;
}


@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
DeletePredicateRequest deletePredicateRequest = (DeletePredicateRequest) o;
return Objects.equals(this.start, deletePredicateRequest.start) &&
Objects.equals(this.stop, deletePredicateRequest.stop) &&
Objects.equals(this.predicate, deletePredicateRequest.predicate);
}

@Override
public int hashCode() {
return Objects.hash(start, stop, predicate);
}


@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class DeletePredicateRequest {\n");
sb.append(" start: ").append(toIndentedString(start)).append("\n");
sb.append(" stop: ").append(toIndentedString(stop)).append("\n");
sb.append(" predicate: ").append(toIndentedString(predicate)).append("\n");
sb.append("}");
return sb.toString();
}

/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import okhttp3.ResponseBody;
import okhttp3.MultipartBody;

import com.influxdb.client.domain.DeletePredicateRequest;
import com.influxdb.client.domain.Error;
import com.influxdb.client.domain.Routes;

Expand All @@ -16,6 +17,25 @@
import java.util.Map;

public interface DefaultService {
/**
* delete Time series data from InfluxDB
*
* @param deletePredicateRequest predicate delete request (required)
* @param zapTraceSpan OpenTracing span context (optional)
* @param org specifies the destination organization for writes (optional)
* @param bucket specifies the destination bucket for writes (optional)
* @param orgID specifies the organization ID of the resource (optional)
* @param bucketID specifies the destination bucket ID for writes (optional)
* @return Call<Void>
*/
@Headers({
"Content-Type:application/json"
})
@POST("api/v2/delete")
Call<Void> deletePost(
@retrofit2.http.Body DeletePredicateRequest deletePredicateRequest, @retrofit2.http.Header("Zap-Trace-Span") String zapTraceSpan, @retrofit2.http.Query("org") String org, @retrofit2.http.Query("bucket") String bucket, @retrofit2.http.Query("orgID") String orgID, @retrofit2.http.Query("bucketID") String bucketID
);

/**
* Map of all top level routes available
*
Expand Down
91 changes: 91 additions & 0 deletions client/src/main/resources/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1640,6 +1640,68 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/Error"
/delete:
post:
summary: delete Time series data from InfluxDB
requestBody:
description: predicate delete request
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/DeletePredicateRequest"
parameters:
- $ref: '#/components/parameters/TraceSpan'
- in: query
name: org
description: specifies the destination organization for writes
schema:
type: string
description: all points within batch are written to this organization.
- in: query
name: bucket
description: specifies the destination bucket for writes
schema:
type: string
description: all points within batch are written to this bucket.
- in: query
name: orgID
description: specifies the organization ID of the resource
schema:
type: string
- in: query
name: bucketID
description: specifies the destination bucket ID for writes
schema:
type: string
description: all points within batch are written to this bucket.
responses:
'204':
description: delete has been accepted
'400':
description: invalid request.
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
'404':
description: the bucket or organization is not found.
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
'403':
description: no token was sent or does not have sufficient permissions.
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
default:
description: internal server error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
/ready:
servers:
- url: /
Expand Down Expand Up @@ -3975,6 +4037,12 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/ResourceMembers"
'404':
description: Organization not found
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
default:
description: Unexpected error
content:
Expand Down Expand Up @@ -4067,6 +4135,12 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/ResourceOwners"
'404':
description: Organization not found
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
default:
description: Unexpected error
content:
Expand Down Expand Up @@ -6160,6 +6234,23 @@ components:
$ref: "#/components/schemas/Identifier"
path:
$ref: "#/components/schemas/StringLiteral"
DeletePredicateRequest:
description: the delete predicate request
type: object
required: [start, stop]
properties:
start:
description: RFC3339Nano.
type: string
format: date-time
stop:
description: RFC3339Nano.
type: string
format: date-time
predicate:
description: sql where like delete statement
example: tag1="value1" and (tag2="value2" and tag3="value3")
type: string
Node:
oneOf:
- $ref: "#/components/schemas/Expression"
Expand Down
2 changes: 2 additions & 0 deletions client/src/test/java/com/influxdb/client/ITBucketsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ void findBucketByNameNotFound() {
}

@Test
@Disabled
//TODO https://github.com/influxdata/influxdb/issues/14900
void findBuckets() {

int size = bucketsApi.findBuckets().size();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ void setUp() {

organizationsApi = influxDBClient.getOrganizationsApi();
usersApi = influxDBClient.getUsersApi();

organizationsApi.findOrganizations().stream().filter(org -> org.getName().endsWith("-IT"))
.forEach(organizationsApi::deleteOrganization);
}

@Test
Expand Down
18 changes: 10 additions & 8 deletions client/src/test/java/com/influxdb/client/ITTasksApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class ITTasksApi extends AbstractITClientTest {
private TasksApi tasksApi;

@BeforeEach
void setUp() throws Exception {
void setUp() {

organization = findMyOrg();

Expand All @@ -84,7 +84,11 @@ void setUp() throws Exception {

tasksApi = influxDBClient.getTasksApi();

tasksApi.findTasks().forEach(task -> tasksApi.deleteTask(task));
tasksApi.findTasks().stream().filter(task -> task.getName().endsWith("-IT")).forEach(tasksApi::deleteTask);

OrganizationsApi organizationsApi = influxDBClient.getOrganizationsApi();
organizationsApi.findOrganizations().stream().filter(org -> org.getName().endsWith("-IT"))
.forEach(organizationsApi::deleteOrganization);
}

@Test
Expand Down Expand Up @@ -225,7 +229,7 @@ void findTasks() {

@Test
@Disabled
//TODO set user password -> https://github.com/influxdata/influxdb/issues/11590
//TODO set user password -> https://github.com/influxdata/influxdb/issues/11590
void findTasksByUserID() {

User taskUser = influxDBClient.getUsersApi().createUser(generateName("TaskUser"));
Expand All @@ -238,7 +242,7 @@ void findTasksByUserID() {

@Test
@Disabled
//TODO https://github.com/influxdata/influxdb/issues/11491
//TODO https://github.com/influxdata/influxdb/issues/11491
void findTasksByOrganizationID() throws Exception {

Organization taskOrganization = influxDBClient.getOrganizationsApi().createOrganization(generateName("TaskOrg"));
Expand All @@ -258,7 +262,7 @@ void findTasksByOrganizationID() throws Exception {

@Test
@Disabled
//TODO https://github.com/influxdata/influxdb/issues/13577
//TODO https://github.com/influxdata/influxdb/issues/13577
void findTasksAfterSpecifiedID() {

Task task1 = tasksApi.createTaskCron(generateName("it task"), TASK_FLUX, "0 2 * * *", organization);
Expand Down Expand Up @@ -401,9 +405,7 @@ void runs() throws Exception {
Assertions.assertThat(run.getScheduledFor()).withFailMessage(failMessage).isBefore(OffsetDateTime.now());
Assertions.assertThat(run.getStartedAt()).withFailMessage(failMessage).isBefore(OffsetDateTime.now());
Assertions.assertThat(run.getFinishedAt()).withFailMessage(failMessage).isBefore(OffsetDateTime.now());
Assertions.assertThat(run.getRequestedAt())
.isEqualTo(OffsetDateTime
.of(LocalDateTime.of(1, 1, 1, 0, 0), ZoneOffset.UTC));
Assertions.assertThat(run.getRequestedAt()).isNull();
Assertions.assertThat(run.getLinks()).withFailMessage(failMessage).isNotNull();
Assertions.assertThat(run.getLinks().getLogs()).withFailMessage(failMessage)
.isEqualTo("/api/v2/tasks/" + task.getId() + "/runs/" + run.getId() + "/logs");
Expand Down

0 comments on commit ace4c94

Please sign in to comment.