Skip to content

Commit 92a3f82

Browse files
committed
Added Log API
1 parent 435eab2 commit 92a3f82

33 files changed

+982
-25
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All _notable_ changes to this project will be documented in this file.
55
The format is based on _[Keep a Changelog][keepachangelog]_, and this project
66
adheres to _[Semantic Versioning][semver]_.
77

8+
## [2.1.0] (released: 2025-08-26)
9+
### Updated
10+
- Added Log API
11+
- Updated unit tests
12+
813
## [2.0.0] (released: 2025-06-11)
914
### Updated
1015
- Added unit tests and updated existing
@@ -91,6 +96,7 @@ adheres to _[Semantic Versioning][semver]_.
9196
- Import a list of complaints from CSV file API
9297
- Add Import a list of bounces from CSV file API
9398

99+
[2.1.0]: https://github.com/mailgun/mailgun-java/compare/v2.0.0...v2.1.0
94100
[2.0.0]: https://github.com/mailgun/mailgun-java/compare/v1.1.6...v2.0.0
95101
[1.1.6]: https://github.com/mailgun/mailgun-java/compare/v1.1.5...v1.1.6
96102
[1.1.5]: https://github.com/mailgun/mailgun-java/compare/v1.1.4...v1.1.5

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Add the following to your `pom.xml`:
7676
<dependency>
7777
<groupId>com.mailgun</groupId>
7878
<artifactId>mailgun-java</artifactId>
79-
<version>2.0.0</version>
79+
<version>2.1.0</version>
8080
</dependency>
8181
...
8282
</dependencies>
@@ -85,7 +85,7 @@ Add the following to your `pom.xml`:
8585
Gradle Groovy DSL .
8686

8787
```xml
88-
implementation 'com.mailgun:mailgun-java:2.0.0'
88+
implementation 'com.mailgun:mailgun-java:2.1.0'
8989
```
9090

9191

pom.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.mailgun</groupId>
88
<artifactId>mailgun-java</artifactId>
9-
<version>2.0.0</version>
9+
<version>2.1.0</version>
1010
<packaging>jar</packaging>
1111

1212
<name>${project.groupId}:${project.artifactId}</name>
@@ -97,6 +97,12 @@
9797
<version>${slf4j.version}</version>
9898
</dependency>
9999

100+
<dependency>
101+
<groupId>org.skyscreamer</groupId>
102+
<artifactId>jsonassert</artifactId>
103+
<version>1.5.0</version>
104+
</dependency>
105+
100106
<!-- TESTS -->
101107
<dependency>
102108
<groupId>org.junit.jupiter</groupId>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.mailgun.api.v1;
2+
3+
import com.mailgun.api.MailgunApi;
4+
import com.mailgun.enums.ApiVersion;
5+
import com.mailgun.model.logs.LogsRequest;
6+
import com.mailgun.model.logs.LogsResponse;
7+
8+
import feign.Headers;
9+
import feign.RequestLine;
10+
11+
/**
12+
* <p>
13+
* This API endpoint is logs service.
14+
* </p>
15+
* <p>
16+
* Mailgun keeps track of every inbound and outbound message event and stores this log data.
17+
* This data can be queried and filtered to provide insights into the health of your email infrastructure.
18+
* </p>
19+
*
20+
* @see <a href="https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/logs">Work with Logs</a>
21+
*/
22+
@Headers({"Accept: application/json", "Content-Type: application/json"})
23+
public interface MailgunLogsApi extends MailgunApi {
24+
25+
static ApiVersion getApiVersion() {
26+
return ApiVersion.V_1;
27+
}
28+
29+
/**
30+
* <p>
31+
* Gets filtered logs for an account.
32+
* </p>
33+
* <p>
34+
* Returns a collection of logs and aggregated statistics about your email activities.
35+
* The response contains a paginated collection of individual records and a metrics object
36+
* with aggregated statistics for events specified in the request.
37+
* </p>
38+
*
39+
* @param logsRequest {@link LogsRequest} Request parameters to filter the logs
40+
* @return {@link LogsResponse} Response containing logs and aggregated statistics
41+
*/
42+
@RequestLine("POST /analytics/logs")
43+
LogsResponse getLogs(LogsRequest logsRequest);
44+
45+
}

src/main/java/com/mailgun/model/metrics/MetricsFilter.java renamed to src/main/java/com/mailgun/model/Filter.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.mailgun.model.metrics;
1+
package com.mailgun.model;
22

33
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
44
import com.fasterxml.jackson.annotation.JsonProperty;
@@ -11,16 +11,14 @@
1111

1212
/**
1313
* <p>
14-
* Metric filter.
14+
* Filter.
1515
* </p>
16-
*
17-
* @see <a href="https://documentation.mailgun.com/en/latest/api-stats.html#metrics">Metrics</a>
1816
*/
1917
@Value
2018
@Builder
2119
@Jacksonized
2220
@JsonIgnoreProperties(ignoreUnknown = true)
23-
public class MetricsFilter {
21+
public class Filter {
2422

2523
/**
2624
* <p>

src/main/java/com/mailgun/model/metrics/FilterItem.java renamed to src/main/java/com/mailgun/model/FilterItem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.mailgun.model.metrics;
1+
package com.mailgun.model;
22

33
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
44

src/main/java/com/mailgun/model/Paging.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,11 @@ public class Paging {
4545
*/
4646
String previous;
4747

48+
/**
49+
* <p>
50+
* Total number of items
51+
* </p>
52+
*/
53+
Long total;
54+
4855
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.mailgun.model.logs;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
6+
import lombok.Builder;
7+
import lombok.Value;
8+
import lombok.extern.jackson.Jacksonized;
9+
10+
/**
11+
* <p>
12+
* Account information in logs response.
13+
* </p>
14+
* @see <a href="https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/logs/post-v1-analytics-logs#logs/post-v1-analytics-logs/t=response&c=200&path=items/account">Iteam account</a>
15+
*/
16+
@Value
17+
@Builder
18+
@Jacksonized
19+
@JsonIgnoreProperties(ignoreUnknown = true)
20+
public class ItemAccount {
21+
22+
String id;
23+
24+
@JsonProperty("parent-id")
25+
String parentId;
26+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.mailgun.model.logs;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
5+
import lombok.Builder;
6+
import lombok.Value;
7+
import lombok.extern.jackson.Jacksonized;
8+
9+
/**
10+
* <p>
11+
* Logs pagination.
12+
* </p>
13+
*
14+
* @see <a href="https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/logs/post-v1-analytics-logs#logs/post-v1-analytics-logs/t=response&c=200&path=items/campaigns">Logs item campaigns</a>
15+
*/
16+
@Value
17+
@Builder
18+
@Jacksonized
19+
@JsonIgnoreProperties(ignoreUnknown = true)
20+
public class ItemCampaign {
21+
22+
String id;
23+
24+
String name;
25+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.mailgun.model.logs;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
6+
import lombok.Builder;
7+
import lombok.Value;
8+
import lombok.extern.jackson.Jacksonized;
9+
10+
/**
11+
* <p>
12+
* Client information in logs response.
13+
* </p>
14+
*
15+
* @see <a href="https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/logs/post-v1-analytics-logs#logs/post-v1-analytics-logs/t=response&c=200&path=items/client-info">Logs client info</a>
16+
*/
17+
@Value
18+
@Builder
19+
@Jacksonized
20+
@JsonIgnoreProperties(ignoreUnknown = true)
21+
public class ItemClientInfo {
22+
23+
@JsonProperty("client-name")
24+
String clientName;
25+
26+
@JsonProperty("client-os")
27+
String clientOs;
28+
29+
@JsonProperty("client-type")
30+
String clientType;
31+
32+
@JsonProperty("device-type")
33+
String deviceType;
34+
35+
@JsonProperty("user-agent")
36+
String userAgent;
37+
38+
String ip;
39+
String bot;
40+
}

0 commit comments

Comments
 (0)