Skip to content

Commit

Permalink
fix: regions endpoint signature changes (#81)
Browse files Browse the repository at this point in the history
Co-authored-by: Glaucio Jannotti <[email protected]>
  • Loading branch information
jannotti-glaucio and Glaucio Jannotti authored Oct 30, 2024
1 parent e62bf09 commit 3084b54
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
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

0 comments on commit 3084b54

Please sign in to comment.