Skip to content

Commit

Permalink
Merge pull request #280 from sentinel-hub/feature/configuration-servi…
Browse files Browse the repository at this point in the history
…ce-updates

Configuration service update
  • Loading branch information
mitjak authored Oct 2, 2024
2 parents 8ed8f23 + c2ff047 commit ae2c360
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 41 deletions.
4 changes: 2 additions & 2 deletions src/layer/__tests__/BYOCLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ describe('Test updateLayerFromServiceIfNeeded for ZARR', () => {
});
expect(layer.locationId).toEqual(null);
mockNetwork
.onGet('https://services.sentinel-hub.com/configuration/v1/wms/instances/INSTANCE_ID/layers')
.onGet('https://services.sentinel-hub.com/api/v2/configuration/instances/INSTANCE_ID/layers')
.replyOnce(200, mockedLayersResponse);
await layer.updateLayerFromServiceIfNeeded();
expect(layer.locationId).toEqual(LocationIdSHv3.awsEuCentral1);
Expand All @@ -224,7 +224,7 @@ describe('Test updateLayerFromServiceIfNeeded for ZARR', () => {
});
expect(layer.locationId).toEqual(LocationIdSHv3.creo);
mockNetwork
.onGet('https://services.sentinel-hub.com/configuration/v1/wms/instances/INSTANCE_ID/layers')
.onGet('https://services.sentinel-hub.com/api/v2/configuration/instances/INSTANCE_ID/layers')
.replyOnce(200, mockedLayersResponse);
await layer.updateLayerFromServiceIfNeeded();
expect(layer.locationId).toEqual(LocationIdSHv3.creo);
Expand Down
8 changes: 4 additions & 4 deletions src/layer/__tests__/LayersFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ describe('Test endpoints for getting layers parameters', () => {
},
[{ code: 200, data: [] }],
function expectedEndpoint(instanceId: string): string {
return `https://services.sentinel-hub.com/configuration/v1/wms/instances/${instanceId}/layers`;
return `https://services.sentinel-hub.com/api/v2/configuration/instances/${instanceId}/layers`;
},
],
[
Expand Down Expand Up @@ -217,7 +217,7 @@ describe('Test endpoints for getting layers parameters', () => {
},
[{ code: 200, data: [] }],
function expectedEndpoint(instanceId: string): string {
return `https://sh.dataspace.copernicus.eu/configuration/v1/wms/instances/${instanceId}/layers`;
return `https://sh.dataspace.copernicus.eu/api/v2/configuration/instances/${instanceId}/layers`;
},
],
[
Expand Down Expand Up @@ -255,7 +255,7 @@ describe('Test endpoints for getting layers parameters', () => {
},
[{ code: 200, data: [] }],
function expectedEndpoint(instanceId: string): string {
return `https://services.sentinel-hub.com/configuration/v1/wms/instances/${instanceId}/layers`;
return `https://services.sentinel-hub.com/api/v2/configuration/instances/${instanceId}/layers`;
},
],

Expand All @@ -281,7 +281,7 @@ describe('Test endpoints for getting layers parameters', () => {
},
[{ code: 200, data: [] }],
function expectedEndpoint(instanceId: string): string {
return `https://sh.dataspace.copernicus.eu/configuration/v1/wms/instances/${instanceId}/layers`;
return `https://sh.dataspace.copernicus.eu/api/v2/configuration/instances/${instanceId}/layers`;
},
],

Expand Down
4 changes: 2 additions & 2 deletions src/layer/__tests__/S2L1CCDASLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ describe('Test findDatesUTC using catalog', () => {
});

test.each([
['https://services.sentinel-hub.com/configuration/v1/datasets/S2L1C/dataproducts/99999', false],
['https://services.sentinel-hub.com/configuration/v1/datasets/S2L1C/dataproducts/643', true],
['https://services.sentinel-hub.com/api/v2/configuration/datasets/S2L1C/dataproducts/99999', false],
['https://services.sentinel-hub.com/api/v2/configuration/datasets/S2L1C/dataproducts/643', true],
])(
'AbstractSentinelHubV3Layer.supportsApiType correctly handles DataProducts supported by Processing API',
(dataProduct, expectedResult) => {
Expand Down
4 changes: 2 additions & 2 deletions src/layer/__tests__/S2L1CLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ describe('Test findDatesUTC using catalog', () => {
});

test.each([
['https://services.sentinel-hub.com/configuration/v1/datasets/S2L1C/dataproducts/99999', false],
['https://services.sentinel-hub.com/configuration/v1/datasets/S2L1C/dataproducts/643', true],
['https://services.sentinel-hub.com/api/v2/configuration/datasets/S2L1C/dataproducts/99999', false],
['https://services.sentinel-hub.com/api/v2/configuration/datasets/S2L1C/dataproducts/643', true],
])(
'AbstractSentinelHubV3Layer.supportsApiType correctly handles DataProducts supported by Processing API',
(dataProduct, expectedResult) => {
Expand Down
8 changes: 4 additions & 4 deletions src/layer/__tests__/fixtures.BYOCLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ export function constructFixtureUpdateLayerFromServiceIfNeeded({
const mockedResponse = [
{
'@id':
'https://services.sentinel-hub.com/configuration/v1/wms/instances/cc6082af-2788-4b20-b0fe-54e13454bc66/layers/BYOC3',
'https://services.sentinel-hub.com/api/v2/configuration/instances/cc6082af-2788-4b20-b0fe-54e13454bc66/layers/BYOC3',
id: 'BYOC3',
title: 'byoc3',
description: '',
Expand All @@ -313,7 +313,7 @@ export function constructFixtureUpdateLayerFromServiceIfNeeded({
orderHint: 0,
instance: {
'@id':
'https://services.sentinel-hub.com/configuration/v1/wms/instances/cc6082af-2788-4b20-b0fe-54e13454bc66',
'https://services.sentinel-hub.com/api/v2/configuration/instances/cc6082af-2788-4b20-b0fe-54e13454bc66',
},
dataset: {
'@id': 'https://services.sentinel-hub.com/configuration/v1/datasets/CUSTOM',
Expand All @@ -339,7 +339,7 @@ export function constructFixtureUpdateLayerFromServiceIfNeeded({
},
{
'@id':
'https://services.sentinel-hub.com/configuration/v1/wms/instances/cc6082af-2788-4b20-b0fe-54e13454bc66/layers/BYOC_AZER_SKY_TRUE_COLOR',
'https://services.sentinel-hub.com/api/v2/configuration/instances/cc6082af-2788-4b20-b0fe-54e13454bc66/layers/BYOC_AZER_SKY_TRUE_COLOR',
id: 'BYOC_AZER_SKY_TRUE_COLOR',
title: 'BYOC_AZER_SKY_TRUE_COLOR',
description: '',
Expand All @@ -354,7 +354,7 @@ export function constructFixtureUpdateLayerFromServiceIfNeeded({
orderHint: 0,
instance: {
'@id':
'https://services.sentinel-hub.com/configuration/v1/wms/instances/cc6082af-2788-4b20-b0fe-54e13454bc66',
'https://services.sentinel-hub.com/api/v2/configuration/instances/cc6082af-2788-4b20-b0fe-54e13454bc66',
},
dataset: {
'@id': 'https://services.sentinel-hub.com/configuration/v1/datasets/CUSTOM',
Expand Down
32 changes: 11 additions & 21 deletions src/layer/__tests__/fixtures.makeLayersSHv3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { DATASET_S2L2A } from '../dataset';

export const getLayersFromConfigurationService = [
{
'@id': 'https://services.sentinel-hub.com/configuration/v1/wms/instances/instanceId/layers/1_TRUE_COLOR',
id: '1_TRUE_COLOR',
title: 'True color',
description: 'Based on bands 4,3,2',
Expand All @@ -14,11 +13,9 @@ export const getLayersFromConfigurationService = [
},
],
orderHint: 0,
instance: {
'@id': 'https://services.sentinel-hub.com/configuration/v1/wms/instances/instanceId',
},
dataset: { '@id': 'https://services.sentinel-hub.com/configuration/v1/datasets/S2L2A' },
datasetSource: { '@id': 'https://services.sentinel-hub.com/configuration/v1/datasets/S2L2A/sources/2' },
instanceId: 'instanceId',
collectionType: 'S2L2A',
datasetSourceIdId: '2',
defaultStyleName: 'default',
datasourceDefaults: {
temporal: false,
Expand All @@ -27,7 +24,6 @@ export const getLayersFromConfigurationService = [
},
},
{
'@id': 'https://services.sentinel-hub.com/configuration/v1/wms/instances/instanceId/layers/8-NDSI',
id: '8-NDSI',
title: 'NDSI',
description: 'Based on combination of bands (B3 - B11)/(B3 + B11)',
Expand All @@ -40,11 +36,9 @@ export const getLayersFromConfigurationService = [
},
],
orderHint: 70,
instance: {
'@id': 'https://services.sentinel-hub.com/configuration/v1/wms/instances/instanceId',
},
dataset: { '@id': 'https://services.sentinel-hub.com/configuration/v1/datasets/S2L2A' },
datasetSource: { '@id': 'https://services.sentinel-hub.com/configuration/v1/datasets/S2L2A/sources/2' },
instanceId: 'instanceId',
collectionType: 'S2L2A',
datasetSourceId: '2',
defaultStyleName: 'default',
datasourceDefaults: {
upsampling: 'NEAREST',
Expand All @@ -56,7 +50,6 @@ export const getLayersFromConfigurationService = [
},
},
{
'@id': 'https://services.sentinel-hub.com/configuration/v1/wms/instances/instanceId',
id: 'B8A',
title: 'B8A',
description: 'Band 8A - Vegetation Red Edge - 865 nm|#bc0e10',
Expand All @@ -65,17 +58,14 @@ export const getLayersFromConfigurationService = [
name: 'default',
description: 'Default layer style',
dataProduct: {
'@id':
'https://services.sentinel-hub.com/configuration/v1/datasets/S2L2A/dataproducts/dataProductId',
id: 'dataProductId',
},
},
],
orderHint: 0,
instance: {
'@id': 'https://services.sentinel-hub.com/configuration/v1/wms/instances/instanceId',
},
dataset: { '@id': 'https://services.sentinel-hub.com/configuration/v1/datasets/S2L2A' },
datasetSource: { '@id': 'https://services.sentinel-hub.com/configuration/v1/datasets/S2L2A/sources/2' },
instanceId: 'instanceId',
collectionType: 'S2L2A',
datasetSourceId: '2',
defaultStyleName: 'default',
datasourceDefaults: {
mosaickingOrder: 'mostRecent',
Expand Down Expand Up @@ -215,7 +205,7 @@ export const expectedResultConfigurationService = (
evalscript: null as string,
evalscriptUrl: null as string,
dataProduct:
'https://services.sentinel-hub.com/configuration/v1/datasets/S2L2A/dataproducts/dataProductId',
'https://services.sentinel-hub.com/api/v2/configuration/datasets/S2L2A/dataproducts/dataProductId',
upsampling: null as string,
downsampling: null as string,
mosaickingOrder: 'mostRecent',
Expand Down
4 changes: 2 additions & 2 deletions src/layer/__tests__/fixtures.mosaickingOrder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const getMapParams: GetMapParams = {

const mockedLayersResponse = [
{
'@id': 'https://services.sentinel-hub.com/configuration/v1/wms/instances/INSTANCE_ID/layers/LAYER_ID',
'@id': 'https://services.sentinel-hub.com/api/v2/configuration/instances/INSTANCE_ID/layers/LAYER_ID',
id: 'LAYER_ID',
title: 'Title',
description: 'Description',
Expand All @@ -27,7 +27,7 @@ const mockedLayersResponse = [
],
orderHint: 0,
instance: {
'@id': 'https://services.sentinel-hub.com/configuration/v1/wms/instances/INSTANCE_ID',
'@id': 'https://services.sentinel-hub.com/api/v2/configuration/instances/INSTANCE_ID',
},
dataset: { '@id': 'https://services.sentinel-hub.com/configuration/v1/datasets/S2L2A' },
datasetSource: { '@id': 'https://services.sentinel-hub.com/configuration/v1/datasets/S2L2A/sources/2' },
Expand Down
2 changes: 1 addition & 1 deletion src/layer/__tests__/testUtils.layers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ export const checkLayersParamsEndpoint = async (
});
await layer.updateLayerFromServiceIfNeeded({});
expect(mockNetwork.history.get[0].url).toBe(
`${expectedEndpoint}/configuration/v1/wms/instances/${instanceId}/layers`,
`${expectedEndpoint}/api/v2/configuration/instances/${instanceId}/layers`,
);
};
2 changes: 1 addition & 1 deletion src/layer/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ export const DEFAULT_FIND_TILES_MAX_COUNT_PARAMETER = 50;
export type DataProductId = string;

export const SUPPORTED_DATA_PRODUCTS_PROCESSING: DataProductId[] = [
'https://services.sentinel-hub.com/configuration/v1/datasets/S2L1C/dataproducts/643',
'https://services.sentinel-hub.com/api/v2/configuration/datasets/S2L1C/dataproducts/643',
];

export type BYOCBand = {
Expand Down
6 changes: 4 additions & 2 deletions src/layer/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export async function fetchLayerParamsFromConfigurationService(
throw new Error('Must be authenticated to fetch layer params');
}
const configurationServiceHostName = shServiceHostName ?? SH_SERVICE_ROOT_URL.default;
const url = `${configurationServiceHostName}configuration/v1/wms/instances/${instanceId}/layers`;
const url = `${configurationServiceHostName}api/v2/configuration/instances/${instanceId}/layers`;
const headers = {
Authorization: `Bearer ${authToken}`,
};
Expand Down Expand Up @@ -229,7 +229,9 @@ export async function fetchLayerParamsFromConfigurationService(
maxCloudCoverPercent: l.datasourceDefaults.maxCloudCoverage,
}),
evalscript: l.styles[0].evalScript,
dataProduct: l.styles[0].dataProduct ? l.styles[0].dataProduct['@id'] : undefined,
dataProduct: l.styles[0].dataProduct
? `${configurationServiceHostName}api/v2/configuration/datasets/${l.collectionType}/dataproducts/${l.styles[0].dataProduct['id']}`
: undefined,
legend: l.styles.find((s: any) => s.name === l.defaultStyleName)
? l.styles.find((s: any) => s.name === l.defaultStyleName).legend
: null,
Expand Down

0 comments on commit ae2c360

Please sign in to comment.