package com.example.gitlab; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; import org.json.JSONArray; import org.json.JSONObject; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.example.gitlab.Milestones; import java.io.IOException; import java.util.List; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import java.io.IOException; import java.util.List; public class gitLabKalendar { private final String projectId="projectId"; private static final String GITLAB_API_URL = "..../api/v4/projects/"; private static final String accessToken = ""; public List fetchMilestones() throws IOException { String url = GITLAB_API_URL + projectId + "/milestones"; try (CloseableHttpClient client = HttpClients.createDefault()) { HttpGet request = new HttpGet(url); request.addHeader("PRIVATE-TOKEN", accessToken); String responseBody = client.execute(request, httpResponse -> EntityUtils.toString(httpResponse.getEntity()) ); return parseMilestones(responseBody); } } private List parseMilestones(String json) throws IOException { ObjectMapper mapper = new ObjectMapper(); return mapper.readValue(json, new TypeReference>() {}); } }