diff --git a/src/main/java/com/crowdin/client/Client.java b/src/main/java/com/crowdin/client/Client.java
index e02cd9fce..dc3351bf1 100644
--- a/src/main/java/com/crowdin/client/Client.java
+++ b/src/main/java/com/crowdin/client/Client.java
@@ -17,6 +17,7 @@
import com.crowdin.client.projectsgroups.ProjectsGroupsApi;
import com.crowdin.client.reports.ReportsApi;
import com.crowdin.client.screenshots.ScreenshotsApi;
+import com.crowdin.client.securitylogs.SecurityLogsApi;
import com.crowdin.client.sourcefiles.SourceFilesApi;
import com.crowdin.client.sourcestrings.SourceStringsApi;
import com.crowdin.client.storage.StorageApi;
@@ -63,6 +64,7 @@ public class Client extends CrowdinApi {
private final LabelsApi labelsApi;
private final StringCommentsApi stringCommentsApi;
private final BundlesApi bundlesApi;
+ private final SecurityLogsApi securityLogsApi;
private final NotificationsApi notificationsApi;
private final ApplicationsApi applicationsApi;
private final ClientsApi clientsApi;
@@ -95,6 +97,7 @@ public Client(Credentials credentials) {
this.labelsApi = new LabelsApi(credentials);
this.stringCommentsApi = new StringCommentsApi(credentials);
this.bundlesApi = new BundlesApi(credentials);
+ this.securityLogsApi = new SecurityLogsApi(credentials);
this.notificationsApi = new NotificationsApi(credentials);
this.applicationsApi = new ApplicationsApi(credentials);
this.clientsApi = new ClientsApi(credentials);
@@ -128,6 +131,7 @@ public Client(Credentials credentials, ClientConfig clientConfig) {
this.labelsApi = new LabelsApi(credentials, clientConfig);
this.stringCommentsApi = new StringCommentsApi(credentials, clientConfig);
this.bundlesApi = new BundlesApi(credentials, clientConfig);
+ this.securityLogsApi = new SecurityLogsApi(credentials, clientConfig);
this.notificationsApi = new NotificationsApi(credentials, clientConfig);
this.applicationsApi = new ApplicationsApi(credentials, clientConfig);
this.clientsApi = new ClientsApi(credentials, clientConfig);
diff --git a/src/main/java/com/crowdin/client/securitylogs/SecurityLogsApi.java b/src/main/java/com/crowdin/client/securitylogs/SecurityLogsApi.java
new file mode 100644
index 000000000..565182e5a
--- /dev/null
+++ b/src/main/java/com/crowdin/client/securitylogs/SecurityLogsApi.java
@@ -0,0 +1,106 @@
+package com.crowdin.client.securitylogs;
+
+import com.crowdin.client.core.CrowdinApi;
+import com.crowdin.client.core.http.HttpRequestConfig;
+import com.crowdin.client.core.http.exceptions.HttpBadRequestException;
+import com.crowdin.client.core.http.exceptions.HttpException;
+import com.crowdin.client.core.model.ClientConfig;
+import com.crowdin.client.core.model.Credentials;
+import com.crowdin.client.core.model.ResponseList;
+import com.crowdin.client.core.model.ResponseObject;
+import com.crowdin.client.securitylogs.model.SecurityLogResource;
+import com.crowdin.client.securitylogs.model.SecurityLogResourceObject;
+import com.crowdin.client.securitylogs.model.SecurityLogsResourceResponseList;
+
+import java.util.Map;
+import java.util.Optional;
+
+public class SecurityLogsApi extends CrowdinApi {
+
+ public SecurityLogsApi(Credentials credentials) {
+ super(credentials);
+ }
+
+ public SecurityLogsApi(Credentials credentials, ClientConfig clientConfig) {
+ super(credentials, clientConfig);
+ }
+
+ /**
+ * @param userId user Identifier
+ * @param limit maximum number of items to retrieve (default 25)
+ * @param offset starting offset in the collection (default 0)
+ * @param event value of event
+ * @param ipAddress value of ipAddress
+ * @return list of Security logs
+ * @see
+ */
+ public ResponseList listUserSecurityLogs(Long userId, Long limit, Integer offset, String event, String ipAddress) throws HttpException, HttpBadRequestException {
+ Map> queryParams = HttpRequestConfig.buildUrlParams(
+ "limit", Optional.ofNullable(limit),
+ "offset", Optional.ofNullable(offset),
+ "event", Optional.ofNullable(event),
+ "ipAddress", Optional.ofNullable(ipAddress)
+ );
+ SecurityLogsResourceResponseList securityLogsResponseList = this.httpClient.get(this.url + "/users/" + userId+ "/security-logs", new HttpRequestConfig(queryParams), SecurityLogsResourceResponseList.class);
+ return SecurityLogsResourceResponseList.to(securityLogsResponseList);
+ }
+
+ /**
+ * @param userId user Identifier
+ * @param securityLogId log Identifier
+ * @return Security log
+ * @see
+ */
+ public ResponseObject getUserSecurityLog(Long userId, Long securityLogId) throws HttpException, HttpBadRequestException {
+ SecurityLogResourceObject securityLogResourceObject = this.httpClient.get(this.url + "/users/" + userId+ "/security-logs/" + securityLogId, new HttpRequestConfig(), SecurityLogResourceObject.class);
+ return ResponseObject.of(securityLogResourceObject.getData());
+ }
+
+ /**
+ * @param limit maximum number of items to retrieve (default 25)
+ * @param offset starting offset in the collection (default 0)
+ * @param event value of event
+ * @param createdAfter String Date in UTC format
+ * @param createdBefore String Date in UTC format
+ * @param ipAddress value of ipAddress
+ * @param userId user Identifier
+ * @return list of Security logs
+ * @see
+ */
+ public ResponseList listOrganizationSecurityLogs(Long limit, Integer offset, String event, String createdAfter, String createdBefore, String ipAddress,Long userId) throws HttpException, HttpBadRequestException {
+ Map> queryParams = HttpRequestConfig.buildUrlParams(
+ "limit", Optional.ofNullable(limit),
+ "offset", Optional.ofNullable(offset),
+ "event", Optional.ofNullable(event),
+ "createdAfter", Optional.ofNullable(createdAfter),
+ "createdBefore", Optional.ofNullable(createdBefore),
+ "ipAddress", Optional.ofNullable(ipAddress),
+ "userId", Optional.ofNullable(userId)
+ );
+ SecurityLogsResourceResponseList securityLogsResponseList = this.httpClient.get(this.url + "/security-logs", new HttpRequestConfig(queryParams), SecurityLogsResourceResponseList.class);
+ return SecurityLogsResourceResponseList.to(securityLogsResponseList);
+ }
+
+ /**
+ * @param securityLogId log Identifier
+ * @return Security log
+ * @see
+ */
+ public ResponseObject getOrganizationSecurityLog(Long securityLogId) throws HttpException, HttpBadRequestException {
+ SecurityLogResourceObject securityLogResourceObject = this.httpClient.get(this.url + "/security-logs/" + securityLogId, new HttpRequestConfig(), SecurityLogResourceObject.class);
+ return ResponseObject.of(securityLogResourceObject.getData());
+ }
+
+
+
+}
diff --git a/src/main/java/com/crowdin/client/securitylogs/model/SecurityLogResource.java b/src/main/java/com/crowdin/client/securitylogs/model/SecurityLogResource.java
new file mode 100644
index 000000000..c9d8c7f69
--- /dev/null
+++ b/src/main/java/com/crowdin/client/securitylogs/model/SecurityLogResource.java
@@ -0,0 +1,15 @@
+package com.crowdin.client.securitylogs.model;
+
+import lombok.Data;
+
+@Data
+public class SecurityLogResource {
+ Long id;
+ String event;
+ String info;
+ Long userId;
+ String location;
+ String ipAddress;
+ String deviceName;
+ String createdAt;
+}
diff --git a/src/main/java/com/crowdin/client/securitylogs/model/SecurityLogResourceObject.java b/src/main/java/com/crowdin/client/securitylogs/model/SecurityLogResourceObject.java
new file mode 100644
index 000000000..8778c3510
--- /dev/null
+++ b/src/main/java/com/crowdin/client/securitylogs/model/SecurityLogResourceObject.java
@@ -0,0 +1,8 @@
+package com.crowdin.client.securitylogs.model;
+
+import lombok.Data;
+
+@Data
+public class SecurityLogResourceObject {
+ private SecurityLogResource data;
+}
diff --git a/src/main/java/com/crowdin/client/securitylogs/model/SecurityLogsResourceResponseList.java b/src/main/java/com/crowdin/client/securitylogs/model/SecurityLogsResourceResponseList.java
new file mode 100644
index 000000000..a9a837410
--- /dev/null
+++ b/src/main/java/com/crowdin/client/securitylogs/model/SecurityLogsResourceResponseList.java
@@ -0,0 +1,25 @@
+package com.crowdin.client.securitylogs.model;
+
+import com.crowdin.client.core.model.Pagination;
+import com.crowdin.client.core.model.ResponseList;
+import com.crowdin.client.core.model.ResponseObject;
+import lombok.Data;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Data
+public class SecurityLogsResourceResponseList {
+ private List data;
+ private Pagination pagination;
+
+ public static ResponseList to(SecurityLogsResourceResponseList securityLogsResourceResponseList) {
+ return ResponseList.of(
+ securityLogsResourceResponseList.getData().stream()
+ .map(SecurityLogResourceObject::getData)
+ .map(ResponseObject::of)
+ .collect(Collectors.toList()),
+ securityLogsResourceResponseList.getPagination()
+ );
+ }
+}
diff --git a/src/test/java/com/crowdin/client/securitylogs/SecurityLogsTest.java b/src/test/java/com/crowdin/client/securitylogs/SecurityLogsTest.java
new file mode 100644
index 000000000..56dde6e44
--- /dev/null
+++ b/src/test/java/com/crowdin/client/securitylogs/SecurityLogsTest.java
@@ -0,0 +1,57 @@
+package com.crowdin.client.securitylogs;
+
+import com.crowdin.client.core.model.ResponseList;
+import com.crowdin.client.core.model.ResponseObject;
+import com.crowdin.client.framework.RequestMock;
+import com.crowdin.client.framework.TestClient;
+import com.crowdin.client.securitylogs.model.SecurityLogResource;
+import org.apache.http.client.methods.HttpGet;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class SecurityLogsTest extends TestClient {
+
+ private final long userId = 4;
+ private final long securityLogId = 5;
+
+ @Override
+ public List getMocks() {
+ return Arrays.asList(
+ RequestMock.build(this.url + "/users/" + userId + "/security-logs", HttpGet.METHOD_NAME, "api/securitylogs/listSecurityLogs.json"),
+ RequestMock.build(this.url + "/users/" + userId + "/security-logs/" + securityLogId, HttpGet.METHOD_NAME, "api/securitylogs/getSecurityLogBylogId.json"),
+ RequestMock.build(this.url + "/security-logs", HttpGet.METHOD_NAME, "api/securitylogs/listOrganizationLogs.json"),
+ RequestMock.build(this.url + "/security-logs/" + securityLogId, HttpGet.METHOD_NAME, "api/securitylogs/getOrganizationLogBylogId.json")
+
+ );
+ }
+
+ @Test
+ public void listSecurityLogs(){
+ ResponseList securityLogResourceResponseList = this.getSecurityLogsApi().listUserSecurityLogs(userId,null, null, null, null);
+ assertEquals(securityLogResourceResponseList.getData().size(),2);
+ assertEquals(securityLogResourceResponseList.getData().get(0).getData().getUserId(),userId);
+ }
+
+ @Test
+ public void getSecurityLogByLogId(){
+ ResponseObject securityLogResourceResponseObject = this.getSecurityLogsApi().getUserSecurityLog(userId,securityLogId);
+ assertEquals(securityLogResourceResponseObject.getData().getId(), securityLogId);
+ }
+
+ @Test
+ public void listOrganizationLogs(){
+ ResponseList securityLogResourceResponseList = this.getSecurityLogsApi().listOrganizationSecurityLogs(null,null,null,null,null,null,null);
+ assertEquals(securityLogResourceResponseList.getData().size(), 2);
+ }
+
+ @Test
+ public void getOrganizationLogbylogId(){
+ ResponseObject securityLogResourceResponseObject = this.getSecurityLogsApi().getOrganizationSecurityLog(securityLogId);
+ assertEquals(securityLogResourceResponseObject.getData().getId(), securityLogId);
+ }
+
+}
diff --git a/src/test/resources/api/securitylogs/getOrganizationLogBylogId.json b/src/test/resources/api/securitylogs/getOrganizationLogBylogId.json
new file mode 100644
index 000000000..6a0b215c0
--- /dev/null
+++ b/src/test/resources/api/securitylogs/getOrganizationLogBylogId.json
@@ -0,0 +1,12 @@
+{
+ "data": {
+ "id": 5,
+ "event": "Some event",
+ "info": "Some info",
+ "userId": 4,
+ "location": "USA",
+ "ipAddress": "127.0.0.1",
+ "deviceName": "MacOs on MacBook",
+ "createdAt": "2019-09-19T15:10:43+00:00"
+ }
+}
\ No newline at end of file
diff --git a/src/test/resources/api/securitylogs/getSecurityLogBylogId.json b/src/test/resources/api/securitylogs/getSecurityLogBylogId.json
new file mode 100644
index 000000000..6a0b215c0
--- /dev/null
+++ b/src/test/resources/api/securitylogs/getSecurityLogBylogId.json
@@ -0,0 +1,12 @@
+{
+ "data": {
+ "id": 5,
+ "event": "Some event",
+ "info": "Some info",
+ "userId": 4,
+ "location": "USA",
+ "ipAddress": "127.0.0.1",
+ "deviceName": "MacOs on MacBook",
+ "createdAt": "2019-09-19T15:10:43+00:00"
+ }
+}
\ No newline at end of file
diff --git a/src/test/resources/api/securitylogs/listOrganizationLogs.json b/src/test/resources/api/securitylogs/listOrganizationLogs.json
new file mode 100644
index 000000000..76769e3f1
--- /dev/null
+++ b/src/test/resources/api/securitylogs/listOrganizationLogs.json
@@ -0,0 +1,33 @@
+{
+ "data": [
+ {
+ "data": {
+ "id": 2,
+ "event": "Some event",
+ "info": "Some info",
+ "userId": 4,
+ "location": "USA",
+ "ipAddress": "127.0.0.1",
+ "deviceName": "MacOs on MacBook",
+ "createdAt": "2019-09-19T15:10:43+00:00"
+ }
+ },
+ {
+ "data": {
+ "id": 3,
+ "event": "Some event",
+ "info": "Some info",
+ "userId": 4,
+ "location": "USA",
+ "ipAddress": "127.0.0.1",
+ "deviceName": "MacOs on MacBook",
+ "createdAt": "2019-09-20T15:10:43+00:00"
+ }
+ }
+
+ ],
+ "pagination": {
+ "offset": 0,
+ "limit": 25
+ }
+}
\ No newline at end of file
diff --git a/src/test/resources/api/securitylogs/listSecurityLogs.json b/src/test/resources/api/securitylogs/listSecurityLogs.json
new file mode 100644
index 000000000..76769e3f1
--- /dev/null
+++ b/src/test/resources/api/securitylogs/listSecurityLogs.json
@@ -0,0 +1,33 @@
+{
+ "data": [
+ {
+ "data": {
+ "id": 2,
+ "event": "Some event",
+ "info": "Some info",
+ "userId": 4,
+ "location": "USA",
+ "ipAddress": "127.0.0.1",
+ "deviceName": "MacOs on MacBook",
+ "createdAt": "2019-09-19T15:10:43+00:00"
+ }
+ },
+ {
+ "data": {
+ "id": 3,
+ "event": "Some event",
+ "info": "Some info",
+ "userId": 4,
+ "location": "USA",
+ "ipAddress": "127.0.0.1",
+ "deviceName": "MacOs on MacBook",
+ "createdAt": "2019-09-20T15:10:43+00:00"
+ }
+ }
+
+ ],
+ "pagination": {
+ "offset": 0,
+ "limit": 25
+ }
+}
\ No newline at end of file