-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from CoScale/1.1.0
1.1.0
- Loading branch information
Showing
9 changed files
with
335 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
package com.coscale.client.requests; | ||
|
||
import java.util.List; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
import com.coscale.sdk.client.commons.Protocol; | ||
import com.coscale.sdk.client.metrics.State; | ||
import com.google.common.base.MoreObjects; | ||
import com.google.common.base.Objects; | ||
|
||
public class Request { | ||
|
||
@Nullable | ||
public Protocol protocol; | ||
|
||
public State state; | ||
|
||
@Nullable | ||
public String classifierConfig; | ||
|
||
@Nullable | ||
public Long version; | ||
|
||
@Nullable | ||
public Long id; | ||
|
||
@Nullable | ||
public Long parentId; | ||
|
||
@Nullable | ||
public RequestClassifierType classifierType; | ||
|
||
@Nullable | ||
public List<Request> requests; | ||
|
||
@Nullable | ||
public String source; | ||
|
||
@Nullable | ||
public String description; | ||
|
||
@Nullable | ||
public Integer priority; | ||
|
||
@Nullable | ||
public String name; | ||
|
||
public Request(State state) { | ||
this.state = state; | ||
} | ||
|
||
public Request(Protocol protocol, State state, String classifierConfig, Long version, Long id, | ||
Long parentId, RequestClassifierType classifierType, List<Request> requests, | ||
String source, String description, Integer priority, String name) { | ||
this.protocol = protocol; | ||
this.state = state; | ||
this.classifierConfig = classifierConfig; | ||
this.version = version; | ||
this.id = id; | ||
this.parentId = parentId; | ||
this.classifierType = classifierType; | ||
this.requests = requests; | ||
this.source = source; | ||
this.description = description; | ||
this.priority = priority; | ||
this.name = name; | ||
} | ||
|
||
public Request() { | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return MoreObjects.toStringHelper(this).add("protocol", protocol).add("state", state) | ||
.add("classifierConfig", classifierConfig).add("version", version).add("id", id) | ||
.add("parentId", parentId).add("classifierType", classifierType) | ||
.add("requests", requests).add("source", source).add("description", description) | ||
.add("priority", priority).add("name", name).toString(); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (obj == null) { | ||
return false; | ||
} | ||
if (getClass() != obj.getClass()) { | ||
return false; | ||
} | ||
final Request other = (Request) obj; | ||
|
||
return Objects.equal(this.protocol, other.protocol) | ||
&& Objects.equal(this.state, other.state) | ||
&& Objects.equal(this.classifierConfig, other.classifierConfig) | ||
&& Objects.equal(this.version, other.version) && Objects.equal(this.id, other.id) | ||
&& Objects.equal(this.parentId, other.parentId) | ||
&& Objects.equal(this.classifierType, other.classifierType) | ||
&& Objects.equal(this.requests, other.requests) | ||
&& Objects.equal(this.source, other.source) | ||
&& Objects.equal(this.description, other.description) | ||
&& Objects.equal(this.priority, other.priority) | ||
&& Objects.equal(this.name, other.name); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hashCode(protocol, state, classifierConfig, version, id, parentId, | ||
classifierType, requests, source, description, priority, name); | ||
} | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/coscale/client/requests/RequestClassifierType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.coscale.client.requests; | ||
|
||
public enum RequestClassifierType { | ||
|
||
HOST, | ||
PAGE, | ||
URL, | ||
METHOD; | ||
|
||
} |
88 changes: 88 additions & 0 deletions
88
src/main/java/com/coscale/client/requests/RequestsApi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package com.coscale.client.requests; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
import com.coscale.sdk.client.ApiClient; | ||
import com.coscale.sdk.client.commons.Options; | ||
import com.fasterxml.jackson.core.type.TypeReference; | ||
|
||
/** | ||
* CoScale API client for Requests CoScale endpoint. | ||
* | ||
* @author cristi | ||
* | ||
*/ | ||
public class RequestsApi { | ||
|
||
/** ApiClient used to make HTTP requests. */ | ||
private final ApiClient api; | ||
|
||
/** | ||
* RequestsApi constructor. | ||
* | ||
* @param api | ||
* ApiClient. | ||
*/ | ||
public RequestsApi(ApiClient api) { | ||
this.api = api; | ||
} | ||
|
||
/** Requests end point calls */ | ||
|
||
/** | ||
* all is used to get a list of all requests. | ||
* | ||
* @return List<Request> | ||
* @throws IOException | ||
*/ | ||
public List<Request> all() throws IOException { | ||
return api.callWithAuth("GET", "/requests/", null, new TypeReference<List<Request>>() { | ||
}); | ||
} | ||
|
||
/** | ||
* all is used to get a list of all requests. | ||
* | ||
* @param options | ||
* which contain query parameters | ||
* @return List<Request> | ||
* @throws IOException | ||
*/ | ||
public List<Request> all(Options options) throws IOException { | ||
String url = "/requests/"; | ||
url += (options.hasQuery() ? "?" : "&") + options.query(); | ||
return api.callWithAuth("GET", url, null, new TypeReference<List<Request>>() { | ||
}); | ||
} | ||
|
||
/** | ||
* get a request by the id. | ||
* | ||
* @param id | ||
* id of the request. | ||
* @return Request | ||
* @throws IOException | ||
*/ | ||
public Request get(long id) throws IOException { | ||
return api.callWithAuth("GET", "/requests/" + id + '/', null, new TypeReference<Request>() { | ||
}); | ||
} | ||
|
||
/** | ||
* get a request by the id. | ||
* | ||
* @param id | ||
* id of the request. | ||
* @param options | ||
* which contain query parameters | ||
* @return Request | ||
* @throws IOException | ||
*/ | ||
public Request get(long id, Options options) throws IOException { | ||
String url = "/requests/" + id + '/'; | ||
url += (options.hasQuery() ? "?" : "&") + options.query(); | ||
return api.callWithAuth("GET", url, null, new TypeReference<Request>() { | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.coscale.sdk.client.commons; | ||
|
||
public enum Protocol { | ||
|
||
HTTP, | ||
DATABASE, | ||
PAGE; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.