Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing regions endpoint signature changes #81

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package com.ionos.edc.extension.s3.api;

import java.io.IOException;
import java.util.List;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
Expand Down Expand Up @@ -46,7 +45,7 @@ public S3ApiClient() {
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}

public List<S3Region> retrieveRegions(String token) {
public S3Regions retrieveRegions(String token) {

Request request = new Request.Builder().url(REGIONS_ENDPOINT_URL)
.addHeader(AUTHORIZATION_HEADER, BEARER_TOKEN_PREFIX + token)
Expand All @@ -61,7 +60,7 @@ public List<S3Region> retrieveRegions(String token) {
if (response.body() == null)
throw new IOException("Empty response body retrieving S3 regions");
else
return objectMapper.readValue(response.body().string(), new TypeReference<List<S3Region>>() {});
return objectMapper.readValue(response.body().string(), new TypeReference<S3Regions>() {});

} catch (IOException e) {
throw new EdcException("Error retrieving S3 accesskey", e);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2024 IONOS
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* IONOS
*
*/

package com.ionos.edc.extension.s3.api;

import java.util.List;

public class S3Regions {

private List<S3Region> items;

public List<S3Region> getItems() {
return items;
}

public void setItems(List<S3Region> items) {
this.items = items;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public void deleteAccessKey(String keyID) {
private String getEndpoint(String regionId, String token) {
var regions = S3ApiClient.retrieveRegions(token);

for (S3Region region: regions) {
for (S3Region region: regions.getItems()) {
if (region.getId().equals(regionId)) {
return "https://" + region.getProperties().getEndpoint();
}
Expand Down